Skip to main content
Solved

PowerShell Script


KyleEricson
Forum|alt.badge.img+16

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.

Best answer by koalatee

Invoke-RestMethod -Uri $JAMFAPIURL/computers/serialnumber/$SERIALNUMBER -Credential $Creds -Method DELETE
View original
Did this topic help you find an answer to your question?

8 replies

Forum|alt.badge.img+31
  • Honored Contributor
  • 2721 replies
  • October 8, 2019

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


Forum|alt.badge.img+7
  • Contributor
  • 82 replies
  • Answer
  • October 8, 2019
Invoke-RestMethod -Uri $JAMFAPIURL/computers/serialnumber/$SERIALNUMBER -Credential $Creds -Method DELETE

KyleEricson
Forum|alt.badge.img+16
  • Author
  • Valued Contributor
  • 444 replies
  • October 9, 2019

@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.


Forum|alt.badge.img+7
  • Contributor
  • 82 replies
  • October 9, 2019

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

But using Get-Credential works.


KyleEricson
Forum|alt.badge.img+16
  • Author
  • Valued Contributor
  • 444 replies
  • October 9, 2019

@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.

KyleEricson
Forum|alt.badge.img+16
  • Author
  • Valued Contributor
  • 444 replies
  • October 9, 2019

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


KyleEricson
Forum|alt.badge.img+16
  • Author
  • Valued Contributor
  • 444 replies
  • October 9, 2019

I got it figured out. Thanks


Forum|alt.badge.img+11
  • Valued Contributor
  • 135 replies
  • October 9, 2019

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


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