Public/Get-StringFromSecureString.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
function Get-StringFromSecureString { <# .Synopsis Decrypt SecureString .DESCRIPTION Convert securestring to string with [Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::GetStringFromSecureString .EXAMPLE $test = Get-Credential # Username - Tester, Password test1 $test.Password | Get-StringFromSecureString .EXAMPLE Get-StringFromSecureString -SecureString $test.Password .INPUTS securestring .OUTPUTS string #> [CmdletBinding()] [Alias('Convert-SecureString')] [OutputType([String])] Param( [Parameter( Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName )] [Alias('Password')] [ValidateNotNullOrEmpty()] [securestring]$SecureString ) Process { [Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::GetStringFromSecureString($SecureString) } } |