Active IQ Unified Manager Discussions

WFA Create Local CIFS User with User In-put Password on Cluster Mode

Richy_TH
7,463 Views

Dear All

i would like to create WFA command that can create Local CISF user for ONTAP cluster mode.

i found an error as below.

 

Screen Shot 2558-07-04 at 5.36.19 PM.png

 

The command:

 

 

param (

[parameter(Mandatory=$true, HelpMessage="Cluster (controller) IP or name.")]

[string]$Cluster,

 

  [parameter(Mandatory=$true, HelpMessage="Name of the Storage Virtual Machine in which the CIFS share will be created.")]

  [string]$Vserver,

 

  [parameter(Mandatory=$true, HelpMessage="User Name.")]

  [string]$User,

 

  [parameter(Mandatory=$false, HelpMessage="Password.")]

  [Alias("Password_Password")]

  [string]$Password

 

)

 

 

# connect to cluster

Connect-WFACluster $Cluster

 

 

 

Get-WFALogger -Info -message $("Creating User share: " + $User + "Password: "+ $Password)

 

# Add User

 

 

New-NcCifsLocalUser -UserName  $User -VserverContext $Vserver -Password $Password

 

 

i also attached my command in the attached file.

 

if you guys have any advice please light me.

 

Thank you in advanced.

 

Richy

1 ACCEPTED SOLUTION

sinhaa
6,469 Views

Richy

 

You need to declare the parameter of type "Password" at workflow User-Inputs as well.

 

See the image.

 

AIS_new_cifs_.png

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

View solution in original post

9 REPLIES 9

sinhaa
7,423 Views
This cmdlet need password in type SecureString. WFA password get encrypted when passed into to the command code, you need the cmdlet Get-WfaInputPassword to get it into securestring format. Add the following line $Password= Get-WfaInputPassword -EncryptedPassword $Password So your new code shall be: ###=== param ( [parameter(Mandatory=$true, HelpMessage="Cluster (controller) IP or name.")] [string]$Cluster, [parameter(Mandatory=$true, HelpMessage="Name of the Storage Virtual Machine in which the CIFS share will be created.")] [string]$Vserver, [parameter(Mandatory=$true, HelpMessage="User Name.")] [string]$User, [parameter(Mandatory=$false, HelpMessage="Password.")] [Alias("Password_Password")] [string]$Password ) # connect to cluster Connect-WFACluster $Cluster Get-WFALogger -Info -message $("Creating User share: " + $User + "Password: "+ $Password) # Add User $Password= Get-WfaInputPassword -EncryptedPassword $Password New-NcCifsLocalUser -UserName $User -VserverContext $Vserver -Password $Password ##==== sinhaa
If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

Richy_TH
7,405 Views

Dear sinhaa

thank you for your reply.

i have changed my command as your recommend but still found error.

 

Screen Shot 2015-07-05 at 12.37.06 am.png 

do i miss any thing ?

 

Richy

 

 

Richy_TH
7,254 Views

Dear Sinhaa

finally got complete command.

 

param (

[parameter(Mandatory=$true, HelpMessage="Cluster (controller) IP or name.")] [string]$Cluster,

[parameter(Mandatory=$true, HelpMessage="Name of the Storage Virtual Machine in which the CIFS share will be created.")] [string]$Vserver,

[parameter(Mandatory=$true, HelpMessage="User Name.")] [string]$User,

[parameter(Mandatory=$false, HelpMessage="Password.")] [Alias("Password_Password")] [string]$Password

)
# connect to cluster
Connect-WFACluster $Cluster

Get-WFALogger -Info -message $("Creating User share: " + $User + "Password: "+ $Password)

# Add User

$PlainPass = $Password

$SecPass = $PlainPass | ConvertTo-SecureString -AsPlainText -Force

New-NcCifsLocalUser -UserName $User -VserverContext $Vserver -Password $SecPass

 

Thank you.

 

Brs,

Richy

sinhaa
7,234 Views

Hi Richy,

 

Your command has passed but it hasn't done what you wanted it to do. It created the user account with incorrect password i.e. it sent the encrypted form of the password directly. The below line returns the provided password in SecureString format itself.

 

$SecPassword= Get-WfaInputPassword -EncryptedPassword $Password

 

This is not to be converted to secure string.

 

Right now I can't connect to VED, so will give you the right code.

 

sinhaa

 

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

sinhaa
6,975 Views

Dear Richy,

 

The correct command code would be:

### Beging Code

 

param (
[parameter(Mandatory=$true, HelpMessage="Cluster (controller) IP or name.")]
[string]$Cluster,

[parameter(Mandatory=$true, HelpMessage="Name of the Storage Virtual Machine in which the CIFS share will be created.")]
[string]$Vserver,

[parameter(Mandatory=$true, HelpMessage="User Name.")]
[string]$User,

[parameter(Mandatory=$false, HelpMessage="Password.")]
[Alias("Password_Password")]
[string]$Password

)


# connect to cluster
Connect-WFACluster $Cluster

Get-WFALogger -Info -message $("Creating User share: " + $User + "Password: "+ $Password)

# Add User
$SecPassword= Get-WfaInputPassword -EncryptedPassword $Password
New-NcCifsLocalUser -UserName $User -VserverContext $Vserver -Password $SecPassword

 

## End Code

 

Password.png

 

 

I just change the variable name $Password to $SecPassword. Due to some unknown reason its not overwriting the variable $Password. I'll debug this behavour now.

 

 But the code design has some issues. You $Password is an optional paramter in command definition. So if somone doesn't provide it, your command will fail. So either you need to set it as Mandatory=$true or provide a default value for $Password if empty. I'll leave this choice to you.

 

sinhaa

 

 

 

 

 

 

 

 

 

 

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

sinhaa
6,975 Views

Dear Richy,

 

The correct command code would be:

### Beging Code

 

param (
[parameter(Mandatory=$true, HelpMessage="Cluster (controller) IP or name.")]
[string]$Cluster,

[parameter(Mandatory=$true, HelpMessage="Name of the Storage Virtual Machine in which the CIFS share will be created.")]
[string]$Vserver,

[parameter(Mandatory=$true, HelpMessage="User Name.")]
[string]$User,

[parameter(Mandatory=$false, HelpMessage="Password.")]
[Alias("Password_Password")]
[string]$Password

)


# connect to cluster
Connect-WFACluster $Cluster

Get-WFALogger -Info -message $("Creating User share: " + $User + "Password: "+ $Password)

# Add User
$SecPassword= Get-WfaInputPassword -EncryptedPassword $Password
New-NcCifsLocalUser -UserName $User -VserverContext $Vserver -Password $SecPassword

 

## End Code

 

Password.png

 

 

I just change the variable name $Password to $SecPassword. Due to some unknown reason its not overwriting the variable $Password. I'll debug this behavour now.

 

 But the code design has some issues. You $Password is an optional paramter in command definition. So if somone doesn't provide it, your command will fail. So either you need to set it as Mandatory=$true or provide a default value for $Password if empty. I'll leave this choice to you.

 

sinhaa

 

 

 

 

 

 

 

 

 

 

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

Richy_TH
6,971 Views

Dear Sinhaa

thank you for your kindly helping & reply.

 

i will test out and let you know.

 

Brs,

Richy

 

 

Richy_TH
6,579 Views

Dear Sinhaa

i have tested on the command level seem the command working perfectly fine but when i add it into the workflow.

it doesn't work as it was.

so the error show as below:

 

 

Screen Shot 2558-09-27 at 9.48.06 PM.png

 

i filled up the password but error reture as password empty have you experience this kind of error before ?

 

so if anyone found this issue before please light me.

i am running WFA v3.1

 

Best Regards,

Richy

 

 

 

 

 

sinhaa
6,470 Views

Richy

 

You need to declare the parameter of type "Password" at workflow User-Inputs as well.

 

See the image.

 

AIS_new_cifs_.png

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