PowerShell Script

KyleEricson
Valued Contributor II

Does anyone have a simple PowerShell script to delete a device out of Jamf via device serial number? I have a Mac sh script with curl, but need this in PowerShell.

Read My Blog: https://www.ericsontech.com
1 ACCEPTED SOLUTION

koalatee
Contributor II
Invoke-RestMethod -Uri $JAMFAPIURL/computers/serialnumber/$SERIALNUMBER -Credential $Creds -Method DELETE

View solution in original post

8 REPLIES 8

tlarkin
Honored Contributor

I do not use PS for this but I would look at Invoke-RestMethod cmdlet. You should be able to use it in the same method you use curl

koalatee
Contributor II
Invoke-RestMethod -Uri $JAMFAPIURL/computers/serialnumber/$SERIALNUMBER -Credential $Creds -Method DELETE

KyleEricson
Valued Contributor II

@koalatee How are you do the creds variable I get a 403 error?
I tried $CREDS= Get-Credential
I then type in my username and password just like I was logging into the Jamf pro console.

Read My Blog: https://www.ericsontech.com

koalatee
Contributor II

Oops, I edited the line to remove a faulty quote at the end of $SERIALNUMBER

But using Get-Credential works.

KyleEricson
Valued Contributor II

@koalatee I get this error

Invoke-RestMethod : 
   Status page
Not Found
The server has not found anything matching the request URI
You can get technical details here.
Please continue your visit at our home page.
Read My Blog: https://www.ericsontech.com

KyleEricson
Valued Contributor II

my URL: https://mydomain.jamfcloud.com/JSSResource/computers/serialnumber/$SERIALNUMBER

Read My Blog: https://www.ericsontech.com

KyleEricson
Valued Contributor II

I got it figured out. Thanks

Read My Blog: https://www.ericsontech.com

Heavy_D
Contributor III

@kericson Just because I am curious and was following your post how did you finally get around it?