VMware Cloud Community
swamynaveen
Enthusiast
Enthusiast

Need powerCLi script for ESXi build validation check list.

Hello Friends,

I am looking for a powercli script to check the ESXi configuration details post completion of ESXi build process. The following details need to be reported over csv or any HTML format.

1. Host name

2.Host IP,subnetmask

3.ESXi OS version & Build number

4.syslog details

5.NTP server details & running status.

6.DNS servers& DNS suffix

7.Default gateway.

8.license status

9.SSH configuration

10.Power management to higher performance

11.vmkernel portgroups & active services enabled on them like MGMT,vMotion,FT... etc.

12.vSwitch details &uplink teaming status.

13.DV swtich details & Uplinke teaming status.

14.vCenter, Datacenter,cluster details.

15.default multipathing policy of storage.

16.CDP details & observed VLAN list.

17.Firmware & driver version details of all the hardware components like SASRAID,storage,VMNIC.. etc.

18.Hardware model & serial number.

Regards,

Naveen

9 Replies
LucD
Leadership
Leadership

Do you want rice or fries with that :smileygrin:


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

daphnissov
Immortal
Immortal

Please take a moment to read the article in my signature to understand why this is an unreasonable request.

Reply
0 Kudos
sk84
Expert
Expert

swamynaveen​, in all your posts you are just asking for working PowerCLI scripts. And in not in a single post did you show that you tried it yourself. You just demand that we do the whole work for you. But we are a community and we are here to help each other. And we're not a software company that develops scripts for you for free. So, if you want our help, please start developing, do your own part and if you have any questions or problems, we can help.

--- Regards, Sebastian VCP6.5-DCV // VCP7-CMA // vSAN 2017 Specialist Please mark this answer as 'helpful' or 'correct' if you think your question has been answered correctly.
Reply
0 Kudos
swamynaveen
Enthusiast
Enthusiast

Nope. just to simplify the build validation process. I’ve some scripts but they are not included all the details that I am looking for. Cloud you please help me with this requirement?

Thank you in advance!!

Reply
0 Kudos
swamynaveen
Enthusiast
Enthusiast

sk84​, Never mind, Yes, I also working on some scripts to complete this requirement. so just posted build check list in the forum so that experts can help us with the requirement. It can also helpful for the forum members as well. sure, thanks for the advice we'll follow your suggestions.

Reply
0 Kudos
LucD
Leadership
Leadership

Look, you are asking 18 questions in one thread.

You don't show anything that you already have, and where you eventually got stuck.
Most of the points in your list have been handled in other threads in this community.
Did you even do a search?

You shouldn't consider this community as a free scripting service.
The intention is to help users that get stuck at some point.

I would strongly suggest giving Chip's blog post a read.


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

Reply
0 Kudos
swamynaveen
Enthusiast
Enthusiast

LucD​, I totally agree on your points. there are different scripts available to get individual details. however, I would like to fetch all those 18 details into one report that would be helpful for host configuration standpoint. I just tried with below script however, some details are still not showing. Could you please help me with this requirement?

Thank you in advance.

