Hi!
One of our customers requires you to change your password, which contains the symbol -$. How can I escape a character in a variable?
$password = "www#$123"
$scriptText = @"
echo osadmin:$password | chpasswd
"@
Invoke-VMScript -VM myvm -ScriptType bash -ScriptText $script -GuestUser root -GuestPassword Zz123456
Use single quotes instead of double quotes
Try like this
$scriptText = @"
echo osadmin:$password | chpasswd
"@
Invoke-VMScript -VM myvm -ScriptType bash -ScriptText $script -GuestUser root -GuestPassword Zz123456
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Use single quotes instead of double quotes
Try like this
$scriptText = @"
echo osadmin:$password | chpasswd
"@
Invoke-VMScript -VM myvm -ScriptType bash -ScriptText $script -GuestUser root -GuestPassword Zz123456
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
single quotes not working
i use
echo osadmin:$password > /tmp/result.txt
and see, that $ symbol is missing
Where did you use single quotes (see my example above)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference