Detect Client Connectivity and Trigger Machine Policy Evaluation

Hi. My name is Jesse, and I’m a script-aholic.

I also enjoy sleep, which is typically what motivates me to automate many processes using Powershell. Assuming that you enjoy sleeping as much as I do, I’ll gladly share with you a recent script that I wrote.

Backstory:

I was tasked to deploy an application via ConfigMgr to a group of VPN users around the world. Timing was of the essence, and I needed to ensure that the clients received policy as soon as they were available. However, as the users were global and it was uncertain as to exactly when they would be checking in, I needed to devise a way to detect network connectivity and trigger the machine policy evaluation and retrieval, even as it occurred overnight.

After grouping the machines into a collection in which the application was deployed, I decided to write the following script to automate the policy retrieval. The script does the following:

  • Imports the ConfigMgr module and changes to the site directory
  • Grabs all of the machine names in the defined collection
  • Grabs a count of machines in the collection
  • Starts a do-while loop that continues until $i equals the total count of the collection
  • For each machine, it tries to connect once
    • If successful
      • Triggers the Machine Policy Evaluation and Retrieval
      • Removes the machine from the $Machines variable list (not the collection) so as to not continuously check the same successful machine
      • Increments the value of $i for the do-while loop
      • Writes the machine name and time of successful connectivity to .\MachineEvalTrigger.txt
    • If failed connectivity
      • Will continuously try each member of the $Machines variable until $i reaches the count of machines in the variable

There is a mandatory parameter, so the syntax is:

.\Trigger-MachinePolicyEval.ps1 –CollectionName <CollectionName>

The script is below. Now, catch up on some beauty sleep!

By |2019-01-25T08:33:35+00:00February 25th, 2015|SCCM|0 Comments

About the Author:

Model Technology

Let us help you get your end point and data center strategy on cruise control!  Ask about our Calibration Assessment.

CONTACT US

  • 12125 Woodcrest Executive Drive, Ste. 204 Creve Coeur, MO 63141
  • (314) 254-4138
  • sales@model-technology.com

RECENT TWEETS