1 2 Previous Next 29 Replies Latest reply on Jun 26, 2015 2:26 AM by MKguy Go to original post
      • 15. Re: Script to get serial number of all hosts
        Fjorko Novice

        Robert ? or LuCD ?

        • 16. Re: Script to get serial number of all hosts
          RvdNieuwendijk Virtuoso
          vExpertUser Moderators

          Are you using Windows 7 SP1 like Luc suggests? I am using Windows 7 SP1 and have never seen the "Access Denied" error myself.

          • 17. Re: Script to get serial number of all hosts
            Fjorko Novice

            Yes I am running Windows 7 Sp1.

            • 18. Re: Script to get serial number of all hosts
              Fjorko Novice

              Just double check my steps here please.

               

              1. Log onto my Win7 SP1 pc

              2. Launch POWERCLI

              3. Do a Connect-VIServer <My VC> -Credential ( get-credential) <-------i do this because my pc is in a workgroup and not on the same domain as the VC.

              4. Launch your script.. I have also added the alternate credential lines that you mention in the POST Robert so when the script starts it prompts me for credentials -> This is the Root user and pass for the HOST right ?

               

              Once the script kicks off it runs for about 10 seconds or so, and then comes back with the error below for each host that it tries to connect to :

               

               

              Get-WSManInstance : Access is denied.
              At C:\HostSerials.ps1:44 char:26
              +         Get-WSManInstance <<<<  -Authentication basic -ConnectionURI $uri -Credential $credential -Enumerate -Port 443 -UseSSL -SessionOption $option -ResourceURI "$baseUrl/$class"
                  + CategoryInfo          : InvalidOperation: (:) [Get-WSManInstance], UnauthorizedAccessException
                  + FullyQualifiedErrorId : Exception,Microsoft.WSMan.Management.GetWSManInstanceCommand

               

               

              Does this shed any more light ?

               

              Thanks

              • 19. Re: Script to get serial number of all hosts
                RvdNieuwendijk Virtuoso
                User ModeratorsvExpert

                You seem to have the same client configuration as I have. I'm running PowerShell v2 and PowerCLI v5.0.1 on a Windows 7 Ultimate SP1 64-bit PC that is in a workgroup.

                 

                So I think the problem is host related. That can be the host version, or it can be a server setting.

                 

                We are running ESXi 4.1U2 on all our ESXi servers. They all have the following patches installed:

                PowerCLI C:\users\robert> Get-VMHost $VMHost | Get-VMHostPatch | Select-Object -Property Id,Description | Format-Table -AutoSize

                Id                          Description
                --                          -----------
                ESXi410-Update01            VMware ESXi 4.1 Complete Update 1
                841.k1.16.2-1vmw            qla2xxx: scsi driver for VMware ESX
                hp-nmi-driver-1.2.02        HP NMI Sourcing Driver for VMware ESX/ESXi 4.1
                EMU-be2net-2.104.277.3      Emulex OneConnect NIC Driver
                ESXi410-Update02            VMware ESXi 4.1 Complete Update 2
                hpq-esxi4.1uX-bundle-1.2-25 HP ESXi 4.1 Bundle 1.2-25
                ESXi410-201201402-BG        Updates VMware Tools
                ESXi410-201201401-SG        Updates Firmware


                I have tried if enabling or disabling "Lockdown Mode" on the host would make a difference. But it doesn't.

                 

                At the moment I ran out of ideas how to solve the "Access denied" problem.

                • 21. Re: Script to get serial number of all hosts
                  Fjorko Novice

                  Hi Guys

                   

                  I have to hang my head in shame - I said I was running the script from Windows 7 Sp1. I didn't even bother to check that because I was so sure I was running it on my work notebook - alas I was NOT !

                   

                  I ran the script from home on my SP1 pc and the script worked flawlessly...didn't even have to enter any alternate credentials !

                   

                  Thanks so much ! ... and HUGE apologies !!

                  • 22. Re: Script to get serial number of all hosts
                    bse1969 Novice

                    After spending a few hours playing around with the different CIM components, I started looking at OMC.  I was able to find the serial number for all my host by pulling OMC_UnitaryComputerSystem.  Look at OtherIdentifyingInfo, see anything familiar .  Also I needed BIOS version as well, so I looked under OMC_SMASHFirmwareIdentity.  Look at VersionString.   I was able to locate the data I needed on all my systems that are running ESX 4.1 update 1.  We don't have ESXi so I am not able to verify if it is still valid or not and also we haven't rolled out 5 yet.

                    • 23. Re: Script to get serial number of all hosts
                      bhoriuchi Novice

                      Great find!

                       

                      I was able to verify that you can get the correct serial number for the following on ESXi 4.1 and 5 using the Get-VMHostWSManInstance function with OMC_UnitaryComputerSystem and the otheridentifyinginfo field.

                       

                      HP Blade - BL680c

                      HP DL980

                      IBM Blade - HX5

                      • 24. Re: Script to get serial number of all hosts
                        vkev Novice

                        Why not try this script after connect-viserver ?

                         

                        $esxlist = get-vmhost

                        foreach($Esx in $esxlist){

                        $esxcli=Get-EsxCli -VMHost $Esx

                        write-host $Esx.Name $esxcli.hardware.platform.get().SerialNumber

                        }

                         

                        Regards

                        Kevin Smith

                        • 25. Re: Script to get serial number of all hosts
                          esxi1979 Hot Shot

                          this will not work with 4x esx servers tho

                          • 26. Re: Script to get serial number of all hosts
                            RvdNieuwendijk Virtuoso
                            vExpertUser Moderators

                            You are correct. The esxcli hardware commands are introduced in vSphere 5.0 and will not work in vSphere 4.x.

                            • 27. Re: Script to get serial number of all hosts
                              vKev201110141 Novice

                              Hi,

                              I did get the CIM script script working ok, but it returned the chassis and blade serial without any real way of identifying which was which..., I'd hoped the PowerCLI method was better in terms of premissions but both require admin.

                               

                              Regards

                              Kevin Smith

                              • 28. Re: Script to get serial number of all hosts
                                MRENSEL Lurker

                                I'm sorry, can someone help me put this together, I'm not super spiffy with powercli:


                                "I was able to verify that you can get the correct serial number for the following on ESXi 4.1 and 5 using the Get-VMHostWSManInstance function with OMC_UnitaryComputerSystem and the otheridentifyinginfo field."


                                Something like maybe?:

                                $PhysicalPackage = Get-VMHostWSManInstance -VMHost $_ -class MC_UnitaryComputerSystem -ignoreCertFailures | Where-Object {$_.ElementName -eq "otheridentifyinginfo"}


                                Doesn't seem to work though...

                                • 29. Re: Script to get serial number of all hosts
                                  MKguy Virtuoso

                                  Try Get-EsxCli:

                                  > $esxcli = Get-EsxCli -VMHost MyESXiHostName

                                  ($esxcli.hardware.platform.get()).SerialNumber

                                  AABB112233

                                   

                                  Another option is to import this function to query the CIM interface of the host directly (the CIM Class is CIM_PhysicalPackage):

                                  https://github.com/alpacacode/Homebrewn-Scripts/blob/master/vmware-scripts/Get-CIMProperties.ps1

                                  > (Get-CIMProperties -Target MyESXiHostName -Username root -Password secret -CIMClassName CIM_PhysicalPackage | Where {$_.NAME -eq 'SerialNumber'}).Value

                                  AABB112233

                                  1 2 Previous Next