VMware Cloud Community
Mallik7
Enthusiast
Enthusiast
Jump to solution

need a help

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 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

7 Replies
LucD
Leadership
Leadership
Jump to solution

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: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Mallik7
Enthusiast
Enthusiast
Jump to solution

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....

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Mallik7
Enthusiast
Enthusiast
Jump to solution

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Mallik7
Enthusiast
Enthusiast
Jump to solution

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.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference