Howdy all,
I’m shamelessly trying to add on to our vCheck report to add in any NIC’s that are not Vmxnet3. I’m getting hung on the Get-NetworkAdapter because powercli is saying that it’s not recognized as a cmdlet, function, script file or operable program. And I can’t find any examples of this being done this way except the vCheck script 200 VMs on ephemeral portgroup.ps1…..which by the way has the same error when it’s run. Here is my script.
# Start of Settings
# End of Settings
$VMList = @($VM | Get-NetworkAdapter | Where-object {$_.Type -ne "Vmxnet3"} | Select @{N="VM";E={$_.Parent.Name}},Name,Type )
$VMList
$Title = "VMs without VMXNET3 Adapters"
$Header = "VMs that do not have VMXNET3 Adapters: $(@($VMList).count)"
$Comments = "The following VMs do not have VMXNET3 Adapters"
$Display = "Table"
$Author = "That Guy"
$PluginVersion = 1.1
$PluginCategory = "vSphere"
I can find all kinds of examples where I can do it with a Get-VM command but if I replace $VM with the Get-VM command I go back to the same “is not recognized” error. Here is the example.
Get-VM | Get-NetworkAdapter | Where-object {$_.Type -ne "Vmxnet3"} | foreach ($_) {Write-Host $_.Parent.Name "("$_.Name") type:" $_.Type} | export-Csv c:\Network_Interface.csv -NoTypeInformation
Ideas??
Which version of PowerCLI are you using? It might be an old version that did not have the Get-NetworkAdapter cmdlet.
6.3 Release 1 build 3737840
Would you mind sharing a screenshot with the error?
I tried your plugin, and it works without an issue for me (6.5.2).
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Here is the error.
Get-NetworkAdapter : Cannot validate argument on parameter 'Snapshot'. The
argument is null. Provide a valid value for the argument, and then try running
the command again.
At E:\powercli\vCheck\vCheck-vSphere-master-BillyTest\Plugins\60 VM\203 Check
for E1000 NIC.ps1:7 char:19
+ $VMList = @($VM | Get-NetworkAdapter | Where-object {$_.Type -ne "Vmxnet3"}
| Se ...
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-NetworkAdapter], Parameter
BindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.ViCore.Cmdlets.Commands.VirtualDevice.GetNetworkAdapter
But this is a different error, it seems to indicate that the $VM variable is empty.
Are you sure that you are connected to a vCenter when you run the script, but then again, that should have given an error message as well (while executing plugin 00)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference