Advertisement
Merzavets

Securing password

Aug 23rd, 2012
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Set-myCredential: This will prompt you for credentials and store them in the file specified.
  2. #####################
  3. #Set-myCredential.ps1
  4. Param($File)
  5. $Credential = Get-Credential
  6. $credential.Password | ConvertFrom-SecureString | Set-Content $File
  7. #####################
  8.  
  9. #Get-myCredential: This will get you credentials from a file specified. It require you know the user name.
  10. #####################
  11. #Get-myCredential.ps1
  12. Param($User,$File)
  13. $password = Get-Content $File | ConvertTo-SecureString
  14. $credential = New-Object System.Management.Automation.PsCredential($user,$password)
  15. $credential
  16. #####################
  17.  
  18. #With these two script you can do something like this (using VMware Toolkit for example.)
  19.  
  20. #c:\scripts\Set-myCredential.ps1 c:\tools\mp.txt
  21. #$creds = c:\scripts\Get-myCredential.ps1 MyUserName c:\tools\mp.txt
  22. #Get-ViServer MyVirtualCenter -cred $creds
  23.  
  24. # Borrowed from http://bsonposh.com/archives/338 :-)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement