7 Replies Latest reply on Nov 25, 2019 10:10 AM by LucD

    need a help

    Mallik7 Enthusiast

      I'm in need a powercli script to generate ESXi host log bundles per cluster wise (each cluster will have about 10-15 hosts), can some help here.

       

      TIA

        • 1. Re: need a help
          LucD Guru
          Community WarriorsvExpertUser Moderators

          Something like this?

           

          Get-Cluster |

          ForEach-Object -Process {

              $esx = Get-VMHost -Location $_

              $dir = New-Item -Path ".\$($_.Name)" -ItemType Directory

              Get-Log -VMHost $esx -Bundle -DestinationPath $dir

          }

          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          1 person found this helpful
          • 2. Re: need a help
            Mallik7 Enthusiast

            can I input the list of ESXi hosts into a text file and grab it from there and create a log bundle of each esxi host....

            • 3. Re: need a help
              LucD Guru
              vExpertUser ModeratorsCommunity Warriors

              You can, but can the log bundles go in one folder then?
              Like this?

               

              $dir = New-Item -Path ".\Log-Bundles" -ItemType Directory

              Get-Content -Path .\esxnames.txt |

              ForEach-Object -Process {

                  Get-VMHost -Name $_ | Get-Log -Bundle -DestinationPath $dir

              }

              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
              • 4. Re: need a help
                Mallik7 Enthusiast

                if I add 3 hosts to the esxnames.txt file, it is creating the bundles only for first 2 hosts.

                if I add 2 hosts to the esxnames.txt file, it is creating the bundle for single host (which is the first one) - can you please fix this....

                 

                if I give a cluster name (hard coded entry also is fine, I'll keep changing the cluster name when ever required) and create the log bundles for each host in that respective cluster. if you can help to add this step and with the same cluster name the folder get created.

                 

                though the execution complete, the script is not coming out automatically. I need to hit enter or need to press Ctrl + C. (can you please fix this too)

                 

                TIA

                • 5. Re: need a help
                  LucD Guru
                  User ModeratorsCommunity WarriorsvExpert

                  How does you .txt file look like?
                  For me it works without a problem, and includes all ESXi nodes I specified in the .txt file.

                   

                  What is with the clustername?
                  You never said you wanted to be able to specify a clustername.

                   

                  Please list the requirements complete and correctly, otherwise, this thread will again go on for a very long time.

                  Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                  • 6. Re: need a help
                    Mallik7 Enthusiast

                    very sorry Luc. space has added to the host name when I copy and pasted into the text file. it is good now.

                    initially I thought to go with host names. sorry for that.

                    • 7. Re: need a help
                      LucD Guru
                      vExpertCommunity WarriorsUser Moderators

                      So do you need to be able to specify a clustername?
                      Just add the -Name clustername on the Get-Cluster cmdlet in the 1st script.

                      Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                      1 person found this helpful