Skip to main content

Add device manufacturer

  • August 3, 2021
  • 1 reply
  • 105 views

Forum|alt.badge.img

When comparing Automox to competitor products, one feature I found lacking was the ability to apply policies based on device manufacturer. As many admins are already aware, Dell specifically has had a couple zero days released in recent months.

This worklet is a slight modification of the code posted by JHagstrom, and simply adds the device manufacturer as a tag so it can be targeted.

One thing I haven’t figured out is how to add the tag without removing existing tags. Be aware that this will delete any existing tags on the device.

Function Invoke-AutomoxAPI{
[cmdletbinding()]
Param()

$apiKey = "INSERT API KEY HERE"
$apiUrl = "https://console.automox.com/api/servers/"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "Bearer $apiKey")

#Get all devices in the org to parse
$response = Invoke-RestMethod $apiUrl -Method 'GET' -Headers $headers -Body $body
$response | ConvertTo-Json
$currentMachineName = $env:COMPUTERNAME;
#Perform loop to figure out what our deviceID is and populate variables
foreach($server in $response){
	$name = $server.name;	
	if($currentMachineName -eq $name){
		$id = $server.id
		$organization_id = $server.organization_id
        $server_group_id = $server.server_group_id

    	#Modify device through API
	    ## Now calling modify device API and set Manufacturer in tags
		$headers.Add("Content-Type", "application/json")
		$apiUrl = "https://console.automox.com/api/servers/$($id)?o=$($organization_id)"
				$body = "{
				    `"server_group_id`": $server_group_id,
				    `"tags`": [
				        `"$man`"
				    ]
                }"
                $body 
				$response = Invoke-RestMethod $apiUrl -Method 'PUT' -Headers $headers -Body $body
				$response | ConvertTo-Json
        }
    }
}
# Get device manufacturer, save into variable, and push to Automox
     try { 
        $man = (Get-WmiObject win32_computersystem).Manufacturer
        Invoke-AutomoxAPI
         } catch {
            Write-Output "Error"
         }

1 reply

Brittany
Forum|alt.badge.img
  • Pro
  • 40 replies
  • August 3, 2021

A post was merged into an existing topic: Worklet: Install BitLocker and store keys in device tag


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