Subscribe

PowerShell Command Question

what is the command for powershell to 

 

- create volume 12gb

- set a volume as thin provisioned

- securitystyle unix

- enable storage efficiency

- autogrow volume 

- automatically delete older snapshots

 

 

Re: PowerShell Command Question

[ Edited ]

Hi,

 

You can easily find the PowerShell CmdLet names and their syntax by importing the DataONTAP module, listing the availableCmdLets and reading the CmdLet Help.

If you are not sure what the CmdLet name is then you can find it by using a wildcard on the object type you are searching for (EG aggregate, volume, qtree, vserver etc)

Here are some examples of how you can get starting searching the DataONTAP powershell module to identify the CmdLet Syntax required:

 

PS>Import-Module DataONTAP

PS>Get-Command -ModuleName DataONTAP

PS>Get-Command *-NcVol*

PS>Get-Help New-NcVol -Full | more

 

So to help answer you question with some "examples" (modify to meet the requirements in your environments):

 

#'------------------------------------------------------------------------------
#'Set Variables
#'------------------------------------------------------------------------------
$clusterName         = "cluster1"
$vserverName         = "vserver1"
$volumeSecurityStyle = "unix"
$aggregateName       = "node1_aggr1"
$spaceReserve        = "none"
$volumeName          = "volume1"
$volumeState         = "online"
$volumeType          = "rw"
$volumeSize          = 12
$volumeFormat        = "g"
$volumeMaxSize       = 20
$volumeIncrement     = 2
#'------------------------------------------------------------------------------
#'PowerShell DataONTAP CmdLet Examples:
#'------------------------------------------------------------------------------
Import-Module DataONTAP
$username    = "admin"
$password    = Read-Host "Please enter the password to connect to cluster ""$clusterName"" as user ""$username""" -AsSecureString
$credentials = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $password
Connect-NcController -Name $clusterName -Credential $credentials -HTTPS
New-NcVol -Name $volumeName -Aggregate $aggregateName -JunctionPath "/$volumeName" -SpaceReserve $spaceReserve -SecurityStyle $volumeSecurityStyle -State $volumeState -Type $volumeType -Size "$volumeSize$volumeFormat" -VserverContext $vserverName
Set-NcVolAutosize -Name $volumeName -Enabled -MaximumSize "$volumeMaxSize$volumeFormat" -IncrementSize "$volumeIncrement$volumeFormat" -VserverContext $vserverName
$command = "volume efficiency start -vserver $vserverName -volume $volumeName -scan-old-data true"
Invoke-NcSsh -Command $command

 

As for deleting old snapshots, see "Get-Help Get-NcSnapShot" and "Get-Help Remove-NcSnapShot" however you shouldn't need to delete old snapshots unless you have taken the snapshot manually as the snapshot policy\schedule assigned to the volume will automatically create\remove them.

 

Based on the list of configuration steps required I think what you are attempting to achieve would be ideal as a WFA workflow.

Have you considered using Workflow automation?

 

Hope this helps

 

/matt

 

 

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