-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathGet-Profile.ps1
59 lines (51 loc) · 1.98 KB
/
Get-Profile.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<#
.SYNOPSIS
Gets Profiles with optional query parameters to limit results.
.DESCRIPTION
Gets Profiles with optional query parameters to limit results.
.PARAMETER query
Optional query parameters to refine search. For values, refer to API documentation. https://as135.awmdm.com/api/help/#!/apis/10003?!/ProfilesV2/ProfilesV2_Search
Multiple parameters should be joined with "&"
.INPUTS
AirWatchConfig.json
CSV File with headers
.OUTPUTS
Outputs a CSV: "Profiles[today's date].csv"
.NOTES
Version: 1.4
Author: Joshua Clark @MrTechGadget
Creation Date: 01/09/2021
Update Date: 10/14/2023
Site: https://github.com/MrTechGadget/aw-bulkdevices-script
.EXAMPLE
.\Get-Profile.ps1 -query "status=Active&platform=Apple"
#>
[CmdletBinding()]
Param(
[Parameter(HelpMessage="Optional query parameters to refine search. For values, refer to API documentation. https://as135.awmdm.com/api/help/#!/apis/10003?!/ProfilesV2/ProfilesV2_Search")]
[string]$query
)
Import-Module .\PSairwatch.psm1
Write-Log -logstring "$($MyInvocation.Line)"
$Logfile = "$PSScriptRoot\Profiles.log"
Write-Log -logstring "$($MyInvocation.Line)" -logfile $Logfile
Write-Log -logstring "Getting Profiles in AirWatch" -logfile $Logfile
$date = Get-Date -Format yyyyMMdd
if ($query) {
$endpointURL = "mdm/profiles/search?$query&PageSize=500"
} else {
$endpointURL = "mdm/profiles/search"
}
$results = Send-Get -endpoint $endpointURL -version "application/json;version=2"
try {
if ($results.ProfileList) {
Write-Log -logstring "$($results.ProfileList.Length) Profiles returned out of $($results.TotalResults) total, writing csv." -logfile $Logfile
Write-Host "$($results.ProfileList.Length) Profiles returned out of $($results.TotalResults) total, writing csv."
$results.ProfileList | Export-Csv -Path "Profiles${query}.csv"
} else {
Write-Log -logstring "No Results" -logfile $Logfile
}
}
catch {
Write-Log -logstring "Error (maybe no results) $_" -logfile $Logfile
}