Solved

Worklet to change Zones

  • 18 October 2023
  • 1 reply
  • 63 views

Badge

Has anyone created a Worklet that can change Zones of Windows systems?  I am not the best at PowerShell and was hoping someone has already created this. I know it can be done through the command line so assuming it can be done through PowerShell.

C:\’Program Files (x86)’\Automox\amagent.exe --setkey <ZONE KEY>

net stop amagent

net start amagent

icon

Best answer by JohnG-Automox 19 October 2023, 15:19

View original

1 reply

Userlevel 3

Good morning @Karl_Hart !

While migrating a device to another zone can be scripted via Powershell, it goes against our best practices to use this method via a Worklet as there is a high chance that it will result in a dead agent and/or a stuck command. We recommend manually issuing the --setkey command to the device to change zones:

https://help.automox.com/hc/en-us/articles/5352231166612-Moving-Devices-From-One-Zone-to-Another

 

If you wanted to perform this via Powershell, you can use the following script:

# Provide the key for your target Automox zone
$newZoneKey = ""

# Predefined amagent variables
$amagentPath = "C:\Program Files (x86)\Automox\amagent.exe"

# Set the new zone key
Start-Process $amagentPath -ArgumentList ("--setkey $newZoneKey")

# Deregister the device
Start-Process $amagentPath -ArgumentList ("--deregister")

# Stop the amagent service, sleep, and restart the service
Stop-Service -Name amagent -Force
Start-Sleep 10
Start-Service -Name amagent

 

Again, this is not a method that should be executed via a Worklet, but instead issued to the device locally or through another RMM.

 

I hope this helps. Have a great day!

Reply