Today I got this challenge and I did it in below way-
#Start here
$VC = Read-host "Enter your vCenter server name\IP "
Connect-VIServer $VC
$vmName = Read-host "Enter the target VM Name in vCenter "
$UN = read-host "Enter the target username "
$pswd = 'Password' #Enter password here which you want to set in '' mark
$Chpass = @"
`$securePswd = ConvertTo-SecureString -AsPlainText -String $pswd -Force
Get-LocalUser -Name $newUser | Set-LocalUser -Password `$securePswd -Confirm:`$false
"@
Invoke-VMScript -VM TestVM -ScriptText $Chpass -GuestUser "$UN" -GuestPassword "Asdf@1234" -ScriptType Powershell | Select -ExpandProperty scriptoutput
#End here
Please note that -
"Asdf@1234" is existing password of the guestOS
In case any error, do let me know, will surely help you out
Thank you,
Team vCloudNotes
#Start here
$VC = Read-host "Enter your vCenter server name\IP "
Connect-VIServer $VC
$vmName = Read-host "Enter the target VM Name in vCenter "
$UN = read-host "Enter the target username "
$pswd = 'Password' #Enter password here which you want to set in '' mark
$Chpass = @"
`$securePswd = ConvertTo-SecureString -AsPlainText -String $pswd -Force
Get-LocalUser -Name $newUser | Set-LocalUser -Password `$securePswd -Confirm:`$false
"@
Invoke-VMScript -VM TestVM -ScriptText $Chpass -GuestUser "$UN" -GuestPassword "Asdf@1234" -ScriptType Powershell | Select -ExpandProperty scriptoutput
#End here
Please note that -
"Asdf@1234" is existing password of the guestOS
In case any error, do let me know, will surely help you out
Thank you,
Team vCloudNotes
0 Comments:
Post a Comment