1 Reply Latest reply on Jul 1, 2020 1:56 PM by LucD

    Powercli scripts

    rmahmoud Novice

      DEar Colleague

       

      I want to understand this script and test it on powercli. Please help

       

       

       

       

      # List the Software AcceptanceLevel for each host Foreach ($VMHost in Get-VMHost ) { $ESXCli = Get-EsxCli -VMHost $VMHost $VMHost | Select Name, @{N="AcceptanceLevel";E={$ESXCli.software.acceptance.get()}} } # List only the vibs which are not at "VMwareCertified" or "VMwareAccepted" or "PartnerSupported" acceptance level Foreach ($VMHost in Get-VMHost ) { $ESXCli = Get-EsxCli -VMHost $VMHost $ESXCli.software.vib.list() | Where { ($_.AcceptanceLevel -ne "VMwareCertified") -and ($_.AcceptanceLevel -ne "VMwareAccepted") -and ($_.AcceptanceLevel -ne "PartnerSupported") } }

        • 1. Re: Powercli scripts
          LucD Guru
          vExpertUser ModeratorsCommunity Warriors

          The script isn't that complicated.

           

          Before running the script, make sure you are connected (Connect-VIServer) to a vSphere server.

           

          Both snippets of code are based on the Get-EsxCli cmdlet.

          This cmdlet returns an object on which you can run all available esxcli commands.

          The ForEach loop in both snippets run through all the ESXi nodes in the environment.

           

          Once you have the object returned by Get-EsxCli, you can make all the esxcli calls.

          For details on esxcli see Chapter 1 in Getting Started with vSphere Command-Line Interfaces

           

          Both snippets investigate the Acceptance Levels of ESXi nodes and VIBs.

          See Manage the Acceptance Levels of Hosts and VIBs

           

          The 2nd snippet uses a Where-clause to limit the VIBs to only specific Acceptance levels (see comment)

           

          # List the Software AcceptanceLevel for each host

          Foreach ($VMHost in Get-VMHost ) {

              $ESXCli = Get-EsxCli -VMHost $VMHost

              $VMHost | Select Name, @{N="AcceptanceLevel";E={$ESXCli.software.acceptance.get()}}

          }


          # List only the vibs which are not at "VMwareCertified" or "VMwareAccepted" or "PartnerSupported" acceptance level

          Foreach ($VMHost in Get-VMHost ) {

              $ESXCli = Get-EsxCli -VMHost

              $VMHost $ESXCli.software.vib.list() |

              Where { ($_.AcceptanceLevel -ne "VMwareCertified") -and ($_.AcceptanceLevel -ne "VMwareAccepted") -and ($_.AcceptanceLevel -ne "PartnerSupported") }

          }

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