$report = Get-Datacenter | % {  

      $datacenter=$_

      foreach($esx in Get-VMhost -Location $datacenter){

        $esxcli = Get-EsxCli -VMHost $esx -V2

        $nic = Get-VMHostNetworkAdapter -VMHost $esx | Select -First 1 | select -ExpandProperty Name

        $hba =Get-VMHostHBA -VMHost $esx -Type FibreChannel | where {$_.Status -eq "online"} |  Select -First 1 |select -ExpandProperty Name

        Get-VMHostHBA -VMHost $esx -Type FibreChannel | where {$_.Status -eq "online"} |

        Select @{N="Datacenter";E={$datacenter.Name}},

                @{N="VMHost";E={$esx.Name}},

                @{N="HostName";E={$($_.VMHost | Get-VMHostNetwork).HostName}},

                @{N="version";E={$esx.version}},

                @{N="Manufacturer";E={$esx.Manufacturer}},

                @{N="Hostmodel";E={$esx.Model}},

                @{Name="SerialNumber";Expression={$esx.ExtensionData.Hardware.SystemInfo.OtherIdentifyingInfo |Where-Object {$_.IdentifierType.Key -eq "Servicetag"} |Select-Object -ExpandProperty IdentifierValue}},

                @{N='vCenter';E={$_.Uid.Split('@')[1].Split(':')[0]}},

                @{N='DNSAddress';E={$script:net.DNSAddress -join ','}},

                @{N="NTPServer";E={$_ |Get-VMHostNtpServer}}, @{N="ServiceRunning";E={(Get-VmHostService -VMHost $_ | Where-Object {$_.key-eq "ntpd"}).Running}},

                @{N="Cluster";E={

                    if($esx.ExtensionData.Parent.Type -ne "ClusterComputeResource"){"Stand alone host"}

                    else{

                        Get-view -Id $esx.ExtensionData.Parent | Select -ExpandProperty Name

                    }}},

                Device,Model,Status,

                @{N="WWPN";E={((("{0:X}"-f $_.NodeWorldWideName).ToLower()) -replace "(\w{2})",'$1:').TrimEnd(':')}},

                @{N="WWN";E={((("{0:X}"-f $_.PortWorldWideName).ToLower()) -replace "(\w{2})",'$1:').TrimEnd(':')}},

              # @{N="Fnicvendor";E={$esxcli.software.vib.list() | ? {$_.Name -match ".*$($hba.hbadriver).*"} | Select -First 1 -Expand Vendor}},

                @{N="Fnicvendor";E={$esxcli.hardware.pci.list() | where {$hba -contains $_.VMKernelName} |Select -ExpandProperty VendorName }},

                @{N="fnicdriver";E={$esxcli.system.module.get("fnic").version}},

                @{N="enicdriver";E={$esxcli.system.module.get("enic").version}},

               # @{N="Enicvendor";E={$esxcli.software.vib.list() | ? {$_.Name -match ".net.*"} | Select -First 1 -Expand Vendor}}

                 @{N="Enicvendor";E={$esxcli.hardware.pci.list() | where {$nic -contains $_.VMKernelName} |Select -ExpandProperty VendorName }}

                 #@{N="Enicvendor";E={$esxcli.network.nic.list() | where {$vmnic.name -eq $_.vmnic1} | select -First 1 -ExpandProperty Description }}

      }

}

$report  | Export-Csv -Path C:\temp\HostInfo.csv -NoClobber -NoTypeInformation

Reply
0 Kudos
swamynaveen
Enthusiast
Enthusiast

LucD​ I also trived the following script. however, some details are still missing. Could you please hlep me to complete rest of the details?

