PowerCLI

 View Only
  • 1.  Query ESXi hostname & DELL Service Tag

    Posted Jun 11, 2013 10:42 AM

    Hi there

    I need audit all ESXi 5.x hosts and provide the DELL Service Tag associated with it. I found the following script with mixed results

    Script:

    Get-View -ViewType HostSystem | Select Name,@{N="Tag";E={$_.Summary.Hardware.OtherIdentifyingInfo[0].IdentifierValue}}

    The script works fine however the Service Tags that returns is either not in the the same tag visible in the Properties view in the C# client or blank.

    I assumed it might be a hidden value for the Chassis.

    If i change the value to "OtherIdentifyingInfo[1] the fields remain blank or get populated 5[000]

    Is there a better way to query all the fields available for each host "Configuration|Processors|Systems"?

    Thanks

    Johan



  • 2.  RE: Query ESXi hostname & DELL Service Tag

    Posted Jun 11, 2013 11:05 AM

    The field that you retrieve with that script should be the Service Tag.

    But it depends on the HW you are using, it seems that some vendors didn't implement this in the way it is supposed to be done.

    With some vendors you even see a difference depending on the HW model you are using.



  • 3.  RE: Query ESXi hostname & DELL Service Tag

    Posted Jun 11, 2013 11:22 AM

    If you have a PowerShell v3 station you try to run something like this

    import-module CimCmdlets
    $ipaddress = "192.168.1.1"
    $HostUsername = "root"
    $CIOpt = New-CimSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck -Encoding Utf8 -UseSsl
    $Session = New-CimSession -Authentication Basic -Credential $HostUsername -ComputerName $Ipaddress -port 443 -SessionOption $CIOpt
    Get-CimInstance -CimSession $Session -ClassName CIM_PhysicalFrame

    The script is based on Alan's Using PowerShell v3.0 CIM cmdlets with VMware ESXi Hosts  post



  • 4.  RE: Query ESXi hostname & DELL Service Tag

    Posted Jun 11, 2013 01:17 PM

    Hi Luc

    Great thanks, I installed PSv3 and script work like a charm. Any advise on how to query this for all 100 hosts and then to filter the below output to get the first Tag listed "SerialNumber" instead of Service Tag the labeled used in the C# client

    AudibleAlarm              :

    BreachDescription         :

    CableManagementStrategy   :

    CanBeFRUed                :

    Caption                   : Chassis

    ChassisPackageType        :

    ChassisTypeDescription    :

    CommunicationStatus       :

    CreationClassName         : OMC_Chassis

    CurrentRequiredOrProduced :

    Depth                     :

    Description               :

    DetailedStatus            :

    ElementName               : Chassis

    HealthState               :

    HeatGeneration            :

    Height                    :

    HotSwappable              :

    InstallDate               :

    InstanceID                :

    IpmiNodeCount             : 1

    IsLocked                  :

    LockPresent               : false

    ManufactureDate           :

    Manufacturer              : Dell Inc.

    Model                     : PowerEdge M620

    MultipleSystemSupport     :

    Name                      :

    NumberOfPowerCords        :

    OEMSpecificStrings        : {Dell System, 5[0000]}

    OperatingStatus           :

    OperationalStatus         : 0

    OtherIdentifyingInfo      : Asset Tag: unknown

    OtherPackageType          :

    PackageType               : 16

    PartNumber                :

    PoweredOn                 : true

    PrimaryStatus             :

    RackMountable             :

    Removable                 :

    RemovalConditions         : 0

    Replaceable               :

    SKU                       :

    SecurityBreach            :

    SerialNumber              : GNML9X1

    Status                    : Unknown

    StatusDescriptions        : unknown

    Tag                       : 23.0

    UserTracking              :

    VendorEquipmentType       :

    Version                   : PowerEdge M1000e

    VisibleAlarm              :

    Weight                    :

    Width                     :

    uuid                      : 4c4c4544-004e-4d10-804c-c7c04f395831

    PSComputerName            : dcpwesx005

    AudibleAlarm              :

    BreachDescription         :

    CableManagementStrategy   :

    CanBeFRUed                :

    Caption                   : Chassis

    ChassisPackageType        : 28

    ChassisTypeDescription    : Blade Enclosure

    CommunicationStatus       :

    CreationClassName         : OMC_Chassis

    CurrentRequiredOrProduced :

    Depth                     :

    Description               :

    DetailedStatus            :

    ElementName               : Chassis

    HealthState               :

    HeatGeneration            :

    Height                    :

    HotSwappable              :

    InstallDate               :

    InstanceID                :

    IpmiNodeCount             : 1

    IsLocked                  :

    LockPresent               : false

    ManufactureDate           :

    Manufacturer              : Dell Inc.

    Model                     : PowerEdge M620

    MultipleSystemSupport     : 1

    Name                      :

    NumberOfPowerCords        :

    OperatingStatus           :

    OperationalStatus         : 0

    OtherIdentifyingInfo      : Asset Tag: unknown

    OtherPackageType          :

    PackageType               : 3

    PartNumber                :

    PoweredOn                 : true

    PrimaryStatus             :

    RackMountable             :

    Removable                 :

    RemovalConditions         : 0

    Replaceable               :

    SKU                       :

    SecurityBreach            :

    SerialNumber              : 5TF085J

    Status                    : Unknown

    StatusDescriptions        : unknown

    Tag                       : 23.1

    UserTracking              :

    VendorEquipmentType       :

    Version                   : PowerEdge M1000e

    VisibleAlarm              :

    Weight                    :

    Width                     :

    uuid                      : 4c4c4544-004e-4d10-804c-c7c04f395831

    PSComputerName            : dcpwesx005



  • 5.  RE: Query ESXi hostname & DELL Service Tag

    Posted Jun 11, 2013 02:12 PM

    Try something along these lines

    Import-Module CimCmdlets
    $CIOpt = New-CimSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck -Encoding Utf8 -UseSsl

    $cred = Get-Credential -Message "ESXi credentials" -UserName root

    Get-VMHost | %{
       
    $Session = New-CimSession -Authentication Basic -Credential $cred -ComputerName $_.Name -port 443 `
           
    -SessionOption $CIOpt
       
    $frame = Get-CimInstance -CimSession $Session -ClassName CIM_PhysicalFrame
       
    $_ | Select Name,@{N="$frame.SerialNumber"
    }

    It assumes that you can use the same credential for each of your ESXi servers.



  • 6.  RE: Query ESXi hostname & DELL Service Tag

    Posted Mar 09, 2014 07:44 AM

    Hello,

    I get error to import the module

    import-module CimCmdlets


    Can that be use in "powerCLI" ?


    Thanks




  • 7.  RE: Query ESXi hostname & DELL Service Tag

    Posted Mar 09, 2014 07:45 AM

    esxcli hardware platform get

    above gives the info for dell servers in esxi5x

    so can we use that one in power cli ?



  • 8.  RE: Query ESXi hostname & DELL Service Tag

    Posted Mar 09, 2014 08:11 AM

    To use the CimCmdlets module, you need at least PowerShell 3.0.

    You can use the esxcli commands from PowerCLI using the Get-EsxCli cmdlet, for example:

    PowerCLI C:\> $EsxCli = Get-VMHost -Name 192.168.0.133 | Get-EsxCli

    PowerCLI C:\> $EsxCli.hardware.platform.get()


    IPMISupported : false

    ProductName   : VMware Virtual Platform

    SerialNumber  : VMware-56 4d 18 c1 ff 0d 73 69-f4 dc 7b d3 c6 a5 79 d9

    UUID          : 0x56 0x4d 0x18 0xc1 0xff 0xd 0x73 0x69 0xf4 0xdc 0x7b 0xd3 0xc6 0xa5 0x79 0xd9

    VendorName    : VMware, Inc.



    As you can see in the output, my ESXi server is a nested ESXi server running on a VMware hypervisor, VMware Fusion in this case.