The password i am entering has a dollar sign but the script errors out with the message of incorrect login.
Any help would be great
by DonJ at 2013-01-02 07:38:06
Precede it with an escape ` character or put it in single quotes. Whichever you prefer.
In double quotes, PowerShell is seeing $password as a variable and attempting to replace it with the variable's contents. It won't do that in single quotes.
by dcoz at 2013-01-03 00:06:34
Thank Don, Just to be clear are you meaning when prompted to enter your password enter it in the prompt box with single quotes or escape character or change the code to the below? username = read-Host "Please enter Username" $password = Read-Host -Prompt "Please enter Password?" -AsSecureString $VMHost | Get-VMHostAuthentication | Set-VMHostAuthentication -JoinDomain -Domain test.com -Username "$username" -Password '$password'
If I put the variable in single quotes wouldn't this just take the -password parameter as a literal string?
by megamorf at 2013-01-03 00:53:53
Don Jones told you to remove the quotation marks around the variables. These tell powershell to expand your variables and you don't want that when you pass variables as arguments.