Microsoft Virtualization Discussions
Microsoft Virtualization Discussions
Im looking for a script that will give me the snapshot copies names, date/time, size, etc for each individual volume on a filer.
Preferably I'd like something exported to excel that would show me:
Volume Name
Snapshot copy name
Snapshot copy name
Based on the screen shot the output would be this:
testSM
hourly.0
hourly.1
nightly.0
hourly.2
Etc....
Doable?
Solved! See The Solution
sorry about that syntax for the cdot is slightly different.
This should do it for you.
Import-Module dataontap
Connect-NaController [filer] -Credential root
get-navol|get-nasnapshot|Export-Csv mysnapshots.csv
Justin,
One way to do this is with the data ontap powershell toolkit
Import-Module dataontap
Connect-NcController Mycluster or
connect-nacontroller filer
Get-NcSnapshot|Export-Csv mysnapshots.csv or
Get-NaSnapshot|Export-Csv mysnapshots.csv
You could also limit down the output by specifiy the volume or the svm(vserver) volume name pattern.
Regards
John
Im familiar with the OnTap toolkit.
It doesnt like the Get-NcSnapshot command:
Get-NcSnapshot : Value cannot be null.
Parameter name: Controller parameter neither specified nor set in $global:CurrentNcController
Here's my script:
Import-Module dataontap
Connect-nacontroller REALFILERNAME -Credential jsmith
Get-NcSnapshot|Export-Csv mysnapshots.csv
Looks like thats a cluster mode command?
I think Im figuring it out, Im using the get-nasnapshot command which is for 7 mode. The only thing is, I need it to grab ALL volumes.
Import-Module dataontap
Connect-nacontroller REALFILERNAME -Credential jsmith
Get-NaSnapshot|Export-Csv 'H:\NetApp Scripts\snapshots.csv'
What happens is it asks me for a TargetName for the volumes.
sorry about that syntax for the cdot is slightly different.
This should do it for you.
Import-Module dataontap
Connect-NaController [filer] -Credential root
get-navol|get-nasnapshot|Export-Csv mysnapshots.csv
That seemed to work....
Only thing is it gives me the info bassackwards.
Is there a way to get the TargetName on the first column of the spreadsheet?
Your welcome!
You can format the output with the select command.
get-navol|get-nasnapshot |select TargetName,name,Created|Export-Csv mysnapshots.csv
You can select any of the rows in the header.
Created | Cumulative | AccessTime | AccessTimeDT | Busy | ContainsLunClones | CumulativePercentageOfTotalBlocks | CumulativePercentageOfUsedBlocks | CumulativeTotal | Dependency | Name | PercentageOfTotalBlocks | PercentageOfUsedBlocks | SnapshotOwnersList | TargetName | TargetType | Total | ContainsLunClonesSpecified |
Regards,
John
Thanks, that worked too... last question.
Here's my current script:
Import-Module dataontap
$Controller = @('filername')
Foreach ($filer in $controller)
{
Connect-nacontroller $filer -Credential jsmith
get-navol | get-nasnapshot | select TargetName,name,Created | Export-Csv 'H:\NetApp Scripts\$filer.snapshots.csv'
}
Im looking for it to save the file with the filername.snapshot. I've tried filername_snapshot and filername.snapshot, but it only gives it the $filer.snapshot name.....
Hi justin_smith
Could you please let me know how you have saved file "filername' for command $Controller = @('filername').
If possible could you please share script as well
Hello @Neal1703,
He is simply using "filername" as a place holder here. The "@()" turns it into an array so that if there are multiple the bits of script below can loop over them.
$Controller = @('myNetApp.local.com', 'myOtherNetApp.local.com', 'myDRNetApp.remove.com')
You asked: "m looking for it to save the file with the filername.snapshot. I've tried filername_snapshot and filername.snapshot, but it only gives it the $filer.snapshot name....." You're seeing that behavior because of the single quotes around the value. If you replace with double quotes it should work...
Get-NaVol | Get-NaSnapshot | select TargetName,name,Created | Export-Csv "H:\NetApp Scripts\$($filer).snapshots.csv"
If you're curious, there is a lot of information about variable expansion in string output here.
Hope that helps.
Andrew
I need script for deleting snapshot more than 32 days in the cluster in CMode.
@justin_smith wrote:Im looking for a script that will give me the snapshot copies names, date/time, size, etc for each individual volume on a filer.
Preferably I'd like something exported to excel that would show me:
Volume Name
Snapshot copy name
Snapshot copy name
Based on the screen shot the output would be this:
testSM
hourly.0
hourly.1
nightly.0
hourly.2
Etc....
Doable?
You should start a new topic to get the best visibility. With that being said, this should work for you:
Get-NcSnapshot | ?{ $_.Created -lt (Get-Date).AddDays(-33) }
Hope that helps.
Andrew