Checking for VM Snapshots in vCenter using Powershell

A small script to output snapshots per VM.

Connect-VIServer myserver.fqdn.com
Write "#####START#####"
$vms = $null
$vms = Get-VM
foreach ($vm in $vms) {
$snapshots =  Get-Snapshot -VM $vm
$i = 1
foreach ($snapshot in $snapshots) {
$i = $i + 1
if ($i -ge 2) {
$vm.name
$i
#$snapshot.Name
#$snapshotTable =  @($vm.Name) # | Sort-Object {$_.name}
#$snapshotTable
}
}
}
Write "#####DONE######"

You can also list snapshots based on a name containing any value using the following code:

Get-VM | Get-Snapshot | Where-Object {$_. -contains "searchString"}

List all VMs with a memory limit set in vCenter using Powershell

This script lists all VMs with a memory limit set in Resource Manger in a given VMWare cluster.

Connect-VIServer myserver.fqdn.com 
Get-Cluster $Cluster | Get-VM | Get-VMResourceConfiguration | where {$_.MemLimitMB -ne "-1"}

If you want to clear all memory limits and set them to unlimited use the following code

Connect-VIServer myserver.fqdn.com 
Get-Cluster MyCluster | Get-VM | Get-VMResourceConfiguration | where {$_.MemLimitMB -ne "-1"} | Set-VMResourceConfiguration -MemLimitMB $null

The same can also be done for the CPU management using CpuLimitMhz attribute.