Powershell to get management_status

DBrowning
Valued Contributor II

Anyone know how to return the value of <user_approved_mdm since="10.4.0"> using Powershell?

I can get the info in bash using xpath, but I've tried pulling it via powershell (I've got limited knowledge) for one of our teams that only uses Windows.  

I know the value is under computer>general>management_status

<management_status>
        <enrolled_via_dep>true</enrolled_via_dep>
        <user_approved_enrollment deprecated="10.4.0">true</user_approved_enrollment>
        <user_approved_mdm since="10.4.0">true</user_approved_mdm>
      </management_status>
1 ACCEPTED SOLUTION

DBrowning
Valued Contributor II

Was able to figure this out.  

View solution in original post

7 REPLIES 7

AJPinto
Valued Contributor II

Not to be a jerk, but honestly just provide the bash script and move on. You are managing Macs, not PCs. Bash (ZSH) is native to macOS/Unix, not PowerShell. If they need this information so badly to be in PowerShell let them figure out how to collect it.

 

If they want a more universal language, bash can be installed on Windows as can Python.

DBrowning
Valued Contributor II

Yeah I can't really do that when its my VP asking for reports.  I like my job.

AJPinto
Valued Contributor II

Sometimes we have to remind people that macOS is not Windows, and cannot be managed or reported on like Windows. We find ourself often of times needing to educate those who are not familiar, and give correct solutions for the macOS environment. This is a common situation I run in to myself. 

 

JAMF grabs User Approved MDM status natively. A smart group or smart search could be created, and used to export this information in .csv (smart search can schedule reporting). Also JAMF API could be used if they want this in more of an on demand fashion. 

 

 

DBrowning
Valued Contributor II

We are using API for his report.  I think the issue i'm having is the key <user_approved_mdm since="10.4.0"> the " since="10.4.0"" part is screwing everything up.  Because I can easily get the first key <enrolled_via_dep> without issue.  Just need someone with PS knowledge to let me know how I can pull that item.

boberito
Valued Contributor

I believe Powershell plays a lot nicer with json. You could get a json output from the API.

@boberito is right. The Classic API JSON bug won't bite you if you are only going after management status so JSON is the way to go. There's a lot of help online for JSON with PowerShell. As programmers have been saying about JSON for quite a while now, "at least it's not XML".

If the user just wants a report then do an Advanced Computer Search, save it and email it to them on a regular basis. That's the one part of Jamf Pro - email integration that works really well. It's entirely set and forget.

DBrowning
Valued Contributor II

Was able to figure this out.