BgInfo deployment script for Windows Server 2025 – Wim Matthyssen

[ad_1]

In this blog post, I’ll show you how to deploy and configure the latest version of BgInfo on a server running Windows Server 2025 using a PowerShell script.

💡 This script also works on servers running Windows Server 2016, 2019, and 2022.

Most IT pros and Windows server administrators are likely familiar with the Windows Sysinternals tool BgInfo (currently version 4.33). For those who aren’t, it’s a free Microsoft tool that captures system information from a workstation or server (especially useful on servers) and displays relevant data directly on the desktop. It shows details like DNS settings, IP addresses, computer name, domain name, OS version, memory, service pack version, and more.

Whenever I create a new Windows Server 2025 Virtual Machine (VM) template for customers, deploy a physical server, or set up a test server in my home environment or lab, I usually add BgInfo to the base (or golden) image, or after deployment, and configure it to start automatically when a user logs in.

To make this process easier, I wrote a PowerShell script that automates the entire BgInfo installation and configuration. In this blog post, I’ll walk you through the steps to set it up.

Table of Contents

Table of Contents

Prerequisites

  • A server (physical or virtual) running Windows Server 2025 with internet access to download the latest version of BgInfo and the logon.bgi file.
1

💡 You can always modify the script to retrieve the files from a central file server or company share if direct Internet access is unavailable or restricted due to security policies.

PowerShell script

To begin, let me explain what this PowerShell script does:

  • Check if PowerShell is running as Administrator, otherwise exit the script.
  • Create a BgInfo folder on the C: drive if it doesn’t already exist; otherwise, delete its contents.
  • Download, save and extract latest BGInfo software to C:\BgInfo.
  • Download, save and extract logon.bgi file to C:\BgInfo.
  • Create BgInfo registry key for AutoStart.
  • Run BgInfo.

To use the script, start by saving a copy as “Deploy-BgInfo-WS2016-WS2019-WS2022-WS2025.ps1” or download it directly from GitHub. Adjust the variables to suit your specific needs, and then run the script using Windows PowerShell (as Administrator) on the server or template VM.

💡 I typically save it locally in the C:\Temp folder on the server and run it from there.

image 1
image 2
<#
.SYNOPSIS

A script used to download, install, and configure the latest version of BgInfo on Windows Server 2016, 2019, 2022, or 2025.

.DESCRIPTION

A script used to download, install, and configure the latest version of BgInfo on Windows Server 2016, 2019, 2022, or 2025.
This script will do all of the following:

Check if PowerShell is running as Administrator, otherwise exit the script.
Create a BgInfo folder on the C: drive if it doesn't already exist; otherwise, delete its contents.
Download, save and extract latest BGInfo software to C:\BgInfo.
Download, save and extract logon.bgi file to C:\BgInfo.
Create BgInfo registry key for AutoStart.
Run BgInfo.

.NOTES

File Name:     Deploy-BgInfo-WS2016-WS2019-WS2022-WS2025.ps1
Created:       08/09/2019
Last Modified: 03/04/2025
Author:        Wim Matthyssen
PowerShell:    Version 5.1 or later
Requires:      -RunAsAdministrator
OS Support:    Windows Server 2016, 2019, 2022, and 2025
Version:       3.2
Note:          Update variables as needed to fit your environment
Disclaimer:    This script is provided "As Is" without any warranties.

.EXAMPLE

.\Deploy-BgInfo-WS2016-WS2019-WS2022-WS2025.ps1

.LINK

PowerShell script: BgInfo deployment script for Windows Server 2025
#> ## ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ## Variables $bgInfoFolder = "C:\BgInfo" $bgInfoFolderContent = "$bgInfoFolder\*" #$itemType = "Directory" $bgInfoUrl = "https://download.sysinternals.com/files/BGInfo.zip" $bgInfoZip = "C:\BgInfo\BGInfo.zip" $bgInfoEula = "C:\BgInfo\Eula.txt" $logonBgiUrl = "https://tinyurl.com/yxlxbgun" $logonBgiZip = "$bgInfoFolder\LogonBgi.zip" $bgInfoRegPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" $bgInfoRegKey = "BgInfo" #$bgInfoRegType = "String" $bgInfoRegKeyValue = "C:\BgInfo\Bginfo64.exe C:\BgInfo\logon.bgi /timer:0 /nolicprompt" #$regKeyExists = (Get-Item $bgInfoRegPath -EA Ignore).Property -contains $bgInfoRegkey $global:currenttime= Set-PSBreakpoint -Variable currenttime -Mode Read -Action Out-Null Write-Host ($writeEmptyLine + "# BgInfo registry key created" + $writeSeperatorSpaces + $currentTime)` -foregroundcolor $foregroundColor2 $writeEmptyLine $foregroundColor1 = "Green" $foregroundColor2 = "Yellow" $foregroundColor3 = "Red" $writeEmptyLine = "`n" $writeSeperatorSpaces = " - " ## --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ## Check if PowerShell is running as Administrator, otherwise exit the script $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) if (-not $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) Out-Null Write-Host ($writeEmptyLine + "# BgInfo folder created at $bgInfoFolder" + $writeSeperatorSpaces + $currentTime)` -foregroundcolor $foregroundColor2 $writeEmptyLine ## --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ## Write script started Write-Host ($writeEmptyLine + "# Script started. Without errors, it can take up to 2 minutes to complete" + $writeSeperatorSpaces + $currentTime)` -foregroundcolor $foregroundColor1 $writeEmptyLine ## --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ## Create a BgInfo folder on the C: drive if it doesn't already exist; otherwise, delete its contents try { if (!(Test-Path -Path $bgInfoFolder)) New-ItemProperty -Path $bgInfoRegPath -Name $bgInfoRegKey -PropertyType String -Value $bgInfoRegKeyValue -Force else Out-Null Write-Host ($writeEmptyLine + "# BgInfo registry key created" + $writeSeperatorSpaces + $currentTime)` -foregroundcolor $foregroundColor2 $writeEmptyLine } catch { Write-Host ($writeEmptyLine + "# Failed to create or clean BgInfo folder: $_" + "ERROR" + $writeSeperatorSpaces + $currentTime)` -foregroundcolor $foregroundColor3 $writeEmptyLine exit } ## --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ## Download, save and extract latest BGInfo software to C:\BgInfo try { # Import the BitsTransfer module to enable file transfer using Background Intelligent Transfer Service (BITS) Import-Module BitsTransfer -ErrorAction Stop # Download the BgInfo ZIP file from the specified URL and save it to the specified destination Start-BitsTransfer -Source $bgInfoUrl -Destination $bgInfoZip # Extract the contents of the downloaded ZIP file to the BgInfo folder Expand-Archive -LiteralPath $bgInfoZip -DestinationPath $bgInfoFolder -Force # Remove the ZIP file and the EULA file after extraction to clean up Remove-Item $bgInfoZip, $bgInfoEula -Force Write-Host ($writeEmptyLine + "# BgInfo downloaded and extracted successfully" + $writeSeperatorSpaces + $currentTime)` -foregroundcolor $foregroundColor2 $writeEmptyLine } catch { Write-Host ($writeEmptyLine + "# Failed to download or extract BgInfo: $_" + "ERROR" + $writeSeperatorSpaces + $currentTime)` -foregroundcolor $foregroundColor3 $writeEmptyLine exit } ## --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ## Download, save and extract logon.bgi file to C:\BgInfo try { # Ensure TLS 1.2 is used for compatibility with modern HTTPS endpoints (required for Windows Server 2016) [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # Download the logon.bgi file Invoke-WebRequest -Uri $logonBgiUrl -OutFile $logonBgiZip -ErrorAction Stop # Extract the ZIP file Expand-Archive -LiteralPath $logonBgiZip -DestinationPath $bgInfoFolder -Force # Clean up the ZIP file Remove-Item $logonBgiZip -Force Write-Host ($writeEmptyLine + "# logon.bgi available" + $writeSeperatorSpaces + $currentTime)` -foregroundcolor $foregroundColor2 $writeEmptyLine } catch { Write-Host ($writeEmptyLine + "# Failed to download or extract logon.bgi: $_" + "ERROR" + $writeSeperatorSpaces + $currentTime)` -foregroundcolor $foregroundColor3 $writeEmptyLine exit } ## --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ## Create BgInfo registry key for AutoStart try { if (Get-ItemProperty -Path $bgInfoRegPath -Name $bgInfoRegKey -ErrorAction SilentlyContinue) { Write-Host ($writeEmptyLine + "# BgInfo registry key already exists" + $writeSeperatorSpaces + $currentTime)` -foregroundcolor $foregroundColor2 $writeEmptyLine } else { New-ItemProperty -Path $bgInfoRegPath -Name $bgInfoRegKey -PropertyType String -Value $bgInfoRegKeyValue -Force | Out-Null Write-Host ($writeEmptyLine + "# BgInfo registry key created" + $writeSeperatorSpaces + $currentTime)` -foregroundcolor $foregroundColor2 $writeEmptyLine } } catch { Write-Host ($writeEmptyLine + "# Failed to create BgInfo registry key: $_" + "ERROR" + $writeSeperatorSpaces + $currentTime)` -foregroundcolor $foregroundColor3 $writeEmptyLine exit } ## --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ## Run BgInfo try { Start-Process -FilePath "C:\BgInfo\Bginfo64.exe" -ArgumentList "C:\BgInfo\logon.bgi /timer:0 /nolicprompt" -NoNewWindow -Wait Write-Host ($writeEmptyLine + "# BgInfo executed successfully" + $writeSeperatorSpaces + $currentTime)` -foregroundcolor $foregroundColor2 $writeEmptyLine } catch { Write-Host ($writeEmptyLine + "# Failed to execute BgInfo: $_" + "ERROR" + $writeSeperatorSpaces + $currentTime)` -foregroundcolor $foregroundColor3 $writeEmptyLine exit } ## --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ## Write script completed Write-Host ($writeEmptyLine + "# Script completed" + $writeSeperatorSpaces + $currentTime)` -foregroundcolor $foregroundColor1 $writeEmptyLine ## ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4
6
5 1
7
8

Using the script on other supported Windows Server OSes

💡 You can easily check the Windows OS version on a server by opening Windows PowerShell and running the following command: systeminfo | findstr /B /C:”OS Name” /C:”OS Version”

Windows Server 2022

9
10 1

Windows Server 2019

11
12

Windows Server 2016

14
15

Conclusion

In this blog post, I introduced a PowerShell script that helps automate the deployment and configuration of BgInfo, a free Microsoft tool that displays system details like IP addresses, computer name, OS version, and more, right on the desktop.

I hope the script proves useful when setting up servers or creating VM templates. If you have any questions or suggestions, feel free to reach out on X (@wmatthyssen) or leave a comment below.



[ad_2]

Share this content:

I am a passionate blogger with extensive experience in web design. As a seasoned YouTube SEO expert, I have helped numerous creators optimize their content for maximum visibility.

Leave a Comment