Subscribe
Highlighted
Accepted Solution

using password out of saved credentials

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

Re: using password out of saved credentials

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.

Re: using password out of saved credentials

thanks ver ymuch !