VMware Cloud Community
karthik_chand
Contributor
Contributor
Jump to solution

Script to report snapshots with exclusion of VMs from certain folders

Dear Experts,

Our requirement is as follows,

We would like to have a weekly report of the snapshot usage within the vCenter. Here, we would like to filter out some of the VMs based on the folders that they exist. 

I have come across many snapshot reports but none of them cater to our needs to filter them by the folders. 

For example, we would like to exclude VMs which are in the folders "TEST" "REPLICAS" etc. 

Thanks in advance!

Regards,

Karthik

Reply
0 Kudos
2 Solutions

Accepted Solutions
Macleud
Enthusiast
Enthusiast
Jump to solution

Hi.

You could try something like this.

 

 

Get-Vm | where {$_.Folder -ne "TEST" -and $_.Folder -ne "REPLICAS"} | Get-Snapshot | Select-Object Description, Created, VM, SizeMB, SizeGB

 

 

or

 

$Folders = "TEST", "REPLICAS"

Get-Vm | where {$Folders -NotContains $_.Folder.name } | Get-Snapshot | Select-Object Description, Created, VM, SizeMB, SizeGB

 

 

View solution in original post

LucD
Leadership
Leadership
Jump to solution

Taking into account that casting is determined by the left operand, that should be

Get-Vm | where {$_.Folder.Name -ne "TEST" -and $_.Folder.Name -ne "REPLICAS"} | Get-Snapshot | Select-Object Description, Created, VM, SizeMB, SizeGB

or

Get-Vm | where {"TEST" -ne $_.Folder -and "REPLICAS" -ne $_.Folder} | Get-Snapshot | Select-Object Description, Created, VM, SizeMB, SizeGB

 


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

View solution in original post

2 Replies
Macleud
Enthusiast
Enthusiast
Jump to solution

Hi.

You could try something like this.

 

 

Get-Vm | where {$_.Folder -ne "TEST" -and $_.Folder -ne "REPLICAS"} | Get-Snapshot | Select-Object Description, Created, VM, SizeMB, SizeGB

 

 

or

 

$Folders = "TEST", "REPLICAS"

Get-Vm | where {$Folders -NotContains $_.Folder.name } | Get-Snapshot | Select-Object Description, Created, VM, SizeMB, SizeGB

 

 

LucD
Leadership
Leadership
Jump to solution

Taking into account that casting is determined by the left operand, that should be

Get-Vm | where {$_.Folder.Name -ne "TEST" -and $_.Folder.Name -ne "REPLICAS"} | Get-Snapshot | Select-Object Description, Created, VM, SizeMB, SizeGB

or

Get-Vm | where {"TEST" -ne $_.Folder -and "REPLICAS" -ne $_.Folder} | Get-Snapshot | Select-Object Description, Created, VM, SizeMB, SizeGB

 


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