I like to prompt my script for the Active Directory User ID and password, and use it further on in the script to connect-VIServers
something like...
$MyAdUserID = Read-Host "Enter Active Directory UserID"
$MyAdPassword = Read-Host "Enter Password" -AsSecureString
# now i want to connect to a sequence of vSphere5 hosts
connect-viserver <hostname> -user $MyAdUserID -password $MyAdPassword
It cannot authenticate with the SecureString password
How to make it work?
There is some conversion required to use the password.
The easiest way is to use the Credential parameter.
$MyAdUserID = Read-Host "Enter Active Directory UserID"
$MyAdPassword = Read-Host "Enter Password" -AsSecureString
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList $MyAdUserID,$MyAdPassword
Connect-VIServer <hostname> -Credential $cred
And have a look at Arnim's post Bulk change your ESX root password, I think it does what you are looking for.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
There is some conversion required to use the password.
The easiest way is to use the Credential parameter.
$MyAdUserID = Read-Host "Enter Active Directory UserID"
$MyAdPassword = Read-Host "Enter Password" -AsSecureString
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList $MyAdUserID,$MyAdPassword
Connect-VIServer <hostname> -Credential $cred
And have a look at Arnim's post Bulk change your ESX root password, I think it does what you are looking for.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
What a cool and simple solution!
Thanks again LucD!
No it is for audit things like reporting local users etc.
Thanks