Last active
August 2, 2016 15:04
-
-
Save chelnak/7fd6f759e7f9548fec40fe94eff3889f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-VMExtendedInfo { | |
<# | |
.SYNOPSIS | |
Gets extended information about a Virtual Machine | |
.DESCRIPTION | |
Gets extended information about a Virtual Machine | |
.PARAMETER VM | |
The Virtual Machine to query | |
.INPUTS | |
PSObject | |
.OUTPUTS | |
System.Management.Automation.PSObject | |
.EXAMPLE | |
Get-VM | Get-VMExtendedInfo | Export-Csv -Path .\VMInfo.csv -NoTypeInformation | |
.EXAMPLE | |
Get-VM | Get-VMExtendedInfo | |
.EXAMPLE | |
Get-VM -Name VM-01 | Get-VMExtendedInfo | |
#> | |
[CmdletBinding()][OutputType('System.Management.Automation.PSObject')] | |
Param ( | |
[parameter(Mandatory=$true, ValueFromPipeline=$true)] | |
[ValidateNotNullOrEmpty()] | |
[PSObject[]]$VM | |
) | |
begin {} | |
process{ | |
foreach ($VirtualMachine in $VM) { | |
$View = $VirtualMachine | Get-View | |
[URI]$ServiceUrl = $View.Client.ServiceUrl | |
[PSCustomObject]@{ | |
Name = $VirtualMachine.Name | |
PowerState = $View.Runtime.PowerState | |
GuestOSFullName = $View.Guest.GuestFullName | |
ParentHost = $VirtualMachine.VMHost.Name | |
ParentvCenter = $ServiceUrl.Host | |
ParentvCenterFolder = $VirtualMachine.Folder | |
ParentDatacenter = ($VirtualMachine | Get-Datacenter).Name | |
NumberOfNics = ($VirtualMachine | Get-NetworkAdapter).Count | |
} | |
} | |
} | |
end {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment