Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Set-myCredential: This will prompt you for credentials and store them in the file specified.
- #####################
- #Set-myCredential.ps1
- Param($File)
- $Credential = Get-Credential
- $credential.Password | ConvertFrom-SecureString | Set-Content $File
- #####################
- #Get-myCredential: This will get you credentials from a file specified. It require you know the user name.
- #####################
- #Get-myCredential.ps1
- Param($User,$File)
- $password = Get-Content $File | ConvertTo-SecureString
- $credential = New-Object System.Management.Automation.PsCredential($user,$password)
- $credential
- #####################
- #With these two script you can do something like this (using VMware Toolkit for example.)
- #c:\scripts\Set-myCredential.ps1 c:\tools\mp.txt
- #$creds = c:\scripts\Get-myCredential.ps1 MyUserName c:\tools\mp.txt
- #Get-ViServer MyVirtualCenter -cred $creds
- # Borrowed from http://bsonposh.com/archives/338 :-)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement