Automated Group Change with PowerShell

  • 21 March 2021
  • 0 replies
  • 167 views

Userlevel 5
Badge +1

This PowerShell function will help you automate putting Automox clients into Groups. I’m running this during the imaging process so I don’t have to manually move new workstations in a specific group. The example shows parent group.


Function Set-AutomoxGroup{
$key = "Your-Orgs-Key"
$num = Get-Random -Minimum 1 -Maximum 5

$group = switch ($num)
{
1 {'EUS Windows Group 1'}
2 {'EUS Windows Group 2'}
3 {'EUS Windows Group 3'}
4 {'EUS Windows Group 4'}
5 {'EUS Windows Group 5'}
Default {'EUS Windows Group 1'}
}

Start-Process "C:\Program Files (x86)\Automox\amagent.exe" -ArgumentList "--deregister" | Out-Null
& "C:\Program Files (x86)\Automox\amagent.exe" --setgrp "Default Group/Workstations/$group"
& "C:\Program Files (x86)\Automox\amagent.exe" --setkey $key"
Restart-Service amagent

Return $group
}
$grp = Set-AutomoxGroup
Write-Output"Set Automox to group $grp" -ForegroundColor Cyan

0 replies

Be the first to reply!

Reply