I am getting an issue when trying to pass a securestring
in to a powershell script, but it's coming back with this error?
Cannot process argument transformation on parameter 'Password'.
Cannot convert the "ConvertTo-SecureString" value
of type "System.String" to type "System.Security.SecureString".
$SecureServiceAccountPassword = ConvertTo-SecureString "somethingstong!" `
-AsPlainText -Force
$AgentAccount = "myAccount"
$ServiceAccountOU = "MYOU"
POWERSHELL -COMMAND $ADAccountScript `
-ServiceAccountOU $ServiceAccountOU `
-Account $AgentAccount `
-Password $SecureAgentAccountPassword
The script that it's calling is this.
param(
##MasterKey for KeePass currently stored in a DB.
[Parameter(Position=0,mandatory=$true)] [string] $ServiceAccountOU,
##Account to be created in AD
[Parameter(Position=1,mandatory=$true)] [string] $Account,
[Parameter(Position=2,mandatory=$true)] [SecureString] $Password
)
NEW-ADUSER -Name $Account `
-AccountPassword $Password `
-Path $SrviceAccountOU `
-Enabled $True `
-PasswordNeverExpires $True `
-CannotChangePassword $True