Get-VMHost | Select Name,PowerState, Version,@{N="ManagementIP"; E={Get-VMHostNetworkAdapter -VMHost $_ -VMKernel | ?{$_.ManagementTrafficEnabled} | %{$_.Ip}}},LicenseKey,  @{N='LicenseName';E={$vmhostLM.AssignedLicense.Name | Select-Object -Unique}},@{N='ExpirationDate';E={$_.AssignedLicense.Properties.where{$_.Key -eq 'expirationDate'}.Value }},

    Build,

    @{N="Cluster Name";E={($_ | Get-Cluster).Name}},@{N="Datacenter";E={$datacenter.Name}},

    Manufacturer, Model, ProcessorType,@{Name="SerialNumber";Expression={$esx.ExtensionData.Hardware.SystemInfo.OtherIdentifyingInfo |Where-Object {$_.IdentifierType.Key -eq "Servicetag"} |Select-Object -ExpandProperty IdentifierValue}},

    @{N="NumCPU";E={($_| Get-View).Hardware.CpuInfo.NumCpuPackages}},

    @{N="Cores";E={($_| Get-View).Hardware.CpuInfo.NumCpuCores}},

    @{N="Service Console IP";E={($_|Get-VMHostNetwork).ConsoleNic[0].IP}},

    @{N="vMotion IP";E={($_|Get-VMHostNetwork).VirtualNic[0].IP}},

    @{N="HBA count";E={($_| Get-VMHostHba | where {$_.Type -eq "FibreChannel"}).Count}},

    @{N="DatastoreName(Capacity in GB)";E={[string]::Join(",",( $ _| Get-Datastore | %{$_.Name + "(" + ("{0:f1}" -f ($_.CapacityMB/1KB)) + ")"}))}},

    @{N="FC Device";E={[string]::Join(",",(($ _| Get-View).Config.StorageDevice.HostBusAdapter | where{$_.GetType().Name -eq "HostFibreChannelHba"} | %{$_.Device}))}},

    @{N="FC WWN";E={[string]::Join(",",(($ _| Get-View).Config.StorageDevice.HostBusAdapter | where{$_.GetType().Name -eq "HostFibreChannelHba"} | %{"{0:x}" -f $_.NodeWorldWideName}))}},

    @{N="Physical NICS count";E={($_ | Get-View).Config.Network.Pnic.Count}},

    @{N="vSwitches(Number of Ports)";E={[string]::Join(",",( $ _| Get-VirtualSwitch | %{$_.Name + "(" + $_.NumPorts + ")"}))}},

    @{N="Portgroups";E={[string]::Join(",",( $ _| Get-VirtualPortGroup | %{$_.Name}))}},

    @{N="pNIC MAC";E={[string]::Join(",",($ _| Get-VMHostNetworkAdapter | %{$_.MAC}))}},

    @{N="SC Mem (MB)";E={"{0:f1}" -f (($_| Get-View).Config.ConsoleReservation.ServiceConsoleReserved/1MB)}},

    @{N='vCenter';E={$_.Uid.Split('@')[1].Split(':')[0]}},

    @{N='DNS Server(s)';E={$_.Extensiondata.Config.Network.DnsConfig.Address -join ' , '}},

    @{N='Time';E={(Get-View -Id $_.ExtensionData.ConfigManager.DatetimeSystem).QueryDateTime()}},

    @{N="NTPServer";E={$_ |Get-VMHostNtpServer}}, @{N="ServiceRunning";E={(Get-VmHostService -VMHost $_ | Where-Object {$_.key-eq "ntpd"}).Running}},

    @{N='InstallationDate';E={

        $script:esxcli = Get-EsxCli -VMHost $_

        $epoch = $script:esxcli.system.uuid.get().Split('-')[0]

     

        [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds([int]"0x$($epoch)"))}},

    @{N='UpgradeDate';E={

        $script:esxcli.software.vib.list()  | where{$_.Name -eq 'esx-base'} | select -ExpandProperty InstallDate

    }},@{N="LockDown";E={$_.Extensiondata.Config.adminDisabled}},

   @{N="SyslogServer";E={$_ |Get-VMHostSyslogServer}},

    @{N = 'HostFQDN'; E = {$esxcli.system.hostname.get.Invoke().FullyQualifiedDomainName}},

    @{N = 'CoreDumpConfigured'; E = {if ($_.Configured) {$_.Configured} else {'None'}}},

    @{N='pNIC';E={(Get-VMHostNetworkAdapter -Physical -VMHost $_).Name -join '|'}},

    @{N = 'linkspeed';E={$spec=Get-VMHostNetworkAdapter -VMHost $_$spec.extensiondata.linkspeed.speedMb -join '|'}},

    @{N="Uptime"; E={New-Timespan -Start $_.ExtensionData.Summary.Runtime.BootTime -End (Get-Date) | Select -ExpandProperty Days}},

    @{N="Last Boot (UTC)";E={$_.ExtensionData.Summary.Runtime.BootTime}},

   @{N="Last Boot (Locale)";E={Convert-UTCtoLocal -UTCTime $_.ExtensionData.Sumary.Runtime.BootTime}},

@{N='PCLI';E={(Get-AdvancedSetting -Entity $_ -Name 'VSAN.ClomRepairDelay').Value}},

  @{N='Scratch';E={(Get-AdvancedSetting -Entity $_ -Name 'ScratchConfig.ConfiguredScratchLocation').Value}},

  @{N='Log';E={(Get-AdvancedSetting -Entity $_ -Name 'Syslog.global.logDir').Value}},

  @{N="HostUUID";E={$_.ExtensionData.hardware.systeminfo.uuid}},

  @{N="HT Available";E={($_).HyperthreadingActive}},

  @{N="HT Active";E={($_ | get-view).Config.HyperThread.Active}},

  @{N=“Speed“;E={"" + [math]::round(($_| get-view).Hardware.CpuInfo.Hz / 1000000, 0)}},

  @{N=“Memory GB“;E={“” + [math]::round(($_| get-view).Hardware.MemorySize / 1GB, 0) + “ GB“}},

  @{ N="CurrentPolicy"; E={$_.ExtensionData.config.PowerSystemInfo.CurrentPolicy.ShortName}},

  @{N="Power Policy";E={$powSys = Get-View $_.ExtensionData.ConfigManager.PowerSystem

  $powSys.Info.CurrentPolicy.ShortName }},

  @{N = 'OverallStatus'; E = {$_.ExtensionData.OverallStatus}},

