HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
Array Performance and Data Protection
cancel
Showing results for 
Search instead for 
Did you mean: 

Powershell script to sell all Snapshot

 
SOLVED
Go to solution
Francois lepage
Occasional Advisor

Powershell script to sell all Snapshot

I want to use powershell to list all snapshot beginning by Ncss on all volumes

I can't find how to do it for all volumes but I am able to do it for one volumes with this command

   Get-NSSnapshot -vol_name "NMBL-DBEX-SIEGESOCIAL" | where {$_.name -match "NSs"}

Is it possible to achieve my goal

thanks

4 REPLIES
dgonzalez59
HPE Blogger

Re: Powershell script to sell all Snapshot

Hello Francois,

There are several ways to script this. Here is an example, where we first get volumes, and then pass the output through a foreach loop. In the sample below, I am focusing on volumes that have 2017-06-09 in the snapshot name.

Dianne

Sample script

Connect-NSGroup -Credential $nm_cred -group $nsarray

$volname = Get-NSVolume | Select-Object -Property "name"

$snaplist = @()

foreach ($name in $volname)

{

$res = Get-NSSnapshot -vol_name $name.name | where { $_.name -like "*2017-06-09*" } | select name, id

$snaplist += $res

}

Write-Output $snaplist

Solution

Re: Powershell script to sell all Snapshot

Dang, She beat me to it..

From the CLI, this will check all volumes, and all snaps of those volumes;

Get-NSVolume | foreach-object { get-nssnapshot -vol_name $_.name | where {$_.name -match "MyTestString" } }

Francois lepage
Occasional Advisor

Re: Powershell script to sell all Snapshot

thanks it is working!! If I could put 2 solutions as the correct answer you will be marked as that too

thanks again

Francois lepage
Occasional Advisor

Re: Powershell script to sell all Snapshot

Thanks also working!!!