Having the misfortune of a sudden battery failure on my laptop the other day, it got me thinking about how we monitor laptop health across our environment. Wouldn’t it be cool if I could monitor battery health for all laptops in my organisation and get them to raise support tickets if they found their battery health was failing.

So once again going back to one of the most under utilised and powerful features of configuration manager (CI & CB), I set up a configuration item and baseline to perform the following actions

Query the machine WMI for the manufactures max charge spec Query the WMI for the current max charge Compare the two values Should the battery health be below a set value (in my example below I used a very high value at 99%, obviously this is just for testing however I would recommend ~40% for real world monitoring) generate a full battery status report and email it to our IT Helpdesk using a template containing the Make, Model and Serial number of the laptop with the issue:



Email Notification



Attachment – Battery Health Report

Microsoft Script Library Link – https://gallery.technet.microsoft.com/Laptop-Battery-Health-98d1dc60

Note: This script requires Windows 8 upwards if you require the battery report attachment.

UPDATE – 24/2/2017

Following feedback from the community I have updated the script to allow environments with no internal SMTP relay or port 25 access to external SMTP servers to save the reports to a network share.

When the script runs and you use the -NetworkReport $true in the function call it will generate a CSV with the required values to generate an email and the battery report, the goal here is to get your reports saved to a server with access to the network share and SMTP ACL access. In this instance a new secondary script (which I have included in the updated link on the MS script link) can be scheduled to run on this server in order to generate the notifications to your helpdesk.

Things To Note:

You might want to consider including a date filter on line 51 in the LaptopBatteryNotifier.ps1 script so the helpdesk don’t receive mulitple emails for the same machine over time. For instance you could schedule the script to run every 7 days and only include machine reports within that period by changing the line to;

$Computers = Get-ChildItem -Path $NetworkShare | where-object {$_.LastWriteTime -gt (Get-Date).AddDays(-7)

If you are using this method make sure that the share has permissions for at least the Domain Computers and the account you are running the LaptopBatteryNotifier script to have full permissions to the share / folder. I would recommend that this folder is a hidden share in this instance.

Here is how it is done



Create A Configuration Item

Open the SCCM Management console and under Assets and Compliance\Compliance Settings select Configuration Item. Now create a new Configuration Item

Select Operating Systems

Pick the Operating Systems that you which to apply the CI to:

Add Settings

Click on New on this screen and select “Script” under Settings Type:





Discovery Script

Now enter your Discovery script (LaptopBatteryCheck.ps1 from the ZIP file). No remediation script is required unless you want to separate the email function.

Create A New Rule

Here we will select the settings previously created and set a target value for the new rule

Now the Configuration Item is in place, we can go onto setting up the Baseline to deploy to your chosen Collection.

Create A New Configuration Baseline

Create your new Configuration Baseline, Select the Configuration Item you set up in the previous steps and click OK.

The Final Step is to deploy your newly created Configuration Baseline to a chosen collection.

As always folks, please keep your PowerShell version installations up to date for compatibility.

(9308)