In this useful article, I will show you how to initiate SCCM Client policy retrieval using Visual Basic script. Using this script, you can manually trigger policy retrieval from the client.
A Configuration Manager client downloads its client policy on a schedule configured as a part if client settings. You can modify SCCM client policy polling interval time from client settings.
There might be occasions when you want to initiate SCCM client policy retrieval manually from the Configuration Manager properties.
For example, consider a scenario when you have deployed an application to a device collection. If the application doesn’t appear in the Software center, you can initiate SCCM client policy retrieval using a simple script.
The client policy polling interval time in SCCM specifies how frequently client computers checks and download new client policy(s). By default, the client policy polling interval is set to 60 minutes.
Without using a script, one can initiate SCCM client policy retrieval using the Actions tab on the Configuration Manager client and running the Machine Policy Retrieval & Evaluation cycle. However, using a script to trigger client policy retrieval makes your task easier.
If you are new to client actions, take a look at ConfigMgr client actions for more details. Every client action cycle is explained in detail.
To initiate SCCM client policy retrieval using script, you must be logged onto the client computer with local administrative rights.
Visual Basic Script for Client Policy Retrieval
Copy the client policy retrieval script into a notepad and save the file as Clientpolicyretrieval.vbs. Since the script is written in Visual Basic, the filename containing this script should end with .vbs extension.
The below script when run initiates the SCCM client policy retrieval (triggers Machine Policy Retrieval & Evaluation Cycle) on the client computer.
on error resume next dim oCPAppletMgr 'Control Applet manager object. dim oClientAction 'Individual client action. dim oClientActions 'A collection of client actions. 'Get the Control Panel manager object. set oCPAppletMgr=CreateObject("CPApplet.CPAppletMgr") if err.number <> 0 then Wscript.echo "Couldn't create control panel application manager" WScript.Quit end if 'Get a collection of actions. set oClientActions=oCPAppletMgr.GetClientActions if err.number<>0 then wscript.echo "Couldn't get the client actions" set oCPAppletMgr=nothing WScript.Quit end if 'Display each client action name and perform it. For Each oClientAction In oClientActions if oClientAction.Name = "Request & Evaluate Machine Policy" then wscript.echo "Performing action " + oClientAction.Name oClientAction.PerformAction end if next set oClientActions=nothing set oCPAppletMgr=nothing
Steps to Initiate SCCM Client Policy Retrieval Using Script
To initiate SCCM client policy retrieval using a script, login to the client computer. There are two ways to run the script:
- Run the Clientpolicyretrieval.vbs directly on the client computer to trigger the client policy update.
- Use the command prompt and run the Clientpolicyretrieval.vbs script.
Method 1: Navigate to the Clientpolicyretrieval.vbs by using Windows Explorer, and double-click the script file. You see a dialog box with a message “Performing action Request & Evaluate Machine Policy“. Click OK in the Windows Script Host dialog box.
The below script initiates the SCCM client policy retrieval (triggers Machine Policy Retrieval & Evaluation Cycle) on the client computer.
Method 2: The second method to run the client policy retrieval script is using Command Prompt. Launch the command prompt as administrator and run the command cscript “Clientpolicyretrieval.vbs“.
The above command will immediately initiate the client policy retrieval from the SCCM client installed on the computer.
I hope this article helps you to trigger the client policy retrieval on the client computer using a simple Visual Basic script. You can execute this script using two different and initiate the client policy update. If you have any questions or suggestions, let me know in the comments section.