Skip to content

Instantly share code, notes, and snippets.

@BenNeise
Created April 23, 2013 10:45
Show Gist options
  • Save BenNeise/5442585 to your computer and use it in GitHub Desktop.
Save BenNeise/5442585 to your computer and use it in GitHub Desktop.
Find machines where the configured memory is greater than 2000, and filter those machines to display only those with Windows XP guests.
# Loop through each VM
ForEach ($objVM in (
Get-VM | Where-Object {
# Where the configured memory is greater than 2000
$_.MemoryMB -gt "2000"
}
)){
# Get the VM guest object
Get-VMGuest -VM $objVM | Where-Object {
# Where the operating system is Windows XP
$_.OSFullName -like "Microsoft Windows XP Professional*"
# And display the VM object name, the guest hostname, and the memory in MB
} | Select-Object VMName,Hostname,MemoryMB
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment