Microsoft Virtualization Discussions

Ontap commands run from Powershell

HighmarkECB
2,218 Views

Hello all, Need some help.  I want to run the following:

 

volume snapshot show -fields create-time, size, state, is-constituent

Using the Ontap Powershell and redirect it to a local Excel format.  I can get connected to my Clusters using the Connect-NcController, just cannot get the syntax correct for the volume command.

 

Any help would be great. 

1 ACCEPTED SOLUTION

Ontapforrum
2,173 Views

Try to look up in our forum, you might find lots of examples. 

 

This command should return the size, created time but not sure about state, is-constituent.

Get-NcSnapshot 

 

Check this thread:
https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Powershell-command-to-list-snapshot-details-for-particular-volumes/m-p/108689

 

Following command will give more output, check it out yourself.

Get-NcSnapshot | ?{ $_.Created}
Get-NcSnapshot | ?{ $_.Created} | Export-Csv snapshot.csv
Note: File will get saved in your c:/drive.

View solution in original post

2 REPLIES 2

Ontapforrum
2,174 Views

Try to look up in our forum, you might find lots of examples. 

 

This command should return the size, created time but not sure about state, is-constituent.

Get-NcSnapshot 

 

Check this thread:
https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Powershell-command-to-list-snapshot-details-for-particular-volumes/m-p/108689

 

Following command will give more output, check it out yourself.

Get-NcSnapshot | ?{ $_.Created}
Get-NcSnapshot | ?{ $_.Created} | Export-Csv snapshot.csv
Note: File will get saved in your c:/drive.

Ashun
110 Views

hi

 

Once you have successfully connected to the cluster using Connect-NcController, you can easily get the information you want by running the following script

script

# Get all snapshot information and convert the Total field to legible units
$snapshots = Get-NcSnapshot | Select-Object Name, Volume, Created, Total

#Function: Converts bytes into legible units
function Convert-Bytes {
param([long]$bytes)

if ($bytes -lt 1KB) {
return "{0} B" -f $bytes
}
elseif ($bytes -lt 1MB) {
return "{0:N2} KB" -f ($bytes / 1KB)
}
elseif ($bytes -lt 1GB) {
return "{0:N2} MB" -f ($bytes / 1MB)
}
elseif ($bytes -lt 1TB) {
return "{0:N2} GB" -f ($bytes / 1GB)
}
else {
return "{0:N2} TB" -f ($bytes / 1TB)
}
}

# Change the unit of the Total field
$snapshots | ForEach-Object {
$_ | Add-Member -MemberType NoteProperty -Name "Total " -Value (Convert-Bytes $_.Total) -Force
$_
} | Select-Object Name, Volume, Created, "Total "

Public