Modern Management - Part Nine - BGinfo via Intune

I've used BGinfo (https://docs.microsoft.com/en-us/sysinternals/downloads/bginfo) for years across numerous clients to present helpful support informaiton to clients on the desktop. 





Working for a client recently I've created a custom Win32 app for this with the help of this post (https://oliverkieselbach.com/2018/12/15/deploying-win32-app-bginfo-with-intune/) from Oliver Kieselbach (MVP).


Install.ps1 (this has been amended from the original to copy a backgroud.jpg and a Version1.txt which I'm going to use to check for the detection method) - https://gist.github.com/okieselbach/59920bb8f67e09a8e68fc570200e5294


<#
Version: 1.0
Author:  Oliver Kieselbach (oliverkieselbach.com)
Date: 15.12.2018

Description:
Install BGInfo64 with custom background scheme where hostname and logged on user incl. membership (Admin|User) is shown.
It is especially usefull when dealing with virtual test environments where different devices, users, and different
Autopilot profiles are used. It enhanced viability of hostname, username and available permissions of the user.

Thanks to Nick Hogarth for inspiring me with his initial version. I basically extended his solution.
His version can be found here: https://nhogarth.net/2018/12/14/intune-win32-app-deploying-bginfo/

Release notes:
Version 1.0: Original published version.

The script is provided "AS IS" with no warranties.
#>

New-Item -ItemType Directory -Force -Path "c:\Program Files\BGInfo" | Out-Null
#Start-BitsTransfer -Source "https://live.sysinternals.com/Bginfo64.exe" -Destination "C:\Program Files\BGInfo"
Copy-Item -Path "$PSScriptRoot\Bginfo64.exe" -Destination "C:\Program Files\BGInfo\Bginfo64.exe"
Copy-Item -Path "$PSScriptRoot\custom.bgi" -Destination "C:\Program Files\BGInfo\custom.bgi"
Copy-Item -Path "$PSScriptRoot\Desktop_Backgroud.jpg" -Destination "C:\Program Files\BGInfo\Desktop_Backgroud.jpg"
Copy-Item -Path "$PSScriptRoot\Version1.txt" -Destination "C:\Program Files\BGInfo\Version1.txt"

$Shell = New-Object -ComObject ("WScript.Shell")
$ShortCut = $Shell.CreateShortcut("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\BGInfo.lnk")
$ShortCut.TargetPath="`"C:\Program Files\BGInfo\Bginfo64.exe`""
$ShortCut.Arguments="`"C:\Program Files\BGInfo\custom.bgi`" /timer:0 /silent /nolicprompt"
$ShortCut.IconLocation = "Bginfo64.exe, 0";
$ShortCut.Save()

$CheckAdminScript = @"
Dim WshShell, colItems, objItem, objGroup, objUser
Dim strUser, strAdministratorsGroup, bAdmin
bAdmin = False

On Error Resume Next
Set WshShell = CreateObject("WScript.Shell")
strUser = WshShell.ExpandEnvironmentStrings("%Username%")

winmgt = "winmgmts:{impersonationLevel=impersonate}!//"
Set colItems = GetObject(winmgt).ExecQuery("Select Name from Win32_Group where SID='S-1-5-32-544'",,48)

For Each objItem in colItems
     strAdministratorsGroup = objItem.Name
Next

Set objGroup = GetObject("WinNT://./" & strAdministratorsGroup)

For Each objUser in objGroup.Members
    If objUser.Name = strUser Then
         bAdmin = True
         Exit For
    End If
Next
On Error Goto 0

If bAdmin Then
     Echo "Admin"
Else
     Echo "User"
End If
"@

$CheckAdminScript | Out-File -FilePath "C:\Program Files\BGInfo\CheckAdmin.vbs" -Encoding utf8 -Force -Confirm:$false

Return 0


Uninstall.ps1https://gist.github.com/okieselbach/4a379a5407b5cb66d38117060a3acf9b


<#
Version: 1.0
Author:  Oliver Kieselbach (oliverkieselbach.com)
Date: 15.12.2018

Description:
Uninstall BGInfo64. User has to switch background to the original one by his own.

Release notes:
Version 1.0: Original published version.

The script is provided "AS IS" with no warranties.
#>

Remove-Item -Path "C:\Program Files\BGInfo" -Recurse -Force -Confirm:$false
Remove-Item -Path "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\BGInfo.lnk" -Force -Confirm:$false

Return 0

With all my source files in place (in C:\IntuneWinAppUtil\Source\) :



I copied them to the destination directory (C:\Program Files\BGInfo\and configured my custom.bgi file to my liking (copying back to the source directory once I was happy with the content and layout):


I've used the command IntuneWinAppUtil -c C:\IntuneWinAppUtil\Source -s C:\IntuneWinAppUtil\Source\Bginfo64.exe Custom.bgi /nolicprompt /silent /timer:0 -o C:\IntuneWinAppUtil\Output -q to create my .intunewin file:




And then created an App within Intune with the following configuration:



PROPERTIES

APP TYPE
Windows app (Win32)
APP PACKAGE FILE
Bginfo64.intunewin
APP INFORMATION

NAME
BgInfo (x64)
DESCRIPTION
BgInfo v4.27
PUBLISHER
Sysinternals
CATEGORY
Computer Management
DISPLAY THIS AS A FEATURED APP IN THE COMPANY PORTAL
No
INFORMATION URL
https://docs.microsoft.com/en-us/sysinternals/downloads/bginfo
PRIVACY URL
None
DEVELOPER
Sysinternals
NOTES
None
LOGO
None
PROGRAM

INSTALL COMMAND
powershell -ex bypass -file install.ps1
UNINSTALL COMMAND
powershell -ex bypass -file uninstall.ps1
INSTALL BEHAVIOUR
System
REQUIREMENTS

OPERATING SYSTEM ARCHITECHTURE
32-BIT & 64-BIT
MINIMUM OPERATING SYSTEM
WINDOWS 10 1607
DISK SPACE REQUIRED (MB)
NONE
PHYSICAL MEMORY REQUIRED (MB)
NONE
MINIMUM CPU SPEED REQUIRED (MHZ)
NONE
DETECTION RULES

RULE TYPE
File
PATH
C:\Program Files\BGInfo
FILE OR FOLDER
Version1.txt
DECTION METHOD
File or folder exists
ASSOCIATED WITH A 32-BIT APP ON 64-BIT CLIENTS
NO
RETURN CODES

0
SUCCESS
1707
SUCCESS
3010
SOFT REBOOT
1641
HARD REBOOT
1618
RETRY


And finally assigned it to my devices. Within a few minutes and a sync of the client we have BGinfo deployed :)

If I need to make changes I can simply update the source files and create a new .intunewin file and then change the detection method to Version2.txt and of course remember to update the Install.ps1.


Comments