Hello Team,
Im trying to create a script PowerCLI that collect logs from specific ESXI servers into the same VCenter using this script but unfortunately it doesn't work and i dont know why !! Any suggestion please ?
$csvFilePath = "C:\esxi_info.csv"
$destinationFolder = "C:\Logs"
$esxiInfo = Import-Csv -Path $csvFilePath
foreach ($esxi in $esxiInfo) {
$esxiIP = $esxi.IP
$esxiUser = $esxi.User
$esxiPassword = $esxi.Password
# Connect to the ESXi server
Connect-VIServer -Server $esxiIP -User $esxiUser -Password $esxiPassword
# Generate the log bundle filename
$bundleFileName = "LogBundle_$($esxiIP.Replace('.', '_')).zip"
$bundleFilePath = Join-Path -Path $destinationFolder -ChildPath $bundleFileName
# Collect the log bundle
$task = Get-VMHost -Name $esxiIP | Get-Log -Bundle -DestinationPath $bundleFilePath -RunAsync
Write-Host "Collecting log bundle for ESXi host ($esxiIP)..."
# Wait for the log bundle collection task to complete
$task | Wait-Task
Write-Host "Log bundle collected for ESXi host ($esxiIP) and saved as $bundleFileName"
# Disconnect from the ESXi server
Disconnect-VIServer -Server $esxiIP -Confirm:$false
}
Thanks
Do you get errors?
Is the file created, or is it empty?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hey Luck,
No there was no file created and no errors.
what do you think about the script does it seems correct to you ?
Thanks
The DestinationPath parameter on the Get-Log cmdlet wants a path, not a file.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LuckD,
The "destinationPath" parameter already receive a path. Correct me if i'm wrong :
-DestinationPath $bundleFilePath
$destinationFolder = "C:\Logs" ==> indicate the path where the logs will be saved
$bundleFilePath = Join-Path -Path $destinationFolder -ChildPath $bundleFileName
Thanks in advance
You attach the ZIP filename to that path (-DestinationPath $bundleFilePath).
That is a file, not a folder
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
So the paramètres should be like this ?
$task = Get-VMHost -Name $esxiIP | Get-Log -Bundle -DestinationPath "C:\Logs" -RunAsync
Thanks
Yes, and I would first run a test with 1 ESXi node without the RunAsync parameter.
Collecting a log bundle might take some time and you might hit the WebOperationsTimeout (default 300 seconds).
Increase the value with the Set-PowerCLIConfiguration cmdlet if needed.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
