Security
Always use PSCredential for credentials/passwords
param (
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
$Credentials
) # Get the cleartext password for a method call:
$Insecure.SetPassword($Credentials.GetNetworkCredential().Password)Other Secure Strings
# Decrypt a secure string.
$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($this)
$plaintext = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
[System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($BSTR)
$plaintextLast updated
Was this helpful?