Need help to create and then using stored credentials

I'm looking to automate several scripts to use the

storage of credentials for script of Alans vCheck

This post is exactly what I would do:

# # Save the credentials of the Bank of VI credentials once
Se connect-VIServer -Server myVC0.domain.com -Credential ()Get-Credential domain\user0() -SaveCredentials

You could also add the elements of the VI credentials store using the New-VICredentialStoreItem cmdlet.  Using this cmdlet looks like:

# # Add the credentials to the store
New-VICredentialStoreItem -Host myVC0.domain.com -user domain\user0 -password supersecretpass

I'm looking for a way to run my scripts PowerCLI by selecting a VC and calling the - user and - password. I don't know what format to create this? This is what I call the Victoria Cross.

[CmdletBinding()]

(param
[Parameter (Position = 0, mandatory = $true)]
[System.String]
$VirtualCenterServer,
[Parameter (Position = 1)]
[System.String]
$ClusterName,
[Parameter (Position = 2)]
[System.Boolean]
$asLocalUser = $true
)

$user = C:\vmware\user.txt (not sure what type of file is needed)

$password = C:\vmware\password.txt (not sure what type of file is needed)

New-VICredentialStoreItem -Server $VirtualCenterServer -user $user -password $password


before calling the script/scripts for the - user and - password
SE connect-VIServer-Server $VirtualCenterServer - user $user-Password $password | Out-Null

The release of the new VICredentialStoreItem is an XML file.

You can use the store credenial as follows

# Save

New-VICredentialStoreItem-host $VirtualCenterServer - User Admin - password pass - file C:\cred.xml

# Callback & use

$cred = get-VICredentialStoreItem-User admin-host $VirtualCenterServer - file C:\cred.xml

SE connect-VIServer-Server $cred. Home - user $cred. Username-password $cred. Password | Out-Null

Tags: VMware

Similar Questions

Maybe you are looking for