VMware Cloud Community
Yoko002
Contributor
Contributor
Jump to solution

I want to know "Device Status"

Could you give me some advice?


I want to know the status of the device.


[Virtual Machine Properties ]

 NetworkAdapter  ...   "network001"

          [Device Status]

                connected                            <-----   check on or off ?

                Connect at power on             <-----   check on or off ?


I tried [Get-NetworkAdapter -VM VMNAME] , but did not get along well ...


is there something good way ?


Sincerely

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
MKguy
Virtuoso
Virtuoso
Jump to solution

The ConnectionState properties contain the equivalents to these check boxes in the GUI:

(Get-NetworkAdapter -VM MyVM).ConnectionState.Connected

(Get-NetworkAdapter -VM MyVM).ConnectionState.StartConnected


If checked, it will return a True value. If unchecked, False.

-- http://alpacapowered.wordpress.com

View solution in original post

Reply
0 Kudos
2 Replies
MKguy
Virtuoso
Virtuoso
Jump to solution

The ConnectionState properties contain the equivalents to these check boxes in the GUI:

(Get-NetworkAdapter -VM MyVM).ConnectionState.Connected

(Get-NetworkAdapter -VM MyVM).ConnectionState.StartConnected


If checked, it will return a True value. If unchecked, False.

-- http://alpacapowered.wordpress.com
Reply
0 Kudos
Yoko002
Contributor
Contributor
Jump to solution

Dear  MKguy

Thank you for giving me good advice !

I got very good results

---------------------------------------------------------------------

$AuditVM = @()
foreach ($vm in Get-VM | Where-Object {$_.PowerState -eq "PoweredOn"}) {
  foreach ($nic in Get-NetworkAdapter $vm | Where-Object {$_.ConnectionState.StartConnected -eq $False}) {

    $objVM= "" | Select Name,NetworkName,ConnectatPowerOn,Connected

    $objVM.Name = $vm.Name
    $objVM.NetworkName = $nic.NetworkName
    $objVM.ConnectatPowerOn = $nic.ConnectionState.StartConnected
    $objVM.Connected = $nic.ConnectionState.Connected

    $AuditVM += $objVM
  }
}

$AuditVM

---------------------------------------------------------------------

Thanks again.

Reply
0 Kudos