Greetings,
I need to go through all of my VM's in vCenter and find any NIC that is CONNECTED but set to NOT CONNECT AT STARTUP, and then configure the NIC to CONNECT AT STARTUP. You can see I can parse out the ConnectionState.StartConnected value, but how do I also grab whether the NIC is currently connected? ConnectionState.Connected does not seem to work for me. Note that the VM's in question my have a single NIC or multiples...
Get-NetworkAdapter -VM $Vm.Name | Where-object {-not $_.ConnectionState.StartConnected} |
Select-Object @{N = 'vCenter'; E = { ([uri]$_.Parent.ExtensionData.Client.ServiceUrl).Host }},
@{N="VM Name";E={$_.Parent}},
@{N="NIC Name";E={$_.Name}},
@{N="NIC Type";E={$_.Type}},
@{N="Network Name";E={$_.NetworkName}},
@{N="Connection State";E={$_.ConnectionState}},
@{N="MAC Address";E={$_.MacAddress}},
@{N="WakeOnLan Enabled";E={$_.WakeOnLanEnabled}} |
Export-Csv .\NetAdapterStartUp.csv -Append -NoTypeInformation
I've also tried this:
Get-VM | Where{ Get-NetworkAdapter -VM $_ | Where-object {($_.ConnectionState.Connected ) -and ( not $_.ConnectionState.StartConnected)}}
But this just shows which VM's have ANY NIC set to what I am looking for....
This is probably simple, but I am having a roadblock somewhere in my brain.....