A Parameter Cannot Be Found That Matches Parameter Name AsPlainText Fix

Updated On: November 24, 2025

A Parameter Cannot Be Found That Matches Parameter Name ‘AsPlainText’ – Troubleshooting Guide

When working with PowerShell commands, especially with cmdlets related to credentials or text input, you may encounter an error message similar to:

Error: A parameter cannot be found that matches parameter name ‘AsPlainText’.

This error can be confusing if you are not familiar with the cmdlet’s available parameters or if you are using an outdated version of PowerShell. This article will explore the causes of this error, how to diagnose it, and solutions to resolve the issue.

Understanding the Error Message

The error “A parameter cannot be found that matches parameter name ‘AsPlainText'” typically occurs when a cmdlet is called with a parameter that it does not recognize. This can happen for several reasons:

  • The cmdlet does not support the -AsPlainText parameter.
  • You are using an outdated version of PowerShell or the module where the cmdlet is defined.
  • The syntax or casing of the parameter is incorrect.
  • The wrong cmdlet is being used or the command is mistyped.

Understanding these causes is vital to fixing the problem efficiently.

Common Scenario: SecureString and PSCredential Cmdlets

One of the most frequent scenarios where this error appears is when using ConvertTo-SecureString or creating a new PSCredential object.

For example, consider this command:

$securePassword = ConvertTo-SecureString "P@ssw0rd" -AsPlainText -Force

If the -AsPlainText parameter is not recognized, the error occurs.

Why Does This Happen?

The ConvertTo-SecureString cmdlet does support -AsPlainText, but only in PowerShell versions 3.0 and above. If you are using PowerShell 2.0 or earlier, this parameter is not available.

Moreover, if you misspell the parameter, for example, writing -Asplaintext instead of -AsPlainText, PowerShell will not recognize it.

Checking PowerShell Version

To confirm your PowerShell version, run:

$PSVersionTable.PSVersion

If your version is below 3.0, consider upgrading PowerShell to access the -AsPlainText parameter.

Example Table: Parameter Support by PowerShell Versions

PowerShell Version Supports -AsPlainText in ConvertTo-SecureString
1.0 and 2.0 No
3.0 and later Yes

Correct Usage of ConvertTo-SecureString with -AsPlainText

When using ConvertTo-SecureString with plaintext, the proper syntax is:

$securePassword = ConvertTo-SecureString "YourPasswordHere" -AsPlainText -Force

The -Force parameter is necessary because converting plaintext passwords to secure strings is potentially insecure and PowerShell will otherwise throw a warning or error.

Example


$password = "P@ssw0rd"
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential ("username", $securePassword)

Common Mistakes to Avoid

  • Incorrect Parameter Name: PowerShell parameters are case-insensitive but spelling must be correct. Do not use extra spaces or misspell.
  • Missing -Force Parameter: When using -AsPlainText, -Force is mandatory to suppress warnings.
  • Using Outdated PowerShell Versions: Upgrade if your version is below 3.0.
  • Using the Wrong Cmdlet: Ensure you are using ConvertTo-SecureString and not another cmdlet that does not support -AsPlainText.

Additional Troubleshooting Steps

Validate Cmdlet Availability

Run the following to check if the cmdlet supports the parameter:

Get-Help ConvertTo-SecureString -Full

Look for -AsPlainText in the parameter list.

Verify Module Versions

Sometimes, third-party or custom modules have cmdlets with similar names but different parameters.

Check which module the cmdlet belongs to:

Get-Command ConvertTo-SecureString | Select-Object Module

Ensure you are not using a custom or legacy module version that lacks the parameter.

Use Alternative Approaches if Necessary

If upgrading PowerShell is not an option, you can input a secure string via other methods, such as:

  • Using Read-Host -AsSecureString to prompt for password input.
  • Manually converting plaintext strings using .NET methods (though this is less straightforward).

Example: Using Read-Host with SecureString

$securePassword = Read-Host "Enter password" -AsSecureString
$credential = New-Object System.Management.Automation.PSCredential ("username", $securePassword)

This avoids the need for -AsPlainText altogether.

Summary of Solutions

Issue Cause Solution
Parameter not recognized PowerShell version below 3.0 Upgrade PowerShell to version 3.0 or later
Parameter typo Incorrect spelling of -AsPlainText Correct spelling and casing
Missing -Force parameter Using -AsPlainText without -Force Add -Force parameter
Wrong cmdlet Using a cmdlet that doesn’t accept -AsPlainText Use ConvertTo-SecureString or update the cmdlet usage

Understanding SecureString and Why It Matters

SecureString is a PowerShell object designed to protect sensitive text, such as passwords, in memory. It encrypts the value and restricts access so that the password is not stored or displayed in plain text.

By converting plaintext passwords to SecureString, scripts can handle credentials more securely. However, PowerShell requires explicit instructions to convert plaintext strings safely, which is why the -AsPlainText and -Force parameters exist.

Why Forcing the Usage of Plain Text Conversion Is Necessary

PowerShell intentionally requires the -Force parameter when converting plaintext to secure strings to remind users that this operation potentially exposes sensitive information in memory or logs. This helps prevent accidental security risks.

Security Tip: Avoid hardcoding passwords in scripts. Use secure methods such as prompting for credentials or storing encrypted passwords in files.

Practical Example: Creating a PSCredential Object

Creating a PSCredential object is common when automating tasks that require authentication.

Here is a complete example:


$username = "domain\user"
$passwordPlain = "P@ssw0rd123"

# Convert plaintext password to secure string
$passwordSecure = ConvertTo-SecureString $passwordPlain -AsPlainText -Force

# Create credential object
$credential = New-Object System.Management.Automation.PSCredential ($username, $passwordSecure)

# Use credential in command
Invoke-Command -ComputerName Server01 -Credential $credential -ScriptBlock { Get-Process }

If the above code throws the “A parameter cannot be found that matches parameter name ‘AsPlainText'” error, verify your PowerShell environment.

Additional Notes on PowerShell Versions

PowerShell has evolved significantly over time. Many cmdlets and parameters available in PowerShell 3.0+ are missing from earlier versions.

If you are using Windows PowerShell 2.0 (default on Windows 7 and Windows Server 2008 R2), consider upgrading to at least PowerShell 5.1 or switching to PowerShell Core (7.x) for enhanced features and security.

Steps to Upgrade PowerShell

  1. Check current version: $PSVersionTable.PSVersion
  2. Download the latest Windows Management Framework (WMF) to upgrade PowerShell.
  3. Install WMF following Microsoft instructions.
  4. Restart your system or PowerShell session.
  5. Confirm new version with $PSVersionTable.PSVersion.

Alternative Method: Using Secure Password Files

For automation without exposing plaintext passwords, you can store credentials securely in a file:


# Save credential to a file
$credential = Get-Credential
$credential | Export-CliXml -Path "C:\secure\mycredential.xml"

# Import credential from file
$credential = Import-CliXml -Path "C:\secure\mycredential.xml"

This method avoids using -AsPlainText entirely and is more secure for scripts.

Summary

The “A parameter cannot be found that matches parameter name ‘AsPlainText'” error is almost always related to either PowerShell version incompatibility or incorrect cmdlet usage.

Key points to remember:

  • Ensure PowerShell version is 3.0 or higher.
  • Use the correct cmdlet ConvertTo-SecureString with parameters -AsPlainText and -Force.
  • Check spelling and syntax carefully.
  • Consider alternative secure methods like Read-Host -AsSecureString or credential export/import.

Following this guidance will help you avoid this common error and improve the security and reliability of your PowerShell scripts.

Photo of author

Emily Johnson

Hi, I'm Emily, I created Any Team Names. With a heart full of team spirit, I'm on a mission to provide the perfect names that reflect the identity and aspirations of teams worldwide.

I love witty puns and meaningful narratives, I believe in the power of a great name to bring people together and make memories.

When I'm not curating team names, you can find me exploring languages and cultures, always looking for inspiration to serve my community.

Leave a Comment

Share via
Copy link