- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
PowerCli Script to collect logs from Multiples ESXI into the same Vcenter
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