Microsoft Virtualization Discussions

Created object on get-NaSnapsot Powershell 4.1 dissapeared

falarkiko10
3,879 Views

Hi!

 

I have one Powershell code to delete old snapshots: Get-Navol | Get-NaSnapshot | where-object {$_.name -like "smo_*" -and $_.created -lt $3days} | Remove-NaSnapshot -Confirm

 

My storage is FAS8020 7-mode 8.2.2P2 and after upgrade the powershell toolkit to version 4.1 de .created object was dissapear.

 

Who can I do the same with the new version of Powershell or where can I download the old version of toolkit?

 

Best regards

 

4 REPLIES 4

asulliva
3,841 Views

Can you give any more details?

 

  • Does "Get-NaVol" return all expected volumes?
  • Does "Get-NaVol | Get-NaSnapshot" return all expected snapshots?
  • Does the filter for '$_.Name -like "smo_*"' return the exected values?
  • Does the filter for '$_.Created -lt $3days' return the expected values?
  • What is the value of "$3days"?

In particular, for the last two it would be helpful to know if they work separately...i.e. just use one at a time for the testing. 

 

Andrew

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

falarkiko10
3,830 Views

This is the complete script

 

#Variable of date type which is 3 days before the current date

$3days = (get-date).adddays(-3)

 

#Get list of all snapshots older than 3 days and delete them 

Get-Navol | Get-NaSnapshot | where-object {$_.name -like "smo_*" -and $_.created -lt $3days} | Remove-NaSnapshot -Confirm

 

It was working properly until the upgrade.

 

Thanks

 

Aparajita
3,806 Views

Could you also tell us which version of Data ONTAP PowerShell Toolkit you were using before this?

Shashanka
3,747 Views

I tried with the same scenario and was able to achieve the deletion of snapshots. I have tried with just 1 day earlier snapshots, as I dont have very old snapshots. Below are the images for reference.

 

#Variable of date type which is 1 day before the current date

$1day = (get-date).adddays(-1)

 

 11.png

 

22.png

33.png

44.png

 

As seen in the images, the snapshots were deleted successfully.

 

Public