Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function Publish-admcred {
- Begin{
- $path = "$home\Desktop\mycred.json"
- # Remove existing cred file if exists
- if (test-path $path){Remove-Item $path -force}
- }
- Process{
- $cred = Get-Credential
- $cred |
- Select Username,@{n="Password"; e={$_.password | ConvertFrom-SecureString}} |
- ConvertTo-Json |
- Set-Content -Path $path -Encoding UTF8
- }
- }
- Function set-admcreds {
- Begin{$path = "$home\Desktop\mycred.json"}
- Process{
- $o = Get-Content -Path $path -Encoding UTF8 -Raw | ConvertFrom-Json
- $cred = New-Object -TypeName PSCredential $o.UserName, ($o.Password | ConvertTo-SecureString)
- }
- End{Return $cred}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement