VMware Cloud Community
OBTMOM
Enthusiast
Enthusiast

Extract/list OVF Vendor Details

Hello again,

we do run some appliances where i would need to get the vendor details out of the option.

What i found so far is this

Get-View -viewtype virtualmachine -Filter @{‘config.VAppConfig’=‘VMware.Vim.VmConfigInfo’} | select Name, @{N=“Appliance Name”; @{N=“Vendor”; E={$_.config.VAppConfig.product.Vendor}}

this does make the trick to get the vendor details but i would need to for a single machine to be able to compare and run a IF/Else command with it.

Here i would need the command for a single vm.

Something like

$vm = get vendor name.

Afterwards i could run a if statement with it.

Would you please help me to get a solution?

thank you very very much.

best wishes armin

0 Kudos
4 Replies
LucD
Leadership
Leadership

Are you sure that the first calculated property is correct?

Shouldn't that be

@{N=“Appliance Name”; E={$_.config.VAppConfig.product.Name}}


If I understand the question correctly, you want a method to retrieve that Vendor's name.

You could do that in a function like this

function Get-VendorName{

    param(

        [VMware.Vim.VirtualMachine]$VM

    )


    if($vm.Config.VAppConfig -is [VMware.Vim.VmConfigInfo]){

        $VM.config.VAppConfig.product.Vendor

    }

    else{'na'}

}

You can then use that function in a Select-Object

Get-View -viewtype virtualmachine |

Select Name,@{N='Vendor';E={Get-VendorName -VM $_}}

or as a way to test on the Vendor name

Get-View -viewtype virtualmachine -PipelineVariable vm |

ForEach-Object -Process {

    $vendor = Get-VendorName -VM $_

    if($vendor -eq 'VMware Inc.'){

        Write-Host "$($vm.Name) is an appliance from $vendor"

    }

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

OBTMOM
Enthusiast
Enthusiast

Excellent. Let me give that a try.

Luc, as always i cannot thank you enough!

0 Kudos
OBTMOM
Enthusiast
Enthusiast

Hi Luc,

your script worked but i would need it for a single vm to be able to run a configuration afterwards (the uuid thing)

This was the command i used before.

Get-View -viewtype virtualmachine -Filter @{‘config.VAppConfig’=‘VMware.Vim.VmConfigInfo’} | select Name, @{N=“Appliance Name”; E={$_.config.VAppConfig.product.name}}, @{N=“Vendor”; E={$_.config.VAppConfig.product.Vendor}}, @{N=“Version”; E={$_.config.VAppConfig.product.Version}}

output was listed with all vms.

Name                                           Appliance Name           Vendor      Version

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

F5-MWLAB-DMZ-GTM-001                           BIG-IP VE 14.1.2.1.0.0.4 F5 Networks 14.1.2.1

F5-MWLAB-DMZ-GTM-002                           BIG-IP VE 14.1.2.1.0.0.4 F5 Networks 14.1.2.1

F5-MWLAB-DMZ-LTM-ASM-001                       BIG-IP VE 14.1.2.1.0.0.4 F5 Networks 14.1.2.1

F5-MWLAB-DMZ-LTM-ASM-002                       BIG-IP VE 14.1.2.1.0.0.4 F5 Networks 14.1.2.1

F5-MWLAB-DMZ-LTM-APM-001                       BIG-IP VE 14.1.2.1.0.0.4 F5 Networks 14.1.2.1

F5-MWLAB-DMZ-LTM-APM-002                       BIG-IP VE 14.1.2.1.0.0.4 F5 Networks 14.1.2.1

F5-MWLAB-LAN-GTM-001                           BIG-IP VE 14.1.2.1.0.0.4 F5 Networks 14.1.2.1

F5-MWLAB-LAN-GTM-002                           BIG-IP VE 14.1.2.1.0.0.4 F5 Networks 14.1.2.1

F5-MWLAB-LAN-LTM-001                           BIG-IP VE 14.1.2.1.0.0.4 F5 Networks 14.1.2.1

F5-MWLAB-LAN-LTM-002                           BIG-IP VE 14.1.2.1.0.0.4 F5 Networks 14.1.2.1

F5-MWLAB-LAN-LTM-003                           BIG-IP VE 14.1.2.1.0.0.4 F5 Networks 14.1.2.1

F5-MWLAB-LAN-LTM-004                           BIG-IP VE 14.1.2.1.0.0.4 F5 Networks 14.1.2.1

F5-MWLAB-RF-LAN-LTM-ASM-001                    BIG-IP VE 14.1.2.1.0.0.4 F5 Networks 14.1.2.1

F5-MWLAB-RF-LAN-LTM-ASM-002                    BIG-IP VE 14.1.2.1.0.0.4 F5 Networks 14.1.2.1

F5-MWLAB-LAN-LTM-001_clean_DAILY_20200925_bkp1 BIG-IP VE 14.1.2.1.0.0.4 F5 Networks 14.1.2.1

my action should focus on a single vm.

Example check if F5-MWLAB-DMZ-GTM-001 has the vendor F5 Network than do "something".

Else leave it alone...

Hope you can follow me Smiley Happy

thanks Luc!

0 Kudos
OBTMOM
Enthusiast
Enthusiast

Ok, i do get a result here.

Your function:

function Get-VendorName{

                        param(

                                [VMware.Vim.VirtualMachine]$VM

                                )

                        if($vm.Config.VAppConfig -is [VMware.Vim.VmConfigInfo]){

                        $VM.config.VAppConfig.product.Vendor

                       }

                        else{'na'}

                       }

with this

Get-View -viewtype virtualmachine -PipelineVariable vm |

ForEach-Object -Process {

    $vendor = Get-VendorName -VM $_

    if($vendor -eq 'F5 Networks'){

        if ($vmname -eq $($vm.Name)) {Write-Host "this is an F5 $vmname / $($vm.Name)"}

    }

}

is does show me my vmname and the name from the list. So could i use this to run another IF command?

thanks!

0 Kudos