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)
})
}