Posted on 11-05-2018 04:04 AM
Hi
We had a powershell script (pictured) that would Get information about Mobile Device Apps and who they were scoped to so that we could use this data else where. After one of the recent updates it has stopped working.
Does anyone have any idea as to why this would be?
Solved! Go to Solution.
Posted on 11-05-2018 07:53 AM
Maybe TLS changes (10.6? or 10.7? can't remember). Try adding this to the top of your code.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Posted on 11-05-2018 05:01 AM
It looks like you're not specifying an Accept header, while Jamf Pro is capable of returning both XML and JSON, therefore you may be receiving XML or JSON when expecting the other. I don't know powershell well enough to know which you're expecting, but I'm guessing JSON, in which case line 19 should look something like the following:
$data = Invoke-restmethod -Method Get -Uri $uri$i -Credential $cred -Headers @{"accept"="application/json"}
Posted on 11-05-2018 05:07 AM
Unfortunately the same issue. I just get our "There was a problem with" error.
Posted on 11-05-2018 05:40 AM
I would imagine you were using XML and that it's now returning JSON. Try adding:
-Headers @{"Accept"="application/xml"}
Onto the end of your $data section.
Posted on 11-05-2018 06:07 AM
Same thing annoyingly. This used to work perfectly.
Does anyone use a similar thing that works?
Posted on 11-05-2018 06:29 AM
I would start by adding some write-host outputs into your script to see what you're getting. Can you post the exact output you get when you run the script? You've confirmed that the API is accessible via a web browser etc?
Posted on 11-05-2018 06:48 AM
I normally run the below to run the script and output it to a csv file.
C:ScopedScriptsAppSyncAppSync.ps1 | Select-Object -Property DisplayName,AllJSSUsers,AllMobileDevices,LimitToUsers,Exclusions | Export-csv
I only have a csv file from when it worked which looks like the attached.
The output i get now is blank as this is all i get when i run the script.
Posted on 11-05-2018 07:46 AM
It's the path then that's probably wrong. One way you can find out is to run the script again via the ISE, and then add a line $l and start typing in the path, powershell should offer you the options and you can then find out the correct path.
Posted on 11-05-2018 07:53 AM
Maybe TLS changes (10.6? or 10.7? can't remember). Try adding this to the top of your code.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Posted on 11-05-2018 07:54 AM
@koalatee that could be it, I glossed over that line right at the top of my script!
Posted on 11-05-2018 08:00 AM
Thats the one. I would have never got that in a millions years. Thank you!!