Ask The Experts

Powershell Guide

Tas
7,098 Views

Perhaps someone on the Experts list can answer some questions for me.

1.  Why is the Powershell forum now the Virtualization / Microsoft forum?

2.  I am having a heck of a time trying to find answers to the PS cmdlets created by NetApp for NC.  My biggest headache right now is finding how to use authentication, and to keept it while traversing mulstiple-clusters.  It would be great if there were some TR's on PS Best practices, but the latest appears to be circa 2011.  I know I had seen a discussion prior to the Community re-shuffle, but I can no longer find it, no matter what I put in the search.

3.  How come I can't use PS cmdlets to assign Snapshot policies to volumes?  (Don't tell me to do it via the ncssh cmdlet.)

4.  I am still grapling with this final question;  should I jump on PS, or just stay with the CLI over SSH?

 

Thank you

Tas

1 ACCEPTED SOLUTION

dkon
6,977 Views
4 REPLIES 4

dkon
6,978 Views

Tas
6,941 Views

Yes, duckduckgo helped me find this link, yesterday, and it helped tremendously.  However, I still insist that NetApp needs to have a better PS Toolkit Script Developers Guide.

I love to learn new things, but not when it becomes frustrating because of lack of documentation.

However, be that as it may, the Practical Administrators Guide to PS Toolkit is the best guide I have seen yet.

 

TasP

mbeattie
6,970 Views

Hi Tas,

 

All valid questions, can't comment on the forum but can easily set authentication for your clusters simply by using the "Add-NcCredential". The "Connect-NcController" cmdlet will read credentials from the cache assuming you've added them otherwise it will prompt you for credentials. EG:

 

PS C:\> Add-NcCredential -Controller cluster2.testlab.local -Credential (Get-Credential -Credential admin)

Name                   Credential                                HostUser
----                   ----------                                --------
cluster2.testlab.local System.Management.Automation.PSCredential TESTLAB\mbeattie

PS C:\> connect-nccontroller -Name cluster2.testlab.local -https

Name                 Address           Vserver              Version
----                 -------           -------              -------
cluster2.testlab.... 192.168.100.3                          NetApp Release 9.4: Fri Jun 08 22:50:12 UTC 2018

Note: The "Connect-NcController" cmdlet will read the cached credentials (IE you don't need to pass the -Credential paramater to it if you have added credentials for a cluster using "Add-NcCredential")

 

The "Update-NcVol" cmdlet can be used to modify properties of a volume (EG snapshot policy). Here is an example :

 

$query = Get-NcVol -Template
$query.Vserver = "vserver2"
$query.Name = "nfs_data_001"
Initialize-NcObjectProperty $query VolumeSnapshotAttributes
$attributes = Get-NcVol -Template
Initialize-NcObjectProperty $attributes VolumeSnapshotAttributes
$attributes.VolumeSnapshotAttributes.SnapshotPolicy = "default-1weekly"
Update-NcVol -Query $query -Attributes $attributes

Result:

NcController : cluster1.testlab.local
SuccessCount : 1
FailureCount : 0
SuccessList  : {nfs_data_001}
FailureList  : {}

CLI result:

cluster1::> vol show -volume nfs_data_001 -fields snapshot-policy
vserver  volume       snapshot-policy
-------- ------------ ---------------
vserver2 nfs_data_001 default-1weekly

I would only use Invoke-NcSsh as an absolute last resort. You can use Invoke-NcSystemApi as an alternative to SSH but in the majority of all requirements there is a powershell cmdlet that will provide object based output rather than parsing SSH output string (the format of which is not guarenteed to remain constant in future ONTAP releases). I highly recommend you avoid using SSH if you can achive the desired result using the PSTK.

 

Hope that helps

 

/Matt

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

GidonMarcus
6,967 Views

1. Tagging @LeoD in case he know. but i thin PS goes under the SDK as the PS module is now part of it. and i don't see it under Virt in currently in the community

https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/bd-p/sdk-and-api-discussions

https://mysupport.netapp.com/NOW/download/software/nmsdk_dotnet/9.4/

 

2. in my scripts either open multiple connections in one of these ways (Prefer the first one)

 

$NCClustersNames = "clu01","clu02"
$NCClusters =  Connect-NcController -Name $NCClustersNames -Credential (Get-Credential) 

OR

$NCClusters = @{}
$NCClusters.clu01 = Connect-NcController -Name "clu01" -Credential (Get-Credential) 
$NCClusters.clu02 = Connect-NcController -Name "clu02" -Credential (Get-Credential) 

And use it as

 

 

 

Get-NcVol -Controller ($NCClusters | ? name -eq "clu01")

OR

Get-NcVol -Controller $NCClusters.clu01

OR - when i want the data from all the clusters (for the first option only):

Get-NcVol -Controller $NCClusters

 

3. see here https://practical-admin.com/blog/netapp-powershell-toolkit-101-volume-snapshots/

$query = @{
    Name = $volName
}
$attributes = @{
    VolumeSnapshotAttributes = @{
        SnapshotPolicy = $policyName
    }
}
Update-NcVol -Query $query -Attributes $attributes

4. I think yes,  working with SSH output is not fun, here someone actually  formatted for you the outputs and inputs of thousands of commands.

As a person who work with the top four vendors SDK's, it seems to me that NetApp has the most advanced PS Module out there, that is most compliant to the PS standards and really has almost 1:1 mapping between every API command they have to the PS one.

is it perfect? - Not, but i see vendors releasing PS Modules that their own commands dosen't pipe to one another, and the parameters has different name in each cmdlet. 

 

Gidi

 

Gidi Marcus (Linkedin) - Storage and Microsoft technologies consultant - Hydro IT LTD - UK
Public