The following script may be useful if you are in the process of migrating vRealize Log Insight to a new appliance/cluster. You can use this script before, during and after migrating to check the settings of Syslog.Global.Loghost of all ESXi hosts in vCenter.
# Version 1.0
# 2024-11-17
# Check ESXi Syslog Global LogHost script with HTML output
# This script checks if specified Syslog Global LogHost are configured on all hosts in a datacenter and writes the output to an HTML file
# Connect to vCenter Server
$vCenter = "FQDN vCenter"
Connect-VIServer $vCenter
# Get all ESXi hosts in the cluster
$hosts = get-vmhost
# Initialize HTML content with styles for alternating row colors
$htmlContent = @"
<html>
<head>
<title>ESXi Syslog Settings</title>
<style>
table {
width: 100%;
border-collapse: collapse;
}
th, td {
padding: 8px;
text-align: left;
border: 1px solid #ddd;
}
tr:nth-child(odd) {
background-color: white;
}
tr:nth-child(even) {
background-color: lightgrey;
}
</style>
</head>
<body>
<h1>ESXi Syslog Settings</h1>
<table>
<tr>
<th>ESXi Host</th>
<th>Syslog Global Loghost</th>
</tr>
"@
# Loop through each ESXi host and get the syslog.global.loghost advanced setting
foreach ($esxi in $hosts) {
$setting = Get-AdvancedSetting -Entity $esxi -Name 'syslog.global.loghost'
$htmlContent += "<tr><td>$($esxi.Name)</td><td>$($setting.Value)</td></tr>"
}
# Add the current date and time
$currentDateTime = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$htmlContent += @"
</table>
<p>Report generated on: $currentDateTime</p>
</body>
</html>
"@
# Save HTML content to a file
$outputPath = "C:\Scripts\esxi_syslog_settings.html"
$htmlContent | Out-File -FilePath $outputPath
# Open the HTML file
Start-Process "msedge.exe" $outputPath
# Disconnect from vCenter Server
Disconnect-VIServer -Confirm:$false
For example: You can use the script during vRealize Log Insight in the following way:
Before migration Check the current configured syslog endpoint
During migration Check the current and new syslog endpoints are configured
Aftermigration Check the new configured syslog endpoint
In my last blog, I shared a Powershell script that can be used to remove VIBs from all ESXi hosts in a cluster. I have created a small Powershell script that you can run before and after removing of VIBs to check the availability of VIBs.
The output is displayed in an HTML file once the script is finished. The VIBs being checked are deļ¬ned in $arrayvibs. The location of the HTML file can be defined in $outputPath. The number of VIBs you can have checked depends on how many you define in $arrayvibs.
Here are a few examples of the HTML output files.
Example output before run VIB Check Report script to remove the VIBs “nenic” and “iavmd”.
Example output after run VIB Check Report script to remove the VIBs “nenic” and “iavmd”.
Please be aware that using this script is at your own risk!
# Version 1.0
# 2024-11-14
# Check VIBs script with HTML output
# This script checks if specified VIBs are installed on all hosts in a cluster and writes the output to an HTML file
# Function Check VIB
function CheckVIB {
Param (
$ESXi # The EsxCli object
)
[array]$arrayvibs = @("nenic", "iavmd")
$esxcli = Get-EsxCli -V2 -VMHost $ESXi
$result = ""
foreach ($vib in $arrayvibs) {
if ($esxcli.software.vib.list.Invoke() | Where-Object {$_.Name -eq "$vib"}) {
$result += "<tr style='background-color: #ffe6e6;'><td>$($ESXi.Name)</td><td>$vib</td><td>Found</td></tr>"
} else {
$result += "<tr style='background-color: #e6ffe6;'><td>$($ESXi.Name)</td><td>$vib</td><td>Not Found</td></tr>"
}
}
return $result
}
# vCenter & Cluster Parameters
$vCenter = "FQDN vCenter"
$cluster = "Cluster"
# Connect vCenter
Try {Disconnect-VIServer * -Confirm:$false -ErrorAction SilentlyContinue | Out-Null}
Catch {}
Connect-VIServer $vCenter
$ESXis = Get-Cluster -Name $cluster | Get-VMHost | Sort-Object Name | Where-Object {$_.ConnectionState -eq 'Connected' -or $_.ConnectionState -eq 'Maintenance'}
# HTML header
$html = @"
<html>
<head>
<title>VIB Check Report</title>
<style>
table { width: 100%; border-collapse: collapse; }
th, td { border: 1px solid black; padding: 8px; text-align: left; }
th { background-color: #f2f2f2; }
</style>
</head>
<body>
<h1>VIB Check Report</h1>
<table>
<tr>
<th>Host</th>
<th>VIB</th>
<th>Status</th>
</tr>
"@
foreach ($ESXi in $ESXis) {
$html += CheckVIB -ESXi $ESXi
}
# HTML footer with creation date and time
$creationDate = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$html += @"
</table>
<p>Report generated on: $creationDate</p>
</body>
</html>
"@
# Output HTML to file
$outputPath = "C:\Scripts\VIB_Check_Report.html"
$html | Out-File -FilePath $outputPath
# Open the HTML file in Microsoft Edge
Start-Process "msedge.exe" $outputPath
# Disconnect vCenter
Write-Host "Disconnecting vCenter $vCenter"
Disconnect-VIServer -Confirm:$False | Out-Null
Write-Host "Report generated at $outputPath"
Recently, I wanted to upgrade a vSphere 7 non vSAN cluster to version 8 with a single image. During the compliance check it turned out that all hosts in the cluster were not compliant and therefore the upgrade could not be started. The following error was displayed.
There appeared to be two VIBs installed that were not supported. On the host’s commandline, I looked up the names of VIBs and noted them. The VIBs involved in this case were the following:
nenic
iavmd
These will be needed later in the Powershell script.
Since I don’t want to log into every server and then have to delete the VIBs via the CLI, I created the following script. I would like to thank my colleague Kabir very much for his time, explanation and mentoring. He has great scripting and automation skills and has written great articles that you can find here, whatkabirwrites.nl
Back to the script. The script removes the two VIBs on all hosts in a cluster. Before using the script be sure that the VIBs are not used. The following steps are performed by the script:
Host is put into maintenance mode
Check if VIBs are installed
If present, they are removed
Host is rebooted
Host goes out of maintenance mode
Next host
If a host is already in maintenance mode, it will remain in maintenance mode after the reboot.
At the top of the script, the Remove VIBs function is defined. Adjusting the setting $settings.dryrun = $true to $false really removes the VIBs. Without adjusting this, the VIBs are not removed and only verified to be present or not. Regardless of the value of $settings.dryrun = $true or $false the hosts are always put into maintenance mode and rebooted.
After executing the host reboot, the script waits 4 minutes before continuing. I built in this pause because nested ESXi hosts reboot so quickly that otherwise the script won’t enter or exit the wait loop. I have used the script in a test lab and it works very well.
Please be aware that using this script is at your own risk!
#Version 1.0
#2024-10-20
#Pre-Upgrade script ESXi7 to ESXi8
#This script remove vibs on all hosts in a cluster that blocks the upgrade
# Function Remove VIBs
function RemoveVIB {
Param (
$ESXi # The EsxCli object
)
[array]$arrayvibs = @("nenic", "iavmd")
$esxcli = Get-EsxCli -V2 -VMHost $ESXi
foreach ($vib in $arrayvibs) {
if ($esxcli.software.vib.list.Invoke() | where {$_.Name -eq "$VIB"}) {
$settings = $esxcli.software.vib.remove.CreateArgs()
$settings.dryrun = $true
$settings.vibname = "$VIB"
echo "$VIB VIB found, remove VIB $esx"
$esxcli.software.vib.remove.Invoke($settings)
}
else {
echo "No $VIB VIB found $esx"
}
}
}
# vCenter & Cluster Parameters
$vCenter = "FQDN vCENTER"
$cluster = "Cluster Name"
# Connect vCenter
Try {Disconnect-VIServer * -Confirm:$false -ErrorAction SilentlyContinue | out-null}
Catch {}
Connect-VIServer $vCenter
$ESXis= Get-Cluster -Name $cluster| Get-VMHost | sort Name | where {$_.ConnectionState -eq 'Connected' -or $_.ConnectionState -eq 'Maintenance'}
foreach ($ESXi in $ESXis) {
write-host "Working on host $($esxi)"
# Host status is Maintenance Mode
if ($ESXi.ConnectionState -eq 'Maintenance') {
Write-host "Host is already in Maintenance Mode..."
RemoveVIB -ESXi $ESXi
Write-host "Host Reboot in Maintenance Mode..."
write-host "Herstarten host $($esxi)"
Restart-VMHost -VMHost $ESXi -Confirm:$False | Out-Null
write-host "Waiting 4 minutes to make sure the host is disconnected before proceeding..."
start-sleep 240
$hoststat = (Get-VMHost -Name $ESXi.Name)
While ($hoststat.ConnectionState -eq "NotResponding") {
Write-host "Host is still rebooting... waiting 10sec..."
Start-Sleep 10
$hoststat = (Get-VMHost -Name $ESXi.Name)
}
}
#Host status is not Maintenance Mode
else {
Write-Host "$($ESXi) is not in Maintenance Mode. Put host in Maintenance Mode..."
write-host ""
# Host in Maintenance Mode
Set-VMHost -VMHost $ESXi -State Maintenance -Confirm:$False | Out-Null
# Vib Remove
RemoveVIB -ESXi $ESXi
# Host Reboot
Write-host "Host is in Maintenance Mode"
write-host "Reboot host $($esxi)"
Restart-VMHost -VMHost $ESXi -Confirm:$False | Out-Null
write-host "Waiting 4 minutes to make sure the host is disconnected before proceeding..."
start-sleep 240
$hoststat = (Get-VMHost -Name $ESXi.Name)
While ($hoststat.ConnectionState -eq "NotResponding") {
Write-host "Host is still rebooting... waiting 10sec..."
Start-Sleep 10
$hoststat = (Get-VMHost -Name $ESXi.Name)
}
# Host uit MM
write-host "Reboot on host $($esxi) is completed..."
write-host ""
Start-Sleep 20
Set-VMHost -VMHost $ESXi -State Connected -Confirm:$False | Out-Null
}
write-host "Done on host $($esxi)"
write-host ""
}
#Disconnect vCenter
write-host "Disconnecting vCenter $vCenter"
Disconnect-VIServer -Confirm:$False | Out-Null
Something I struggled with in the past is setting the productlocker, hassle with scripts and ssh and avoiding host reboots. Today we had to configure another 20 hosts with this and I was pointed to a solution doing it with the MOB. So my next thing was, how to automate this. And with 2 simple foreach loops you can set it and check it and be done!
Setting all hosts from a cluster with a specific path for the productlocker