Subscribe
Accepted Solution

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

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

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

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.

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

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

 

 

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

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

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

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.

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

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.

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

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.

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

Dear Sinhaa

thank you for your kindly helping & reply.

 

i will test out and let you know.

 

Brs,

Richy

 

 

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

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

 

 

 

 

 

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

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.