This is very simple function to report all virtual machines in the defined System Center Virtual Machine Manager (SCVMM) with disconnected network adapters or with network adapters without specified VLAN.
Examples
Report
Get-RvSCVirtualNetworkAdapter -VMMServer firstVMM, secondVMM, thirdVMM -NoVMNetworkOrNoVLan | Out-GridView
Code
Function Get-RvSCVirtualNetworkAdapter
{
<#
.SYNOPSIS
Get network adapters of virtual machine on defined SCVMM server.
.DESCRIPTION
Developer
Developer: Rudolf Vesely, http://rudolfvesely.com/
Copyright (c) Rudolf Vesely. All rights reserved
License: Free for private use only
"RV" are initials of the developer's name Rudolf Vesely and distingue names of Rudolf Vesely's cmdlets from the other cmdlets.
Description
Get network adapters of virtual machine on defined SCVMM server.
Requirements
Developed and tested using PowerShell 4.0.
.PARAMETER NoVMNetwork
Get only disconnected NICs (no network).
.PARAMETER NoVLan
Get only NICs without specified VLAN.
.EXAMPLE
Get-RvSCVirtualNetworkAdapter -VMMServer firstVMM, secondVMM, thirdVMM -NoVMNetworkOrNoVLan |
Format-Table -Property Name, VirtualNetwork, LogicalNetwork, LogicalSwitch, VMNetwork, VLanEnabled, VLanID -AutoSize
.INPUTS
.OUTPUTS
.LINK
https://techstronghold.com/
#>
[CmdletBinding(
DefaultParametersetName = 'All',
SupportsShouldProcess = $true,
PositionalBinding = $false,
HelpURI = 'https://techstronghold.com/',
ConfirmImpact = 'Medium'
)]
Param
(
[Parameter(
Mandatory = $false,
# Position = ,
ParameterSetName = 'All'
)]
[switch]$All,
[Parameter(
Mandatory = $false,
# Position = ,
ParameterSetName = 'NoVMNetwork'
)]
[switch]$NoVMNetwork,
[Parameter(
Mandatory = $false,
# Position = ,
ParameterSetName = 'NoVLan'
)]
[switch]$NoVLan,
[Parameter(
Mandatory = $false,
# Position = ,
ParameterSetName = 'NoVLan'
)]
[switch]$NoVMNetworkOrNoVLan,
[Parameter(
Mandatory = $false
# Position = ,
# ParameterSetName = ''
)]
[ValidateLength(1, 255)]
[string[]]$VMMServer = '.'
)
Begin
{
# Configurations
$ErrorActionPreference = 'Stop'
if ($PSBoundParameters['Debug']) { $DebugPreference = 'Continue' }
Set-PSDebug -Strict
Set-StrictMode -Version Latest
}
Process
{
foreach ($vmmServerItem in $VMMServer)
{
Get-SCVirtualNetworkAdapter -All | ForEach-Object -Process `
{
if ($NoVMNetwork)
{
if (!$_.VirtualNetwork -or !$_.VMNetwork) { $_ }
}
elseif ($NoVLan)
{
if (!$_.VLanEnabled -or !$_.VLanID) { $_ }
}
elseif ($NoVMNetworkOrNoVLan)
{
if (!$_.VLanEnabled -or !$_.VLanID -or !$_.VirtualNetwork -or !$_.VMNetwork) { $_ }
}
else
{
$_
}
}
}
}
End
{
}
}
