VMware Cloud Community
Pilu1978
Enthusiast
Enthusiast

Powercli secure password

Hi,

I have a powercli script to do the morning check of all my VCs. I have more than one VC  (e.g. VC1, VC2, VC3 etc) in my environment. Now to login to a VC I have used the following logic in the script:

First I am creating the xml file with the following command from powercli prompt:

New-VICredentialStoreItem -Host VCServerName -Password PASSWORD -User domain\username -file c:\cred.xml

Now my script will read the cred .xml file and login to the VC with the following mentioned in my script:

$creds = Get-VICredentialStoreItem -file C:\cred.xml

Connect-VIServer -Server $creds.Host -user $creds.User -password $creds.Password

Now my query is how to use the single cred.xml file for login to all the VCs as I have more than one VC in my environment.

And also is it possible to schedule the script in Windows 2008 Task scheduler as a scheduled job.

Please help.

0 Kudos
5 Replies
LucD
Leadership
Leadership

Afaik, you will have to create such a file for each server/user combination.

The New-VICredentialStoreItem creates an item per host/user.

How to run a PowerCLI script as a scheduled task is documented in Alan's Running a PowerCLI Scheduled task post.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Pilu1978
Enthusiast
Enthusiast

Hi LucD,

Thanks for your early response.

Same username and password for all the VCs. Is there any way that I can use the same cred.xml file for all the VCs.

0 Kudos
LucD
Leadership
Leadership

I'm afraid not, the server is also in the generated object.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
smithjr
Contributor
Contributor

Hi all,  how i can hide my password?. Currently im using plain text in the Connect-viserver command.

Thanks

0 Kudos
LucD
Leadership
Leadership

Use the Credential parameter instead of the User and Password parameters.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos