Usefull VI Toolkit / Powershell commands

April 2, 2009 — Leave a comment

A few useful VI Toolkit commands I have found / modified.

Get all Service Console IPs

 

Get-VMHost | where {$_.State -eq “Connected”} | Get-View | `

  %{$esxName = $_.Name; Get-View -Id $_.ConfigManager.NetworkSystem} | `

  %{$_.NetworkInfo.ConsoleVnic} | `

  %{Write-Host $esxName $_.Portgroup $_.Spec.Ip.IpAddress}

 

Get all VMKernel IPs

 

Get-VMHost | where {$_.State -eq “Connected”} | Get-View | `

%{$esxName = $_.Name; Get-View -Id $_.ConfigManager.NetworkSystem} | `

%{$_.NetworkInfo.Vnic} | `

%{Write-Host $esxName $_.Portgroup $_.Spec.Ip.IpAddress}

 

Get VM Free Disk Space

 

Connect-VIServer cw-vc

Get-VM | Where { $_.PowerState -eq “PoweredOn” } | Get-VMGuest | Select VmName -ExpandProperty disks  | Select VmName, Path, @{ N=”PercFree”; E={ [math]::Round( (100 * ( $_.FreeSpace / $_.Capacity ) ),0 ) } } | Sort PercFree

 

No Comments

Be the first to start the conversation!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s