...hopefully some useful VMware related stuff

Connect-viserver parameters

11/03/2010 15:16

Useful parameters for connecting to viserver with PowerShell in the VI-Toolkit.

connect-viserver -user -password

eg:

connect-viserver -server vCenter -port 443 -user admin -password @dm1n

 

To direct input from a command line within a script you can use the following:

 

$vc = read-host "Enter vCenter name or ESX host name"
$us = read-host "Enter Username"
$pw = read-host "Enter Password" -assecurestring:$true
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList $us,$pw
Connect-VIServer -Server $vc -Credential $cred

 

This will prompt the user to enter the server name, user name and password whilst in the script and the password will be astrisked out.

 

Thanks LucD for the $cred part!

 

Search site