Created
March 29, 2017 11:08
-
-
Save jkavanagh58/dceb9d9ae0535de68ba2d3aaa0ea8cca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment