Active IQ Unified Manager Discussions

Using password userinput in command fails

kiessl
3,975 Views

Hi,

 

I try to use the new password userinput in a workflow command.

I pass the userinput as a parameter to the command but when I want to use it, the command fails. Here is an excerpt from the command, showing the relevant code:

 

   ...

   [parameter(Mandatory=$true, HelpMessage="Password of the user with privileges to add the SVM to the ADS domain.")]

   [string]$DomainAdmPasswd,

   ...

 

   $pwd = Get-WfaInputPassword -EncryptedPassword $DomainAdmPasswd -ErrorAction Stop

 

   Add-NcCifsServer -Name $CifsServerName -Domain $Domain -OrganizationalUnit $OrganizationalUnit -AdminUsername $DomainAdmUser -AdminPassword $pwd -Force -VserverContext

   $VserverName -ErrorAction Stop

 

This results in the following error: Failed to create the Active Directory machine account "XXX". Reason: LDAP Error: The supplied credential is invalid.

 

Can someone help me with this?

 

Thanks in advance

Walter

 

1 ACCEPTED SOLUTION

rajathr
3,956 Views

Hi Walter,

 

The command which needs the password should have the parameter defined as a 'Password'. The way to do this is to have an alias for the parameter in the command definition.

This is how you would define it in your command definition:

 

 [parameter(Mandatory=$true, HelpMessage="Password of the user with privileges to add the SVM to the ADS domain.")]

 [Alias("Pwd_Password")]

 [string]$DomainAdmPasswd

 

When you use 'Discover Parameters', if the command parameter type is discovered as a 'Password', then you should be fine.

 

Also, the return parameter from the Get-WfaInputPassword is a SecureString type. You need to convert this to plain String before using it as an input parameter to AdminCredential in the cmdlet. Alternatively, you can use the variant that accepts the PSCredential as an input.

 

You can use the 'Create and Configure Virtual Storage Machine' command as a reference. 

Hope this helps.

View solution in original post

2 REPLIES 2

rajathr
3,957 Views

Hi Walter,

 

The command which needs the password should have the parameter defined as a 'Password'. The way to do this is to have an alias for the parameter in the command definition.

This is how you would define it in your command definition:

 

 [parameter(Mandatory=$true, HelpMessage="Password of the user with privileges to add the SVM to the ADS domain.")]

 [Alias("Pwd_Password")]

 [string]$DomainAdmPasswd

 

When you use 'Discover Parameters', if the command parameter type is discovered as a 'Password', then you should be fine.

 

Also, the return parameter from the Get-WfaInputPassword is a SecureString type. You need to convert this to plain String before using it as an input parameter to AdminCredential in the cmdlet. Alternatively, you can use the variant that accepts the PSCredential as an input.

 

You can use the 'Create and Configure Virtual Storage Machine' command as a reference. 

Hope this helps.

kiessl
3,951 Views

Hi Rajathr,

 

with the command 'Create and Configure Virtual Storage Machine' as a reference it works.

 

Thanks for your help!

 

Best Regards

Walter

 

Public