Active IQ Unified Manager Discussions

using password out of saved credentials

THORSTEN_KRAUSE
3,137 Views

Hello,

can you tell me how to get the password out of Get-WfaCredentials return value?

$myCredentials = Get-WfaCredentials -Host "X100X" -ErrorAction stop

Is there a way to do this?

Thanks,

Thorsten

1 ACCEPTED SOLUTION

sinhaa
3,137 Views

In the command "Send Email" There is a function defined which can tell you how to do it.

function ConvertFromSecureToPlain{

    param(

        [Parameter(Mandatory=$true)]

        [System.Security.SecureString] $SecurePassword

    )

    # Create a "password pointer"

    $PasswordPointer = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecurePassword)

    # Get the plain text version of the password

    $PlainTextPassword = [Runtime.InteropServices.Marshal]::PtrToStringAuto($PasswordPointer)

    # Free the pointer

    [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($PasswordPointer)

    # Return the plain text password

    $PlainTextPassword

}

Call this using something like:

$myPassword =  ConvertFromSecureToPlain -SecurePassword $myCredentials.Password

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

View solution in original post

2 REPLIES 2

sinhaa
3,138 Views

In the command "Send Email" There is a function defined which can tell you how to do it.

function ConvertFromSecureToPlain{

    param(

        [Parameter(Mandatory=$true)]

        [System.Security.SecureString] $SecurePassword

    )

    # Create a "password pointer"

    $PasswordPointer = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecurePassword)

    # Get the plain text version of the password

    $PlainTextPassword = [Runtime.InteropServices.Marshal]::PtrToStringAuto($PasswordPointer)

    # Free the pointer

    [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($PasswordPointer)

    # Return the plain text password

    $PlainTextPassword

}

Call this using something like:

$myPassword =  ConvertFromSecureToPlain -SecurePassword $myCredentials.Password

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

THORSTEN_KRAUSE
3,137 Views

thanks ver ymuch !

Public