Wednesday, August 24, 2011

Powershell selection stuff..

Something to remember for myself about selecting:

get-vm | gm as an example, shows all methods and properties you can do with get-vm.

get-vm | where {$_.PowerState -eq "PoweredOn" -and $_.Name -ne "PietjePuk" }

Shows all VM's that are powered on but not that one VM that is called "PietjePuk".
$_.Powerstate is one of the properties of the get-vm statement.

This is how you can select VM's based on different properties.

So get-vm | where {$_.MemoryMB -eq "4096"} shows you all vm's that have 4GB of memory.

-eq = equals
-ne = does not equal
-and = a secondary variable to select.