Functions/Get-VMInfo.ps1
function Get-VMInfo { [CmdletBinding()] param ( [Parameter(Mandatory)] [ValidateSet("Storage", "IsoMounted", "Switches", "Network")] [string] $InfoType ) $AllVms = Get-VM if (!($AllVms)) { break } switch ($InfoType) { "Storage" { $Result = $AllVms | Sort-Object Path | Select-Object Name, Path } "IsoMounted" { $Result = $AllVms | Get-VMDvdDrive | Select-Object VMName, Path } "Switches" { $Result = Get-VMSwitch | Sort-Object Name | Select-Object Name, SwitchType, NetAdapterInterfaceDescription } "Network" { $Result = $AllVms | Get-VMNetworkAdapter | Select-Object VMName, SwitchName, MacAddress, IPAddresses } } return $Result } |