A Modern bginfo solution – just a simple powershell script

Hey, I’ve been looking around for a bginfo solution. I tried the original one from sysinternal tools
https://docs.microsoft.com/en-us/sysinternals/downloads/bginfo
but it always changes the background to “tile”, I don’t know why..
There are hotfixes out there but I don’t want a hotfix. I want a “real solution”

So I found this page.
https://p0w3rsh3ll.wordpress.com/2014/08/29/poc-tatoo-the-background-of-your-virtual-machines/

So started with that, then I’ve worked further with it and now
it’s finally working as I want and the result is this:

So first, Download this script.
Link bginfo.zip

Then just run the script either as a scheduled task or login script in GPO. No bginfo.exe is needed or anything extra.

If you want to change the information on the background, open the bginfo.ps1
then go to the
“#Writing info to the background” part, and then change what information that you want to use 🙂

And if you want to change the Background to be stretch instead of fit, you change this part, change the -style to stretch.

Another thing that is great is, if you want to force a background also, you change this part active, just take away the #

So that’s it

Good luck while using it
Pontus

21 Replies to “A Modern bginfo solution – just a simple powershell script”

  1. Fantastic alternative and works very well on Windows 10. Does not work on Windows 7 though. Any ideas on how to modify to work on both versions?

    Like

  2. There’s a few things that can go wrong here. 1) Your BMP save will try to save to the same file name every time the script runs. If the file already exists and it’s already set as the background, your save will fail with a generic GDI+ error. To fix that, you will need to make the $Outfile name unique every time it runs. 2) This does not work with multiple monitors where there is a combination of both landscape and portrait mode. This is because the script takes the entire resolution of the desktop and the ‘tallest’ y axis measurement brings the information off the screen. Perhaps messing with alignment could fix this. But generally this is not dynamic enough for crazy monitor setups, which seems to be more common these days.

    Still though, very cool script. I appreciate this at least being an option since BGinfo from SysInternals has its own silly limitations with resolution and scaling.

    Like

    1. aha that’s why,I always got that error, was trying to figure that, but didn´t solved it.

      Aha, think it will be hard to solve that issue, will think about it.

      Yes, got tired of bginfo in Sysinternals, register fixes need to get it to work properly.

      Thanks for everyone that uses this, feel free to improve it!

      Cheers.

      Like

      1. for the $outfile, i used:
        [string] $OutFile= “$($env:temp)\” + ( ( get-date ).TimeOfDay.TotalSeconds ) + “BGInfo.bmp”, to randomize it, and allow for multiple logins.

        What you may also want to introduce is a way to choose the “input background” as well, to start fresh if possible. I know you can set the background as it is, but if there is a default install, you should be using that background instead of re-writing the same

        Like

  3. Additionally, changed the info gathering to something I was able to use better:

    $systemInfo = ( .\systeminfo.exe )
    $memory = ( $systemInfo | Select-String ‘Total Physical Memory:’).ToString().Split(‘:’)[1].Trim()
    $osType = ( $systemInfo | Select-String ‘OS Name:’).ToString().Split(‘:’)[1].Trim()
    $osVersion = ( $systemInfo | Select-String ‘OS Version:’ )[0].ToString().Split(‘:’).Trim()[1]
    $BootTime = ( $systemInfo | Select-String ‘System Boot Time’ ).ToString().Substring(27)
    $domaincontroller = $env:LOGONSERVER.split(“\”)[2]

    $t = @”
    Server Computer Name : $env:COMPUTERNAME
    Currently logged on User : $env:USERNAME
    Logon Domain Controller : $domaincontroller
    Last System Start Time : $BootTime
    Total Memory count : $memory
    Total CPU core count : $env:NUMBER_OF_PROCESSORS
    Operating System Type: $osType
    Operating System Version : $osVersion
    Server Logon Domain : $env:USERDNSDOMAIN
    “@

    The extra spaces cleaned up the view when it is placed on the desktop.

    Like

  4. The script is great.

    I found these useful additions:

    $BuildInfo =(Get-ItemProperty -Path “HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion” -Name ReleaseId).ReleaseId
    $IPAddress =(Get-NetIPAddress -AddressFamily ipV4 | Where-Object {$_.IPAddress -notlike ‘127.0.*’} | Select -expandproperty IPAddress)
    $ServiceTag =(Get-WmiObject Win32_BIOS | Select -expandproperty SerialNumber)

    $t = @”

    Host Name: $env:COMPUTERNAME
    Service Tag: $ServiceTag
    IP Adress: $IPAddress
    User Name: $env:USERNAME
    Logon Domain: $env:USERDNSDOMAIN
    Logon Server: $env:LOGONSERVER
    OS Version: $OSVersion
    Build Info: $BuildInfo
    “@

    Like

    1. Thank you for posting, Eric.

      Unfortunately, I ran into an unforeseen problem w/ your Script.
      In most circumstances, your script updates should work, as intended.

      However, I have several NordVPN Adapters, which contain an APIPA Address (169.254.X.X), when the VPN is Deactivated.

      As a result, Four IP Addresses were Listed (169.254.43.40, 169.254.30.3, 192.168.1.127, 169.254.57.70).

      I ended up making a small update to the IP Address portion of your Script, to display only the working IP Address (192.168.1.127).

      Before:
      $IPAddress = (Get-NetIPAddress -AddressFamily ipV4 | Where-Object {$_.IPAddress -notlike ‘127.0.*’} | Select -expandproperty IPAddress)

      After:
      $IPAddress = (Get-NetIPAddress -AddressFamily ipV4 | Where-Object {$_.IPAddress -notlike ‘127.0.*’ -and $_.IPAddress -notlike ‘169.254.*’} | Select -expandproperty IPAddress)

      $t = @”
      IP Address: $IPAddress
      “@

      On a related note, there may be instances where you want to display an APIPA Address, since they are a good indicator of DHCP related Issues, etc.

      Therefore, I thought I’d share an alternative method of acquiring the IP Address.

      $IPAddress = ( Get-NetIPConfiguration | Where-Object { $_.IPv4DefaultGateway -ne $null -and $_.NetAdapter.Status -ne “Disconnected” } ).IPv4Address.IPAddress

      $t = @”
      IP Address: $IPAddress
      “@

      Thanks again!

      Like

  5. I have the script working how I want it. But every time I run it, the text is cut off by the edge of the screen. The script never changes the background settings from fill to stretch. Any ideas on how to get the text info to align correctly at the top right of the screen?

    Like

  6. AVERTISSEMENT : Failed to Exception lors de l’appel de « Save » avec « 2 » argument(s) : « Une erreur générique s’est produite dans GDI+. »

    Any way to fix this ?

    Like

    1. Per Nell Grant’s Comment above, try changing the [string] $OutFile Parameter on Line 29, as follows.

      Before:
      [string] $OutFile= “$($env:temp)\BGInfo.bmp”,

      After:
      [string] $OutFile=“$($env:temp)\” + ( ( get-date ).TimeOfDay.TotalSeconds ) + “BGInfo.bmp”,

      Hope that helps.

      Like

    1. Hello Gearlos,

      As “Nell Grant” pointed out above, the [string]$OutFile Parameter (on Line 29) needs to be Updated, to Randomize the File Name, thereby allowing Multiple Logins, etc.

      Before:
      [string] $OutFile= “$($env:temp)\BGInfo.bmp”,

      After:
      [string] $OutFile=“$($env:temp)\” + ( ( get-date ).TimeOfDay.TotalSeconds ) + “BGInfo.bmp”,

      Give that a try and see if it resolves your issue.

      Like

  7. Hello,

    I am using this opportunity to write that this is very simple and good alternative to bginfo. I was using it for couple of months without issues but after september/october update 2020, script can not be run (Powershell has stopped working error).

    Detailed error: Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

    Have anyone experienced the same type of error?

    Like

Leave a Reply to cdirrigle Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s