Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. Function Publish-admcred {
  2. Begin{
  3. $path = "$home\Desktop\mycred.json"
  4. # Remove existing cred file if exists
  5. if (test-path $path){Remove-Item $path -force}
  6. }
  7. Process{
  8. $cred = Get-Credential
  9. $cred |
  10. Select Username,@{n="Password"; e={$_.password | ConvertFrom-SecureString}} |
  11. ConvertTo-Json |
  12. Set-Content -Path $path -Encoding UTF8
  13. }
  14. }
  15. Function set-admcreds {
  16. Begin{$path = "$home\Desktop\mycred.json"}
  17. Process{
  18. $o = Get-Content -Path $path -Encoding UTF8 -Raw | ConvertFrom-Json
  19. $cred = New-Object -TypeName PSCredential $o.UserName, ($o.Password | ConvertTo-SecureString)
  20. }
  21. End{Return $cred}
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement