VMware Cloud Community
kaljoh
Contributor
Contributor

Get-CINetworkAdapter broken VM parameter validation for unset or null values.

PowerCLI Get-CINetworkAdapter broken VM parameter validation for unset or null values.

When trying to list network adapters for a VM surprisingly results in returning *all* the network adapters of *all* the VMs, if VM parameter for Get-CINetworkAdapter is accidentally null or unset.

To reproduce the issue:

PS C:\> Get-CINetworkAdapter -VM $unsetornullvariable

Surprisingly that doesn't give an error, but instead it returns *all* the NICs of *all* the VMs!

Expected behaviour:

Error stating null or or empty variable, like when passing the same variable to vappnetwork argument.

It's especially dangerous if used like:

Get-CInetworkadapter -VM $vm | Set-CINetworkAdapter

Which might result in unexpectedly modifying networking settings for *all* the VMs.

NOTE! "VAppNetwork" parameter *does* have proper error handling and validation:

PS C:\> Get-CInetworkadapter -VAppNetwork $unsetornullvariable

Get-CINetworkAdapter : Cannot validate argument on parameter 'VAppNetwork'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.

At line:1 char:35

So only the "VM" parameter lacks proper error handling.

Tested with PowerCLI 6.5.1 & 11.0.0 against vCloud director 9.1.0.2

0 Kudos
0 Replies