forked from AutomoxCommunity/Templates_And_Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AutomoxPoliciesReport.ps1
66 lines (56 loc) · 2.42 KB
/
AutomoxPoliciesReport.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
58
59
60
61
62
63
64
65
66
#Automox Policies Report
#Run with Powershell
#The CSV report will be created in the Users Documents folder
#API Request Variables
######################################################
#####Update the $apiKey with your API KEY created from the Automox Portal####
$apiKey = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
$clientID = "XXXX"
#####Only update the two Variables in this block######
######################################################
#Api Request
$headers = @{ "Authorization" = "Bearer $apiKey" }
$uri = "https://console.automox.com/api/policies?o=$clientID"
$responses = (Invoke-WebRequest -Method Get -Uri $uri -Headers $headers).Content | ConvertFrom-Json
#ReportVariables
$Output = @()
$UserPath = "$env:UserProfile"
$date = Get-Date -UFormat %m.%d.%Y
$OutputPath = "$UserPath\Documents\AutomoxPoliciesReport.$date.csv"
#Create Report
$responses | % {
$SingleItem = $_
$id = $SingleItem | Select -ExpandProperty 'id'
$name = $SingleItem | Select -ExpandProperty 'name'
$policy_type_name = $SingleItem | Select -ExpandProperty 'policy_type_name'
$organization_id = $SingleItem | Select -ExpandProperty 'organization_id'
$configuration = $SingleItem | Select -ExpandProperty 'configuration'
$schedule_days = $SingleItem | Select -ExpandProperty 'schedule_days'
$schedule_weeks_of_month = $SingleItem | Select -ExpandProperty 'schedule_weeks_of_month'
$schedule_months = $SingleItem | Select -ExpandProperty 'schedule_months'
$schedule_time = $SingleItem | Select -ExpandProperty 'schedule_time'
$next_remediation = $SingleItem | Select -ExpandProperty 'next_remediation'
$notes = $SingleItem | Select -ExpandProperty 'notes'
$create_time = $SingleItem | Select -ExpandProperty 'create_time'
$server_groups = $SingleItem | Select -ExpandProperty 'server_groups'
$server_count = $SingleItem | Select -ExpandProperty 'server_count'
$AllAddress = New-Object PSObject -Property @{
id = "$id"
name = "$name"
policy_type_name = "$policy_type_name"
organization_id = "$organization_id"
configuration = "$configuration"
schedule_days = "$schedule_days"
schedule_weeks_of_month = "$schedule_weeks_of_month"
schedule_months = "$schedule_months"
schedule_time = "$schedule_time"
next_remediation = "$next_remediation"
notes = "$notes"
create_time = "$create_time"
server_groups = "$server_groups"
server_count = "$server_count"
}
$output += $AllAddress
}
#Export Report
$output | Export-CSV $OutputPath -nti