Last active
December 18, 2019 17:56
-
-
Save rezarahimian/1a0dd65b6f11deade01a7250a7cdf03a 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
#Exporting PSCredential to XML | |
$Password = ConvertTo-SecureString 'XXX' -AsPlainText -Force | |
$Credential = New-Object -TypeName System.Management.Automation.PSCredential('svc_prd', $Password) | |
$Credential | Export-Clixml -Path 'C:\PS\Cred.xml' | |
#Importing PSCredential from XML | |
#$Credential = [System.Management.Automation.PSCredential](Import-Clixml -Path 'C:\PS\Cred.xml') | |
#Converting password to PlainText (e.g., API Payload) | |
#$Password = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment