PowerShell management commands

$owners = @{}
gwmi win32_process |% {$owners[$_.handle] = $_.getowner().user}
get-process | sort vm | select processname, Id, @{l="Owner";e={$owners[$_.id.tostring()]}}

While(1) {ps | sort -des cpu | select -f 15 | ft -a; sleep 1; cls}

Get-Process | sort vm | select name, vm -Last 5

Get-WmiObject win32_processor | select LoadPercentage  |fl

Get-Counter '\Memory\Available MBytes'
Get-Counter '\Processor(_Total)\% Processor Time'

ESX host or guest IP address inventory via PowerCLI

IPaddresses = @()

foreach($vm in Get-VM){     $vm.Guest.Nics | %{         $row = “” | Select Name, IP, MAC         $row.Name = $vm.Name         $row.IP = &{if($_.IPAddress){[String]::Join(‘,’,$_.IPAddress)}}         $row.MAC = $_.MacAddress         $IPaddresses += $row     } }

$IPaddresses = @()

Get-VMHost | Get-VMHostNetworkAdapter -VMKernel | %{     $row = “” | Select Name, IP, MAC     $row.Name = $_.VMHost.Name     $row.IP = $_.IP     $row.MAC = $_.MAC     $IPaddresses += $row }

$IPaddresses

 

or

 

Get-VMHostNetworkAdapter | select VMhost, Name, IP, SubnetMask | Export-Csv -NoTypeInformation C:\temp\host.csv

 

various WMI computer inventory commands via Powershell

wmi Win32_OperatingSystem.CSName
gwmi Win32_OperatingSystem.Name

Get-WmiObject Win32_OperatingSystem).Name | format-list

(Get-WmiObject Win32_OperatingSystem).CSName

Get-WmiObject Win32_OperatingSystem | Format-List csname, name

Get-WmiObject Win32_NetworkAdapterConfiguration | Format-List IPAddress

Get-WmiObject Win32_OperatingSystem | Format-List csname, name

gwmi Win32_NetworkAdapterConfiguration |     Where { $_.IPAddress } | # filter the objects where an address actually exists     Select -Expand IPAddress | # retrieve only the property *value*     Where { $_ -like ‘192.168.*’ }