PowerShell GUI for SCCM or MDT: Battery warning

In this post I will share with you a little PowerShell GUI I in created to display before starting your deployment if your computer is not plug in.

How to get it ?

How it looks like ?
The GUI looks like as below:

Change the text or language
You can change easily the text inside the GUI and also the title bar in order to add your own language for instance.
I try to make it simple to add your own language.
For that after downloading content proceed as below:
1. Open the file GUI_Config.xml
2. See below how looks like the XML content
3. Change the text with your language
4. See below the warning GUI and corresponding part in the XML

5. See below an overview in French

I will work on another version to change the language depending of the culture.

Is your computer running on battery ?
In order to display the GUI we have to find a way to detect if your computer is plugged-in or running on battery.
For that we will use the WMI query below:
gwmi -Class Win32_Battery).BatteryStatus -ne 2

We will use two methods to display the GUI:
- Display the GUI once
- Display the GUI until the computer is plug in

Create the Wizard content
1. Download the wizard
2. Copy the folder to your server
3. Go to C:\Program Files\Microsoft Deployment Toolkit\Templates\Distribution\Tools\x64
4. Copy the file ServiceUI.exe in the wizard folder: 

So far we have seen how to create the wizard content and how to customize it. Now let's see how to implement it in our SCCM environment.

Create the SCCM package
1. Go to Software Library
2. Go to Application Management then Packages
3. Do a right click and select Create Package
4. Type a name like Battery warning wizard
5. Check This package contains source files
6. Click on Browse, then select the folder containing the warning wizard

7. Click on Next
8. Select Do not create a program

9. Click on Next
10. Click on Next
11. Click on Close

Distribute the package
1. Do a right-click on your package
2. Select Distribute Content
3. Click on Next

4. Click on Add and select Distribution Point

5. Select your DP and click on OK

6. Click on Next
7. Click on Next
8. Click on Close

Task Sequence implementation
In this method we will create a Run command Line step that will work as below:
- Detect if running on battery using the WMI query mentioned above
- Run warning wizard: Only if the query returned true

1. Edit your TS
2. Click on Add, General then Run Command Line

3. Type a name like Run battery warning wizard
4. In the commandline part, add the one of the command line below depending of what you want to do:
Display the GUI just once
Display the GUI until the computer is plug in

5. See below how this step looks like

6. Click on the Options tab
7. Click on Add Condition
8. Select Query WMI

9. Add the below WMI query

10. See below how it looks like

11. Click on OK
12. Click on OK

The GUI in action
In the below example I integrated this warning in a custom TS.
The warning is displayed until the computer is not plug in.

WPF_GUI 3968368561520437540

Publier un commentaire

Accueil item


Mes articles en français

Author of Books

PowerShell GUI & WPF Group

PowerShell GUI & WPF Group

Join the FPSUGR

Join the FPSUGR