VMware Cloud Community
nicholas1982
Hot Shot
Hot Shot
Jump to solution

Find Flexible Adapters ?

Hi Guys,

Can someone help me modify this script to find all VM's with flexible adapters regardless of the Tools Status?

If it could display the OS type too that would be great.

# Get all VM objects

$vms = get-view -viewtype virtualmachine

# Set up an empty array

$table = @()

# For Every Vm...

Foreach ($vm in $vms)

{

    # If Tools aren't installed and there is a PCNet32 adapter in the hardware list...

    if ($vm.guest.toolsstatus -eq "toolsNotInstalled" -and (($vm.config.hardware.device | %{$_ -is [VMware.Vim.VirtualPCNet32]}) -contains $true))

    {

        # Then output it to an object and add it to the array

        $table += New-Object PSObject -Property @{"Name"=$vm.name; "ToolsStatus"=$vm.guest.toolsstatus; "NicType"="Flexible"}

    }

}

# Output the table. You can Export to a CSV or whatever here.

$table

Nicholas
Reply
0 Kudos
1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership
Jump to solution

The following code finds all vm's with flexible adapters:

# Get all VM objects
$vms = get-view -viewtype virtualmachine -Property name,config.hardware.device

# Set up an empty array
$table = @()

# For Every Vm...
Foreach ($vm in $vms)
{
    # If there is a PCNet32 adapter in the hardware list...
    if ((($vm.config.hardware.device | %{$_ -is [VMware.Vim.VirtualPCNet32]}) -contains $true))
    {
        # Then output it to an object and add it to the array
        $table += New-Object PSObject -Property @{"Name"=$vm.name; "NicType"="Flexible"}
    }
}

# Output the table. You can Export to a CSV or whatever here.
$table

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

Reply
0 Kudos
3 Replies
RvdNieuwendijk
Leadership
Leadership
Jump to solution

The following code finds all vm's with flexible adapters:

# Get all VM objects
$vms = get-view -viewtype virtualmachine -Property name,config.hardware.device

# Set up an empty array
$table = @()

# For Every Vm...
Foreach ($vm in $vms)
{
    # If there is a PCNet32 adapter in the hardware list...
    if ((($vm.config.hardware.device | %{$_ -is [VMware.Vim.VirtualPCNet32]}) -contains $true))
    {
        # Then output it to an object and add it to the array
        $table += New-Object PSObject -Property @{"Name"=$vm.name; "NicType"="Flexible"}
    }
}

# Output the table. You can Export to a CSV or whatever here.
$table

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
Reply
0 Kudos
nicholas1982
Hot Shot
Hot Shot
Jump to solution

Hi There,

Thanks any chance we can modify to find VM with VMXNET3 ?

Nicholas
Reply
0 Kudos
nicholas1982
Hot Shot
Hot Shot
Jump to solution

Thats cool, I just replaced VirtualPCNet32 with Vmxnet3 Smiley Happy

Nicholas
Reply
0 Kudos