Skip to main content

CWM - Automate - Script -Automate Agent - InstallRepair - For GPO Globals

Summary

The purpose of this script is to create a PowerShell script to be used along with the Automate agent deployment GPO. It will also keep the PowerShell script up-to-date with a new Installation Token.

The generated PowerShell script will install the agent if it is missing, attempt to repair the agent if it is broken, and rip and replace the agent if another MSP's agent is installed.

Intended Target: Domain Controllers with Automate agent deployment GPO

Sample Run

Sample Run

Implementation

Step 1: Create a computer-level EDF "Automate Agent Deployment GPO Enabled."

Step 1

Step 2: Create an Auto-Join Group for the machines where the EDF is checked.

Step 3: Schedule the script to run once per day against the group.

Step 3

Step 4: Mark the EDF of the Domain Controllers where you would like to create the Agent Deployment GPO.

Variables

NameDescription
TargetLocationIDLocation ID to create the Installer Token for. Will use the location ID of the computer.
ValidityPeriodAge limit for the Installer. 1 Day
InstallerTypeIDID of the installer type. 1 represents an .msi agent installer
TokenReasonReason behind creating the installer token.
TokenIngredientsRequired variables/values to create the Agent token.
VerificationKeyVerification Key for the Agent Installer Token.
OutComeOutput of the PowerShell script used to write/modify the agent installation ps1 file.
InstallerTokenInstaller Token generated to be used with the agent reinstall command.

Global Parameters

NameExampleRequiredDescription
DirectoryC:/ProgramData/_Automation/Automate AgentTruePath to create the .ps1 script
FileNameRedo-Agent.ps1TrueName of the .ps1 script

Script States

NameExampleDescription
GPO Agent Tokenf9e7246ae89145e98cd8376d93e247aaUsed to store the currently generated agent token, so that it can be removed before generating another token

Process

  • Remove the previously generated token for the computer from the installertokens table.
  • Clear the 'GPO Agent Token' script state.
  • Create the @Directory@ if it does not exist.
  • Generate an Agent Installer Token.
  • Store the token to the Script State.
  • Generate the PowerShell script on the computer.
  • Verify the presence of the @InstallerToken@ in the script.
  • Log the outcome.

Output

  • Script State
  • Script Log
  • Local File on the computer (C:/ProgramData/_Automation/Automate Agent/Redo-Agent.ps1)

Creating Automate Agent Deployment GPO

Attachments

Automate_Agent_Deployment_GPO.pdf