@{N="DNS suffixes";E={[string]::Join(",", ($esxcli.network.ip.dns.search.list() | %{$_.DNSSearchDomains}))}},

@{N='Power';E={(Get-AdvancedSetting -Entity $_ -Name 'Power.CpuPolicy').Value}}


Get-VMHost | Select Name,PowerState, Version,@{N="ManagementIP"; E={Get-VMHostNetworkAdapter -VMHost $_ -VMKernel | ?{$_.ManagementTrafficEnabled} | %{$_.Ip}}},LicenseKey,  @{N='LicenseName';E={$vmhostLM.AssignedLicense.Name | Select-Object -Unique}},@{N='ExpirationDate';E={$_.AssignedLicense.Properties.where{$_.Key -eq 'expirationDate'}.Value }},    Build,    @{N="Cluster Name";E={($_ | Get-Cluster).Name}},@{N="Datacenter";E={$datacenter.Name}},    Manufacturer, Model, ProcessorType,@{Name="SerialNumber";Expression={$esx.ExtensionData.Hardware.SystemInfo.OtherIdentifyingInfo |Where-Object {$_.IdentifierType.Key -eq "Servicetag"} |Select-Object -ExpandProperty IdentifierValue}},    @{N="NumCPU";E={($_| Get-View).Hardware.CpuInfo.NumCpuPackages}},    @{N="Cores";E={($_| Get-View).Hardware.CpuInfo.NumCpuCores}},    @{N="Service Console IP";E={($_|Get-VMHostNetwork).ConsoleNic[0].IP}},    @{N="vMotion IP";E={($_|Get-VMHostNetwork).VirtualNic[0].IP}},    @{N="HBA count";E={($_| Get-VMHostHba | where {$_.Type -eq "FibreChannel"}).Count}},    @{N="DatastoreName(Capacity in GB)";E={[string]::Join(",",( $ _| Get-Datastore | %{$_.Name + "(" + ("{0:f1}" -f ($_.CapacityMB/1KB)) + ")"}))}},    @{N="FC Device";E={[string]::Join(",",(($ _| Get-View).Config.StorageDevice.HostBusAdapter | where{$_.GetType().Name -eq "HostFibreChannelHba"} | %{$_.Device}))}},    @{N="FC WWN";E={[string]::Join(",",(($ _| Get-View).Config.StorageDevice.HostBusAdapter | where{$_.GetType().Name -eq "HostFibreChannelHba"} | %{"{0:x}" -f $_.NodeWorldWideName}))}},    @{N="Physical NICS count";E={($_ | Get-View).Config.Network.Pnic.Count}},    @{N="vSwitches(Number of Ports)";E={[string]::Join(",",( $ _| Get-VirtualSwitch | %{$_.Name + "(" + $_.NumPorts + ")"}))}},    @{N="Portgroups";E={[string]::Join(",",( $ _| Get-VirtualPortGroup | %{$_.Name}))}},    @{N="pNIC MAC";E={[string]::Join(",",($ _| Get-VMHostNetworkAdapter | %{$_.MAC}))}},    @{N="SC Mem (MB)";E={"{0:f1}" -f (($_| Get-View).Config.ConsoleReservation.ServiceConsoleReserved/1MB)}},    @{N='vCenter';E={$_.Uid.Split('@')[1].Split(':')[0]}},    @{N='DNS Server(s)';E={$_.Extensiondata.Config.Network.DnsConfig.Address -join ' , '}},    @{N='Time';E={(Get-View -Id $_.ExtensionData.ConfigManager.DatetimeSystem).QueryDateTime()}},    @{N="NTPServer";E={$_ |Get-VMHostNtpServer}}, @{N="ServiceRunning";E={(Get-VmHostService -VMHost $_ | Where-Object {$_.key-eq "ntpd"}).Running}},    @{N='InstallationDate';E={
        $script:esxcli = Get-EsxCli -VMHost $_
        $epoch = $script:esxcli.system.uuid.get().Split('-')[0]
     
        [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds([int]"0x$($epoch)"))}},
    @{N='UpgradeDate';E={
        $script:esxcli.software.vib.list()  | where{$_.Name -eq 'esx-base'} | select -ExpandProperty InstallDate
    }},@{N="LockDown";E={$_.Extensiondata.Config.adminDisabled}},   @{N="SyslogServer";E={$_ |Get-VMHostSyslogServer}},    @{N = 'HostFQDN'; E = {$esxcli.system.hostname.get.Invoke().FullyQualifiedDomainName}},    @{N = 'CoreDumpConfigured'; E = {if ($_.Configured) {$_.Configured} else {'None'}}},    @{N='pNIC';E={(Get-VMHostNetworkAdapter -Physical -VMHost $_).Name -join '|'}},    @{N = 'linkspeed';E={$spec=Get-VMHostNetworkAdapter -VMHost $_$spec.extensiondata.linkspeed.speedMb -join '|'}},    @{N="Uptime"; E={New-Timespan -Start $_.ExtensionData.Summary.Runtime.BootTime -End (Get-Date) | Select -ExpandProperty Days}},    @{N="Last Boot (UTC)";E={$_.ExtensionData.Summary.Runtime.BootTime}},
  @{N="Last Boot (Locale)";E={Convert-UTCtoLocal -UTCTime $_.ExtensionData.Sumary.Runtime.BootTime}},
  @{N="Uptime (Locale)";E={getTimeSpanFormatted((Get-Date) - (Convert-UTCtoLocal -UTCTime $_ExtensionData.Summary.Runtime.BootTime))}},  @{N='PCLI';E={(Get-AdvancedSetting -Entity $_ -Name 'VSAN.ClomRepairDelay').Value}},  @{N='Scratch';E={(Get-AdvancedSetting -Entity $_ -Name 'ScratchConfig.ConfiguredScratchLocation').Value}},  @{N='Log';E={(Get-AdvancedSetting -Entity $_ -Name 'Syslog.global.logDir').Value}},  @{N="HostUUID";E={$_.ExtensionData.hardware.systeminfo.uuid}},  @{N="HT Available";E={($_).HyperthreadingActive}},  @{N="HT Active";E={($_ | get-view).Config.HyperThread.Active}},  @{N=“Speed“;E={"" + [math]::round(($_| get-view).Hardware.CpuInfo.Hz / 1000000, 0)}},  @{N=“Memory GB“;E={“” + [math]::round(($_| get-view).Hardware.MemorySize / 1GB, 0) + “ GB“}},  @{ N="CurrentPolicy"; E={$_.ExtensionData.config.PowerSystemInfo.CurrentPolicy.ShortName}},  @{N="Power Policy";E={$powSys = Get-View $_.ExtensionData.ConfigManager.PowerSystem   $powSys.Info.CurrentPolicy.ShortName }},  @{N = 'OverallStatus'; E = {$_.ExtensionData.OverallStatus}}, @{N="DNS suffixes";E={[string]::Join(",", ($esxcli.network.ip.dns.search.list() | %{$_.DNSSearchDomains}))}}, @{N='Power';E={(Get-AdvancedSetting -Entity $_ -Name 'Power.CpuPolicy').Value}}
             

Reply
0 Kudos
swamynaveen
Enthusiast
Enthusiast

LucD​ Here are missing details which need to be appended to the script.

1.license status like Enterpise,Enterprise Pluse & expire date

2.Default gateway

3.SSH service status like enabled or not.

4.Power management to higher performance

5.vmkernel portgroups & active services enabled on them like MGMT,vMotion,FT... etc

6.vSwitch details &uplink teaming status.

7.DV swtich details & Uplinke teaming status

8.default multipathing policy of storage

9.CDP details & observed VLAN list

10.Firmware & driver version details of all the hardware components like SASRAID,storage,VMNIC.. etc

Reply
0 Kudos