To run a scheduled PS script against the vCenter server, you either hard code the credential in your script or use the credential file. Needless to say that credential file is better in terms of security, as the password is encrypted in the file.
Two steps to complete:
1) Create a credential file.
Add-PSSnapIn VMware.VimAutomation.Core
New-VICredentialStoreItem -host my-vcs-server -user jackie.chen -password ****** -file C:\Scripts\credfile.xml
2) Specify which credential file to use in the PS script.
Add-PSSnapIn VMware.VimAutomation.Core
$creds = Get-VICredentialStoreItem -file “C:\Scripts\credfile.xml”
Connect-viserver -Server $creds.Host -User $creds.User -Password $creds.Password
Nearly seven years later and it is still useful. Thanks for the post.
Ibelieve this should now be Install-Module VMware.VimAutomation.Core -Scope CurrentUser