Skip to main content
Solved

Worklet to change Zones

  • October 18, 2023
  • 1 reply
  • 166 views

Karl_Hart
Forum|alt.badge.img

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

Best answer by JohnG-Automox

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!

View original
How helpful was this post to you?

1 reply

JohnG-Automox
Forum|alt.badge.img
  • Automox Employee
  • 121 replies
  • Answer
  • October 19, 2023

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings