toffaha1
Enthusiast
Enthusiast

List all ESXi with all vibs installed + ESXi Serial number + Current power Policy

Jump to solution

Hi Team,

I have some PowerCLI script for listing all ESXi Vibs and getting the build number/serial number and the current policy and I need some guidance for how to combine them into one output or CSV file.

 

Power Policy

 

Get-VMHost |

Select Name,

    @{N='Power Technology';E={$_.ExtensionData.Hardware.CpuPowerManagementInfo.HardwareSupport}},

    @{N='Current Policy';E={$_.ExtensionData.Hardware.CpuPowerManagementInfo.CurrentPolicy}}

 

 
List all VIBs 
 
 

 

$list = @()
$hosts = Get-Cluster myCluster | Get-VMHost
forEach ($vihost in $hosts)
{
$esxcli = get-vmhost $vihost | Get-EsxCli
$list += $esxcli.software.vib.list()  | Select @{N="VMHost";E={$ESXCLI.VMHost}}, Name, Version 
}

$list | Export-Csv -Path c:\test\test.csv -NoTypeInformation

 

 
Build number and Serial number 
 
 

 

Get-Vmhost | Get-View | Sort-object Name | 
select Name,
@{N='Product';E={$_.Config.Product.FullName}},
@{N='Build';E={$_.Config.Product.Build}},
@{Name="Serial Number"; Expression={($_.Hardware.SystemInfo.OtherIdentifyingInfo | where {$_.IdentifierType.Key -eq "ServiceTag"}).IdentifierValue}}

 

Best Regards,
Muhammad Toffaha
Technical Consultant
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

You can combine, but you will have a lot of redundant information in the result.

Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
    $esxcli = Get-EsxCli -VMHost $esx -V2
    $esxcli.software.vib.list.Invoke() |
    ForEach-Object -Process {
        New-Object -TypeName PSObject -Property ([ordered]@{
            VMHost = $esx.Name
            Product = $esx.ExtensionData.Config.Product.FullName
            Build = $esx.ExtensionData.Config.Product.Build
            'Serial Number' = ($esx.ExtensionData.Hardware.SystemInfo.OtherIdentifyingInfo | where {$_.IdentifierType.Key -eq "ServiceTag"}).IdentifierValue
            'Power Technology' = $esx.ExtensionData.Hardware.CpuPowerManagementInfo.HardwareSupport
            'Current Policy' = $esx.ExtensionData.Hardware.CpuPowerManagementInfo.CurrentPolicy
            'VIB Name' = $_.Name
            'VIB Version' = $_.Version
        })
    }
} | Export-Csv -Path c:\test\test.csv -NoTypeInformation -UseCulture


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

View solution in original post

5 Replies
LucD
Leadership
Leadership

You can combine, but you will have a lot of redundant information in the result.

Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
    $esxcli = Get-EsxCli -VMHost $esx -V2
    $esxcli.software.vib.list.Invoke() |
    ForEach-Object -Process {
        New-Object -TypeName PSObject -Property ([ordered]@{
            VMHost = $esx.Name
            Product = $esx.ExtensionData.Config.Product.FullName
            Build = $esx.ExtensionData.Config.Product.Build
            'Serial Number' = ($esx.ExtensionData.Hardware.SystemInfo.OtherIdentifyingInfo | where {$_.IdentifierType.Key -eq "ServiceTag"}).IdentifierValue
            'Power Technology' = $esx.ExtensionData.Hardware.CpuPowerManagementInfo.HardwareSupport
            'Current Policy' = $esx.ExtensionData.Hardware.CpuPowerManagementInfo.CurrentPolicy
            'VIB Name' = $_.Name
            'VIB Version' = $_.Version
        })
    }
} | Export-Csv -Path c:\test\test.csv -NoTypeInformation -UseCulture


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

toffaha1
Enthusiast
Enthusiast

Thanks, @LucD  for your usual support.

Best Regards,
Muhammad Toffaha
Technical Consultant
0 Kudos
casaub
Enthusiast
Enthusiast

Hello,

this looks like a useful script. But is it working?

 

When I run it (vSphere 6.7) it gives me errors:

 

At line:1 char:235
+ ... me PSObject -Property ([ordered]@{ VMHost = $esx.Name Product = $esx. ...
+ ~~~~~~~
Unexpected token 'Product' in expression or statement.
At line:1 char:234
+ ... -TypeName PSObject -Property ([ordered]@{ VMHost = $esx.Name Product ...
+ ~
The hash literal was incomplete.
At line:1 char:234
+ ... -TypeName PSObject -Property ([ordered]@{ VMHost = $esx.Name Product ...
+ ~
Missing closing ')' in expression.
At line:1 char:60
+ Get-VMHost -PipelineVariable esx | ForEach-Object -Process { $esxcli ...
+ ~
Missing closing '}' in statement block or type definition.
At line:1 char:702
+ ... rentPolicy 'VIB Name' = $_.Name 'VIB Version' = $_.Version }) } } | E ...
+ ~
Unexpected token ')' in expression or statement.
At line:1 char:704
+ ... ntPolicy 'VIB Name' = $_.Name 'VIB Version' = $_.Version }) } } | Exp ...
+ ~
Unexpected token '}' in expression or statement.
At line:1 char:706
+ ... Policy 'VIB Name' = $_.Name 'VIB Version' = $_.Version }) } } | Expor ...
+ ~
Unexpected token '}' in expression or statement.
At line:1 char:708
+ ... licy 'VIB Name' = $_.Name 'VIB Version' = $_.Version }) } } | Export- ...
+ ~
An empty pipe element is not allowed.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken

0 Kudos
LucD
Leadership
Leadership

Looks like you lost some CR-LF during the copy/paste.
Try the attached version


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

casaub
Enthusiast
Enthusiast

That was it. Thank you.

Tags (1)
0 Kudos