Subscribe

Usage of WFAInputPassword

Hi,

 

 

I'm trying to use WFA to call the VSC commandlets in VSC 6.0.   I have a question on how to pass a password.    When I try to grab the password from the input and use it,  i get various errors.  I tried Get-WFAInputPassword but I get the below error.  Can anyone help with a code sample?

 

Thanks

 

Mike

 

 

2015-04-26 12:55:31,880 ERROR [com.netapp.wfa.command.execution.instance.impl.ExecutionInstanceDaoImpl] (http-executor-threads - 59) [VSC_Create_DataStore] Cannot bind argument to parameter 'EncryptedPassword' because it is null.

 

import-module VSC
Get-WFALogger -Info -message ("Username " + $vscUser)
Get-WFALogger -Info -message (" Password: " + $vscPass)
$passwordp = Get-WfaInputPassword -EncryptedPassword $vcsPass
$password = ConvertTo-SecureString -AsPlainText -Force $passwordp

$creds = New-Object System.Management.Automation.PSCredential $vscUser, $password
Connect-VSCserver $vscServer -Credential $creds

$SystemID = Get-VscStorageSystemId -ipAddress $Cluster
Get-WFALogger -Info -message (" System ID of " + $Cluster + " is " + $SystemID)

Re: Usage of WFAInputPassword

Mike,

 

Some points here:

 

  1. You need to declare parameter $vcsPass of type Password in your command. See example in WFA developer's guide on how to use it.

 

2.   $passwordp = Get-WfaInputPassword -EncryptedPassword $vcsPass

 

This itself returns the $password in SecureString format and hence you do not need the line: $password = ConvertTo-SecureString -AsPlainText -Force $passwordp

 

Just use the $passwordp to create your credential object : $creds = New-Object System.Management.Automation.PSCredential $vscUser, $passwordp

 

 

sinhaa

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

Re: Usage of WFAInputPassword

Sinhaa,

 

Thanks for the reply.  I've been trying different combinations with various error messages.  Using the Get-WfaInputPassword -EncryptedPassword $vcsPass_Password  still produces errors.   The $vscPass is now an encrypted string but not one the PSCredential likes.

 

My parameter:

 


[parameter(Mandatory=$true, HelpMessage="Specify an VSC password.")]
[Alias("vscPass_Password")] [string]$vscPass,

 

import-module VSC
Get-WFALogger -Info -message ("Username " + $vscUser)
Get-WFALogger -Info -message (" Password: " + $vscPass)

$creds = New-Object System.Management.Automation.PSCredential $vscUser, $vscPass
Connect-VSCserver $VSCHost -Credential $creds

 

Log messages:

 

2015-04-27 08:44:10,583 INFO [com.netapp.wfa.command.execution.instance.impl.ExecutionInstanceDaoImpl] (http-executor-threads - 27) [VSC_Create_DataStore] Username mszafran@netappusps.demo
2015-04-27 08:44:10,630 INFO [com.netapp.wfa.command.execution.instance.impl.ExecutionInstanceDaoImpl] (http-executor-threads - 24) [VSC_Create_DataStore] Password: cZlo6RBVImU/8+d3KfGOqg==
2015-04-27 08:44:10,724 ERROR [com.netapp.wfa.command.execution.instance.impl.ExecutionInstanceDaoImpl] (http-executor-threads - 29) [VSC_Create_DataStore] Cannot find an overload for "PSCredential" and the argument count: "2".

 

Re: Usage of WFAInputPassword

The correct code should be:

====

 

[parameter(Mandatory=$true, HelpMessage="Specify an VSC password.")]
[Alias("vscPass_Password")] [string]$vscPass,

 

import-module VSC
Get-WFALogger -Info -message ("Username " + $vscUser)
Get-WFALogger -Info -message (" Password: " + $vscPass)

 

#Get the password in Secure String format.

$vcsPass_Sec= Get-WfaInputPassword -EncryptedPassword $vcsPass

$creds = New-Object System.Management.Automation.PSCredential $vscUser, $vscPass_Sec
Connect-VSCserver $VSCHost -Credential $creds

 

====

 

sinhaa

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