-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathApplicationReport.ps1
More file actions
248 lines (236 loc) · 7.68 KB
/
Copy pathApplicationReport.ps1
File metadata and controls
248 lines (236 loc) · 7.68 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<#
.SYNOPSIS
Generates a report of All active Applications and their associated assignment groups
.DESCRIPTION
Useful for generating a report of application ownership roles, saves results in a csv file
.EXAMPLE
ApplicationReport -oOrg prod
This command runs a report against the org defined
as 'prod' the result of the report is {org}_ApplicationReport_{YYYYMMDD}.csv
.LINK
https://github.com/mbegan/Okta-Scripts
https://support.okta.com/help/community
http://developer.okta.com/docs/api/getting_started/design_principles.html
#>
Param
(
[Parameter(Mandatory=$false)]
[alias('org','OktaOrg')]
[string]$oOrg=$oktaDefOrg,
[Parameter(Mandatory=$false)]
[ValidateLength(20,20)]
[alias('aid','appid')]
[string]$ApplicationID,
[Parameter(Mandatory=$false)]
[ValidateLength(1,255)]
[alias('appname')]
[string]$ApplicationName="amazon_aws_sso"
)
Import-Module Okta
if (!(Get-Module Okta))
{
throw 'Okta module not loaded...'
}
#preseve value
$curVerbosity = $oktaVerbose
if ( [System.Management.Automation.ActionPreference]::SilentlyContinue -ne $VerbosePreference )
{
$oktaVerbose = $true
} else {
$oktaVerbose = $false
}
#Get all the Apps within the org
if ($ApplicationID)
{
$apps = oktaGetAppbyId -oOrg $oOrg -aid $ApplicationID
} else {
$apps = oktaGetActiveApps -oOrg $oOrg
}
function AppDetails()
{
param
(
$app
)
switch -Exact ($app.signOnMode)
{
'BOOKMARK'
{
return $app.settings.app.url
}
'BROWSER_PLUGIN'
{
#nothing distinguishable
return $null
}
'AUTO_LOGIN'
{
#nothing distinguishable
return $null
}
'SAML_1_1'
{
#probably specific to O365
return $app.settings.app.domain
}
'WS_FEDERATION'
{
return $app.settings.app.wReplyURL
break
}
'SAML_2_0'
{
switch -Exact ($app.name)
{
'template_saml_2_0'
{
return $app.settings.app.destination
}
'salesforce'
{
return ( $app.settings.app.instanceType + " :: " + $app.settings.app.loginUrl)
}
'newrelic'
{
return $app.settings.app.loginUrl
}
#'successfactors' 'servicenow'
{ (($_ -eq 'successfactors') -or ($_ -eq 'servicenow')) }
{
return $app.settings.app.loginURL
}
'bigmachines'
{
return $app.settings.app.siteURL
}
'jira_onprem'
{
return $app.settings.app.baseURL
}
'concur'
{
#nothing distinguishable?
return $null
}
'teachscape'
{
return $app.settings.app.companyName
}
'docusign'
{
return $app.settings.app.instanceType
}
'accellion'
{
return $app.settings.app.subDomain
}
'amazon_aws'
{
return $app.settings.app.identityProviderArn
}
'github_enterprise'
{
return $app.settings.app.githubUrl
}
'opendns'
{
#nothing distinguishable?
return $null
}
default
{
if ($app.settings.signOn.destination -like '*') { return $app.settings.signOn.destination }
elseif ($app.settings.app.loginURL -like '*') { return $app.settings.app.loginURL }
elseif ($app.settings.app.loginUrl -like '*') { return $app.settings.app.loginUrl }
elseif ($app.settings.app.siteUrl -like '*') { return $app.settings.app.siteUrl }
elseif ($app.settings.app.siteURL -like '*') { return $app.settings.app.siteURL }
elseif ($app.settings.app.baseUrl -like '*') { return $app.settings.app.baseUrl }
elseif ($app.settings.app.baseURL -like '*') { return $app.settings.app.baseURL }
else
{
#Write-Host $app.id : $app.label : $app.name : zyzz
#$app.settings | ConvertTo-Json
return $null
}
}
}
break
}
default
{
if ('active_directory' -eq $app.name)
{
#Write-Host $app.id : $app.label : $app.settings.app.namingContext
return $app.settings.app.namingContext
}
return $null
}
}
}
$col1 = New-Object System.Collections.ArrayList
foreach ($app in $apps)
{
#fetch the groups that are used to assign the app to users
$appgroups = oktaGetAppGroups -oOrg $oOrg -AppId $app.id
if ($appgroups)
{
foreach($group in $appgroups)
{
try
{
#fetch the details of the group
$oktagroup = oktaGetGroupbyId -oOrg $oOrg -groupId $group.id
}
catch
{
Write-Error "group didn't exist?"
}
$params = @{ Application = $app
Priority = $group.priority
Updated = $group.lastUpdated
Group = $oktagroup
}
$_c = $col1.add($params)
}
} else {
$params = @{ Application = $app
Priority = 0
Updated = $null
Group = $false
}
$_c = $col1.add($params)
}
}
$col2 = new-object System.Collections.ArrayList
foreach ($c in $col1)
{
$param = @{ AppID = $c.Application.id
Application = $c.Application.name
AssignmentPriority = $c.Priority
Description = $c.Application.label
appSignOnMOde = $c.Application.signOnMode
appUserNameTemplate = $c.Application.credentials.userNameTemplate.template
appVpnNotification = $c.Application.settings.notifications.vpn.network.connection
appHideWeb = $c.Application.visibility.hide.web
appHideMobile = $c.Application.visibility.hide.iOS
appDetail = (AppDetails -app $c.Application)
GroupClass = $null
GroupName = 'NoGroup'
GroupDesc = $null
GroupID = $null
}
if ($c.Group)
{
$param.GroupClass = $c.Group.ObjectClass[0]
$param.GroupName = $C.Group.profile.name
$param.GroupDesc = $C.Group.profile.description
$param.GroupID = $C.Group.id
}
$row = New-Object psobject -Property $param
$_c = $col2.add($row)
}
$fstamp = (Get-Date).ToString(“yyyyMMdd")
$file = $oOrg + "_ApplicationReport_" + $fstamp + '.csv'
$col2 | Select AppID,Application,AssignmentPriority,Description,appSignOnMOde,appUserNameTemplate,`
appVpnNotification,appHideWeb,appHideMobile,appDetail,GroupID,GroupName,GroupClass,GroupDesc `
| Export-Csv -Path ($file) -NoTypeInformation