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.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# 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
# 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
# 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 defined 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!
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# 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
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!
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#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"}){
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