ConfigMgr Client Health - Improve Patch Compliance
ConfigMgr Client Health - Improve Patch Compliance
ConfigMgr Client Health - Improve Patch Compliance
Compliance
ConfigMgr Client Health is a PowerShell script that increased our patch compliance from 85% to
99%. It detects and fixes known errors in Windows and the Configuration Manager Client, and
enforces required services to run and start as Automatic. The script should run in the system context
on the computers you want to validate and fix. The script works with PowerShell version 2 and higher,
and is tested on Windows 7 SP1, Windows 8.1 and Windows 10.
This script was created after one of my customers experienced very bad patch compliance, and a lot of
clients very not patched, or reported as compliant while not being patched at all. Our investigation
discovered several root causes, and I created a tool to fix them all. After running this script on their
computers, patch compliance increased significantly.
Note: This is the main page for ConfigMgr Client Health. It will always contain the latest
information about the latest released version, and this is the place to find the most
current documentation.
Note: Latest database version is 0.7.0. Upgrade from version 0.7.0 and higher do no not require a
database upgrade. Upgrading from older versions of ConfigMgr Client Health requires database
upgrade. Copy / paste the content of “createdatabase.sql” to upgrade the database to the latest version.
Requirements
Powershell version 2 or higher
Windows 7
Windows 8
Windows 8.1
Windows 10
Windows Server 2008 R2
Windows Server 2012
Windows Server 2012 R2
Windows Server 2016
Features
ConfigMgr Client Health detects and fixes following errors:
PowerShell.exe -
ExecutionPolicy
The Powershell script need to run with at least Administrator privileges. WMI remediation only works
if the script is run with SYSTEM privileges. I recommend you deploy a GPO that create a scheduled
task running this script with highest privileges (SYSTEM), and that it’s run from a network share. The
health check use very little resources on the client.
Check out my guide: Powershell script with arguments as a scheduled task for how to deploy
ConfigMgr Client Health as a scheduled task with group policy.
Run CreateDatabase.sql on your SQL server to create the SQL database. ConfigMgr Client Health
requires the computer account of the computer running the health check to have datareader and
datawriter roles on the ClientHealth database. A suggestion is to use “domain\domain computers”
group.
Note: Pending reboot check is only implemented for logging and reporting. ConfigMgr Client Health
do not have any functionality implemented to automatically reboot computers. But a computer stuck
in pending reboot can be difficult to patch.
Updates
Place your mandatory updates in the respective folders for the operating system and architecture.
Make sure to share the root update folder to everyone and everyone have read access. ConfigMgr
Client Health will check the folder for its operating system and architecture and install any patches
you place there.
Unfortunately, I cannot add the updates together with my published tool due to license restrictions. But
I recommend you download and add the following updates as they all fix problems with the Windows
Update Agent. Computers missing these updates may experience problems scanning for and applying
new patches.
Windows 7
Windows 8.1
Config.xml
ConfigMgr Client Health uses config.xml to configure its settings. Below is a picture of an example
config.xml file.
Client
Version: Minimum version of Configuration Manager Client to enforce. A client who is running
a version greater than or equal the one specified in config.xml will not be upgraded, but any
client running an older version will be upgraded to the client installation located in
<ClientInstallProperty>/Source:</ClientInstallProperty>
Sitecode: Configuration Manager Sitecode
Domain: Verify the clients computer is a member of this domain.
AutoUpgrade: True / False. ConfigMgr Client Health will upgrade the client only when this is
set to true.
CacheSize: Sets the required cache size for ConfigMgr client. A fixed number is read as KB. A
number with % after is read as percentage of total disk space.
Share: Fileshare where ConfigMgr client source files is located. It is used when client health is
installing the ConfigMgr client for the first time, upgrade the client to minimum version, or
reinstalling if determined necessary to fix serious errors.
Log: MaxLogSize: Maximum log file size on ConfigMgr client. MaxLogHistory: Maximum log
file history on client. Enable: Enable or disable this check.
These are install properties used when ConfigMgr Client Health is reinstalling the configuration
manager client on your Windows computer. You can add and remove as many as you want, and all
official ccmsetup.exe switches are supported. For a full list of supported ccmsetup.exe
switches: https://docs.microsoft.com/en-us/sccm/core/clients/deploy/about-client-installation-
properties
Service
Services to enforce a specific startup type and running state on the client.
Name: Name of service
Startup type: Automatic, Manual, Disabled
State: Running, Stopped
BITSCheck
Option to check and remediate if BITS have any jobs stuck with errors. Enabling this check may fix
errors where downloads are stuck at 0% in software center.
Fix: Script will fix any errors if set to True. Only logs errors if False. Values: True / False.
DNSCheck
Option to check if IP addresses registered on DNS server record matches local IP addresses on the
computer. Will perform a Resolve-DNSClient if Powershell version 4 or higher, or IPConfig
/RegisterDNS if Powershell version 3 or lower.
Drivers
Option to check if local drivers are working as intended. Will report back devices with missing drivers
or faulty driver.
Updates
ConfigMgr Client Health will detect operating system and architecture, and install all patches placed
here for its operating system and architecture. A computer running Windows 7 64-bit will verify all
patches in “\\CM01\ClientHealth$\Updates\Windows 7 64-Bit” are installed, and install those who are
missing. This is a great way to install patches that fixes bugs in the Windows Update agent.
Logging
Data gathered by the ConfigMgr Client Health script is stored in ClientHealth database on the SQL
server and / or log share specified in the config.xml file. The agent will always log the following
events to log share if log share is enabled.
Log settings
Share: File share where logs are stored.
Level: Depreciated
MaxLogHistory: How many times the script will save its log history for the computer before it
discards the log file and starts over.
Enable: Enable or disable this component. Values: True / False.
PendingReboot
StartRebootApplication: Setting to determince if ConfigMgr Client Health will start the reboot
application if the computer is in a pending reboot state. Values: True / False
Enable: Enable or disable this component. Values: True / False.
RebootApplication
A reboot application is a 3rd party application (or command) that will force a mandatory reboot of the
computer. I recommend the use of Coretech’s Shutdown Tool to reboot computers as it gives the users
a notice and opportunity to postpone the reboot.
MaxRebootDays
This setting determines how many days a computer can be online before ConfigMgr Client Health will
start the reboot application. This setting do nothing if RebootApplication is disabled.
OSDiskFreeSpace
Free space in percent on C: of the client. It’s recommended to have at least 10% free space on the OS
drive.
HardwareInventory
Days: ConfigMgr Client Health will start a hardware inventory on the client if last execution
time was more than the days specified in this setting.
Enable: True / False
Fix: Script will fix any errors if set to True. Only logs errors if False. Values: True / False.
SoftwareMetering
This setting enables a test and remediation on the software metering prep driver.
Remediation
These settings control what components ConfigMgr Client Health will validate and fix.
AdminShare: Checks if Admin$ and C$ is shared and working correctly on the computer. Fix:
True / False.
ClientProvisioningMode: Checks if Configuration Manager Client is stuck in provisioningmode.
Fix: True / False.
ClientStateMessages: Fix: True / False.
ClientWUAHandler: Fix: True / False.
ClientCertificate: Fix: True / False. Checks if the PKI certificate used by ConfigMgr client is
stored in the certificate store.
WMI: Checks if WMI is corrupt. Fix: True / False.
SQL Database
Execute the SQL query stored s”Createdatabase.sql” on your SQL server to create the SQL database.
This query will create the database if it doesn’t exist, or upgrade it to the current version if already
present.
You also need to give the Active Directory group “domain computeres” datareader and datawriter
rights on the database.
SELECT * FROM
dbo.Clients ORDER
SELECT Hostname,
OperatingSystem,
Computers with low or no free space on C: can be hard to patch and deploy software to, but I do not
want the client health script to attempt any auto-cleaning of files. Running this SQL query on the
Client Health database lists all computers with 10% or less free space on C:. This is a list we send to
our service desk, and they will help the users to clean up, or reinstall the computers.
SELECT Hostname,
OperatingSystem,
Computers who have not patched in 60 days or more should be investigated. This query gives you that
list. The easy solution is to just reinstall the computers. The goal of ConfigMgr Client Health is to find
as many causes as possible to why a computer is not patching, and automatically try to fix them.
Please let me know if you find a root cause and fix not detected by this script and I would love to add
it.
The right click tool console extension makes it easy to remotely start ConfigMgr Client Health on
devices and collections. It uses PowerShell to remotely start the scheduled task that executes
ConfigMgr Client Health.
Windows Remote Management (WinRM) must be enabled on the devices for this console extension to
work.
Use the PowerShell installer “Install.ps1” to install the right click tool console extension. The installer
takes two arguments:
-Path
The path to where the console extension stores its assembly and scripts.
-ScheduledTaskName
The name of the scheduled task that starts ConfigMgr Client Health on your computers.
-MaxThreads
Optional parameter. Configures the maximum number of simultaneous threads when running against a
collection of devices. Default value is 20.
Example:
Install.ps1 -Path
"C:\Program
Note: I’m happy to help with issues you have implementing this script, please use the comment below
for that. It helps me a lot if the post your operating system and what rights the script is running.
Minimum required rights are local administrator, recommended is system.
This solution is provided AS-IS and comes with no warranties. Use at your own risk.
Excerpted from ConfigMgr Client Health - Improve Patch Compliance
https://www.andersrodland.com/configmgr-client-health/