VMware Cloud Community
inderraw
Contributor
Contributor

Snapshots holding by particular data store

Hi Team mate,

Please help with VMware script, where i can get detail, one specific Data store holding how many snapshot?

required: it would easy to trace if any DS about to full, so we can check that ds only using script.

Regards

Inder Singh Rawat

 

Reply
0 Kudos
8 Replies
scott28tt
VMware Employee
VMware Employee

Is this a vSphere environment, and are you thinking about a PowerCLI script?

 


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
inderraw
Contributor
Contributor

Yes i am looking for vmware power cli script.

how to check specific Datastore how many vm snapshot holding?

Tags (1)
Reply
0 Kudos
scott28tt
VMware Employee
VMware Employee

I have asked the moderators to move your post.

 


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
inderraw
Contributor
Contributor

Hi,

Please help with script, if anything we can get information about snapshot in  specific DS (vsphere environment).

Reply
0 Kudos
LucD
Leadership
Leadership

You mean something like this?

Get-Datastore -PipelineVariable ds |
ForEach-Object -Process {
  $snap = Get-VM -Datastore $ds | Get-Snapshot

  New-Object -TypeName PSObject -Property ([ordered]@{
    Datastore = $ds.Name
    SnapshotCount = $snap.Count
    SnapshotSize = [math]::Round(($snap | Measure-Object -Property SizeMB -Sum).Sum,1)
  })
}


if you want to look at a specific datastore, specify the name

Get-Datastore -Name MyDS -PipelineVariable ds |
ForEach-Object -Process {
  $snap = Get-VM -Datastore $ds | Get-Snapshot

  New-Object -TypeName PSObject -Property ([ordered]@{
    Datastore = $ds.Name
    SnapshotCount = $snap.Count
    SnapshotSize = [math]::Round(($snap | Measure-Object -Property SizeMB -Sum).Sum,1)
  })
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
inderraw
Contributor
Contributor

Hi Mate,

Thanks for your response, as checked it is showing count of snapshot specific DS, is it possible to know which vm holding snapshot in specific DS?

attached specific DS, snapshot count.

Reply
0 Kudos
LucD
Leadership
Leadership

You can add 1 property for that

Get-Datastore -PipelineVariable ds |
ForEach-Object -Process {
  $snap = Get-VM -Datastore $ds | Get-Snapshot

  New-Object -TypeName PSObject -Property ([ordered]@{
    Datastore = $ds.Name
    SnapshotCount = $snap.Count
    SnapshotSize = [math]::Round(($snap | Measure-Object -Property SizeMB -Sum).Sum,1)
    VM = $snap.VM.Name -join '|'
  })
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
inderraw
Contributor
Contributor

Hi LUCD,

Thanks you so much, it is working fine to me.

 

Reply
0 Kudos