9 Replies Latest reply on Jul 2, 2020 4:10 AM by LucD

    Script Output issue

    SCharchouf Enthusiast

      Could you please assist me on this error, not sure what happend

       

            Welcome to VMware vSphere PowerCLI!

       

      Log in to a vCenter Server or ESX host:          Connect-VIServer
      To find out what commands are available, type:   Get-VICommand

      To show searchable help for all PowerCLI commands:   Get-PowerCLIHelp

      Once you've connected, display all virtual machines: Get-VM

      If you need more help, visit the PowerCLI community: Get-PowerCLICommunity

       

         Copyright (C) VMware, Inc. All rights reserved.

       

       

      PowerCLI C:\> .\PowerShell_Script

      PowerCLI C:\.\VIB_Firmware_Drivers_Details.ps1

       

      Name                       Port  User
      ----                       ----  ----
      XXXXXX.YYY.ZZZ    443  
      XXXXXX.YYY.ZZZ    443  
      XXXXXX.YYY.ZZZ   443  
      prvcafac1.YYY.ZZZ   443  

      WARNING: There were one or more problems with the Update Manager Server certificate:

       

      * A certification chain processed correctly, but terminated in a root certificate which isn't trusted by the trust provider.

       

      * The certificate's CN name does not match the passed value.

       

      Get-EsxCli : 29/06/2020 17:06:33    Get-EsxCli          Message: Une erreur s'est produite lors de la communication avec l'hôte distant.;

      InnerText:

      At C:.\VIB_Firmware_Drivers_Details.ps1:33 char:19

      +     $esxcli = Get-EsxCli -VMHost $esx -V2
      +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo      : NotSpecified: (:) [Get-EsxCli], HostCommunication
      + FullyQualifiedErrorId : Client20_DynamicTypeManagerServiceImpl_GetMoInstances_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.EsxCli.GetEsxCli

       

      You cannot call a method on a null-valued expression.

      At C:.\VIB_Firmware_Drivers_Details.ps1:35 char:9

      +     $reportVIB += $esxcli.software.vib.list.Invoke() |
      +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo      : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : InvokeMethodOnNull

       

      You cannot call a method on a null-valued expression.

      At C:.\VIB_Firmware_Drivers_Details.ps1:99 char:9

      +     $reportNic += $esxcli.network.nic.list.Invoke() |
      +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo      : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : InvokeMethodOnNull

       

      Get-EsxCli : 29/06/2020 17:14:23    Get-EsxCli          Message: Une erreur s'est produite lors de la communication avec l'hôte distant.;

      InnerText:

      At C:.\VIB_Firmware_Drivers_Details.ps1:33 char:19

      +     $esxcli = Get-EsxCli -VMHost $esx -V2
      +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo      : NotSpecified: (:) [Get-EsxCli], HostCommunication
      + FullyQualifiedErrorId : Client20_DynamicTypeManagerServiceImpl_GetMoInstances_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.EsxCli.GetEsxCli

       

      You cannot call a method on a null-valued expression.

      At C:.\VIB_Firmware_Drivers_Details.ps1:35 char:9

      +     $reportVIB += $esxcli.software.vib.list.Invoke() |
      +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo      : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : InvokeMethodOnNull

       

      You cannot call a method on a null-valued expression.

      At C:.\VIB_Firmware_Drivers_Details.ps1:99 char:9

      +     $reportNic += $esxcli.network.nic.list.Invoke() |
      +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo      : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : InvokeMethodOnNull

       

      WARNING: There were one or more problems with the Update Manager Server certificate:

       

      * A certification chain processed correctly, but terminated in a root certificate which isn't trusted by the trust provider.

       

      * The certificate's CN name does not match the passed value.

       

      Get-EsxCli : 29/06/2020 17:16:12    Get-EsxCli          Message: Une erreur s'est produite lors de la communication avec l'hôte distant.;

      InnerText:

      At C:.\VIB_Firmware_Drivers_Details.ps1:33 char:19

      +     $esxcli = Get-EsxCli -VMHost $esx -V2
      +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo      : NotSpecified: (:) [Get-EsxCli], HostCommunication
      + FullyQualifiedErrorId : Client20_DynamicTypeManagerServiceImpl_GetMoInstances_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.EsxCli.GetEsxCli

       

      You cannot call a method on a null-valued expression.

      At C:.\VIB_Firmware_Drivers_Details.ps1:35 char:9

      +     $reportVIB += $esxcli.software.vib.list.Invoke() |
      +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo      : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : InvokeMethodOnNull

       

      You cannot call a method on a null-valued expression.

      At C:.\VIB_Firmware_Drivers_Details.ps1:99 char:9

      +     $reportNic += $esxcli.network.nic.list.Invoke() |
      +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo      : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : InvokeMethodOnNull

       

      WARNING: There were one or more problems with the Update Manager Server certificate:

       

      * A certification chain processed correctly, but terminated in a root certificate which isn't trusted by the trust provider.

       

      * The certificate's CN name does not match the passed value.

       

      WARNING: There were one or more problems with the Update Manager Server certificate:

       

      * A certification chain processed correctly, but terminated in a root certificate which isn't trusted by the trust provider.

       

      * The certificate's CN name does not match the passed value.

       

       

       

      PowerCLI C:.>

        • 1. Re: Script Output issue
          LucD Guru
          User ModeratorsvExpertCommunity Warriors

          Looks like the communication with one of your ESXi nodes through Get-EsxCli is producing an error.
          Are all of your ESXi nodes in the 'connected' state?

          Is it failing for all your ESXi nodes?

          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          • 2. Re: Script Output issue
            SCharchouf Enthusiast

            Yep it's failing for all ESXi Nodes

            I have a lot of ESXi Nodes and they are all ON

            not sure what happend, as the script was working before

            • 3. Re: Script Output issue
              LucD Guru
              User ModeratorsvExpertCommunity Warriors

              Can you attach the complete script?

              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
              • 4. Re:Script Output issue
                Grzesiekk Expert
                Can you check / set  (Get-PowerCLIConfiguration).InvalidCertificateAction Set-PowerCLIConfiguration -InvalidCertificateAction ignore ? Maybe your certificates have some issues ? Or maybe you were running this from old VM where you have different config/cert accepted etc.
                • 5. Re: Script Output issue
                  SCharchouf Enthusiast

                  # vCenter Login

                     

                      $vCUser="User"

                      $vCPass="password"

                   

                  # LIST OF vCenter

                     

                      $vCenterIP = "vcenter1","vcenter22","vcenter3","vcenter4"

                   

                  # Connection to vCenter

                      foreach ($IPAddress in $vCenterIP){

                          Connect-VIServer $IPAddress -User $vCUser -Password $vCPass -port 443

                  }

                   

                  #Requires -Modules ImportExcel

                   

                  $fileName = 'C:\.\ALL_vCenter_Firmware_Report.xlsx'

                   

                  $reportVIB = @()

                   

                  $reportPatch = @()

                   

                  $reportNic = @()

                   

                  $global:DefaultVIServers |

                   

                  ForEach-Object -Process {

                   

                      Get-VMHost -Server $_ -PipelineVariable esx |

                   

                      ForEach-Object -Process {

                   

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

                   

                          $reportVIB += $esxcli.software.vib.list.Invoke() |

                   

                          Select @{N='vCenter';E={([uri]$esx.ExtensionData.Client.ServiceUrl).Host}},

                   

                              @{N='vCenter Version';E={$esx.ExtensionData.Client.ServiceContent.About.Version}},

                   

                              @{N='vCenter Build';E={$esx.ExtensionData.Client.ServiceContent.About.Build}},

                   

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

                   

                              @{N='VMHost Version';E={$esx.Version}},

                   

                              @{N='VMHost Build';E={$esx.Build}},

                   

                              Name,ID,CreationDate,InstallDate,Version,Vendor,AcceptanceLevel

                   

                          Get-Compliance -Entity $esx -Detailed -PipelineVariable baseline |

                   

                          where{$_ -is [VMware.VumAutomation.Types.PatchBaselineCompliance]} |

                   

                      ForEach-Object -Process {

                   

                              $reportPatch += $baseline.CompliantPatches |

                   

                              Select @{N='vCenter';E={([uri]$esx.ExtensionData.Client.ServiceUrl).Host}},

                   

                              @{N='vCenter Version';E={$esx.ExtensionData.Client.ServiceContent.About.Version}},

                   

                              @{N='vCenter Build';E={$esx.ExtensionData.Client.ServiceContent.About.Build}},

                   

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

                   

                              @{N='VMHost Version';E={$esx.Version}},

                   

                              @{N='VMHost Build';E={$esx.Build}},

                   

                              @{N='Baseline';E={$baseline.Baseline.Name}},

                   

                              @{N='Compliant';E={$true}},

                   

                              Name,Vendor,IdByVendor,ReleaseDate,LastUpdateTime,Severity,@{N='Product';E={$_.Product.Name}}

                   

                              $reportPatch += $baseline.NotCompliantPatches |

                   

                              Select @{N='vCenter';E={([uri]$esx.ExtensionData.Client.ServiceUrl).Host}},

                   

                              @{N='vCenter Version';E={$esx.ExtensionData.Client.ServiceContent.About.Version}},

                   

                              @{N='vCenter Build';E={$esx.ExtensionData.Client.ServiceContent.About.Build}},

                   

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

                   

                              @{N='VMHost Version';E={$esx.Version}},

                   

                              @{N='VMHost Build';E={$esx.Build}},

                   

                              @{N='Baseline';E={$baseline.Baseline.Name}},

                   

                              @{N='Compliant';E={$false}},

                   

                              Name,Vendor,IdByVendor,ReleaseDate,LastUpdateTime,Severity,@{N='Product';E={$_.Product.Name}}

                   

                          }

                   

                          $reportNic += $esxcli.network.nic.list.Invoke() |

                   

                              ForEach-Object -Process {

                   

                                  $pMAC = $_.MACAddress

                   

                                  $esxcli.network.nic.get.Invoke(@{nicname=$_.Name}) |

                   

                                  Select-Object @{N = 'vCenter'; E = { ([uri]$esx.ExtensionData.Client.ServiceUrl).Host } },

                   

                                      @{N = 'vCenter Product'; E = { $esx.ExtensionData.Client.ServiceContent.About.Name } },

                   

                                      @{N = 'vCenter Version'; E = { $esx.ExtensionData.Client.ServiceContent.About.Version } },

                   

                                      @{N = 'vCenter Build'; E = { $esx.ExtensionData.Client.ServiceContent.About.Build } },

                   

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

                   

                                      @{N = 'VMHost Product'; E = { $esx.ExtensionData.Config.Product.Name } },

                   

                                      @{N = 'VMHost Version'; E = { $esx.Version } },

                   

                                      @{N = 'VMHost Build'; E = { $esx.Build } },                   

                                     

                                      @{N='NIC';E={$_.Name}},

                   

                                      @{N='pMAC';E={$pMAC}},        

                   

                                      @{N='vMAC';E={$_.VirtualAddress}},        

                   

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

                   

                                      @{N='Driver';E={$_.DriverInfo.Driver}},        

                   

                                      @{N='Version';E={$_.DriverInfo.Version}},

                   

                                      @{N='FirmwareVersion';E={$_.DriverInfo.FirmwareVersion}},

                                     

                                      @{N="Type";E={$esx.ExtensionData.Hardware.SystemInfo.Vendor+""+$esx.ExtensionData.Hardware.SystemInfo.Model}},

                                                         

                                      @{N="BIOS version";E={$esx.ExtensionData.Hardware.BiosInfo.BiosVersion}},

                                     

                                      @{N="BIOS date";E={$esx.ExtensionData.Hardware.BiosInfo.releaseDate}},

                                     

                                      @{N = "CPU"; E = { $esx.ExtensionData.Hardware.CpuPkg[0].Description } }

                          }

                   

                      }

                   

                  }

                   

                  $reportVIB | Export-Excel -Path $fileName -WorksheetName 'VIB'

                   

                  $reportPatch | Export-Excel -Path $fileName -WorksheetName 'Patch'

                   

                  $reportNic | Export-Excel -Path $fileName -WorksheetName 'NIC'

                  • 6. Re:Script Output issue
                    SCharchouf Enthusiast

                    Thanks I will check this also

                    I'm working on a huge env where everything is not set correctly

                    • 7. Re: Script Output issue
                      LucD Guru
                      vExpertUser ModeratorsCommunity Warriors

                      Can you check if the following gives errors?

                       

                      # vCenter Login

                      $vCUser="User"

                      $vCPass="password"


                      # LIST OF vCenter

                      $vCenterIP = "vcenter1","vcenter22","vcenter3","vcenter4"


                      # Connection to vCenter

                      foreach ($IPAddress in $vCenterIP){

                          Connect-VIServer $IPAddress -User $vCUser -Password $vCPass -port 443

                      }


                      $global:DefaultVIServers |

                      ForEach-Object -Process {

                          Get-VMHost -Server $_ -PipelineVariable esx |

                          ForEach-Object -Process {

                              $esx.Name

                              try{

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

                              }

                              catch{

                                  Write-error "Error on node $($esx.Name)"

                                  $error[0]

                              }

                          }

                      }

                      Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                      1 person found this helpful
                      • 8. Re: Script Output issue
                        SCharchouf Enthusiast

                        the scriptis working fine without any errors

                        • 9. Re: Script Output issue
                          LucD Guru
                          Community WarriorsvExpertUser Moderators

                          Does that mean your original script now also works without errors?

                          Besides leaving out the esxcli commands and using a try-catch construct, my script is basically the same as your original script.

                          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz