-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathraindance.ps1
700 lines (623 loc) · 24 KB
/
raindance.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
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
<#
.Synopsis
Intelligence Gathering tool for Office 365 & Microsoft Exchange
.Description
Authenticate to an O365/MSExchange user to perform intelligence
gathering on the domain from the user-context using some snazzy,
hopefully user-friendly cmdlets, or via the menu wizard.
.Example
# Print Help Message & Usage
Rain-Help
.Example
# List available cmdlets
Rain-Help
#>
function Get-Banner{
$BANNER= @"
\ _( )_ \ \ _( )_ \ \
_( )_ _( )_ ( ) \ \
(_________) \ _( )_(_ _)
\ \ \ (_________)________) \ \ \
\ \ \ \ \ \(__________) \
\ \ \ \ \ \ \ \ \
\ . \ \ \ \ \ \ \
\ \_O/ \ \ , \ \ \ \
\ \ \ \ / \ \O_
/\_ \ \_\ ,/\/ \
\ , \ \ \ / \ \
___ \ __ /O\ \ \ \
| _ \ __ _(_)_ __ | _ \ __ _ _ __ ___ ___
| |_) / _ | | '_ \| | | |/ _ | '_ \ / __/ _ \
| _ < (_| | | | | | |_| | (_| | | | | (_| __/
|_| \_\__,_|_|_| |_|____/ \__,_|_| |_|\___\___|
- Office 365 Info-Gathering Toolkit
PRO-TIP: Use 'Rain-help' for a list of commands
UBER PRO-TIP: Rain-Debug will list variables and additional cmdlets for more advanced users
"@
Write-Output $BANNER
}
function Load-Modules {
if ($PSVersionTable.PSVersion.Major -lt 5){
Write-Host("*********************************************")
Write-Host("[-] Minimum PowerShell Version of 5.0 not met.")
Exit
}
$OS=[System.Environment]::OSVersion.Platform
if ($OS -like "*nix*"){
Write-Host("Microsoft currently does not support the necessary libraries (MSOnline & AzureAD) on Linux. n
Sorry but you'll have to use Windows... :(")
Read-Host -Prompt "Press enter to exit..."
Exit-PSSession
}
if (!(Get-Module -ListAvailable -Name MSOnline)){
Write-Output("This tool requires MSOnline PS-module to be installed. Installing...")
try {
Install-Module MSOnline
}
catch
{
Write-Output("Error, unable to install MSOnline. Try running Powershell as administrator and executing the following...")
Write-Output("Install-Module PackageManagement -Force")
Write-Output("Install-Module MSOnline")
Read-Host -prompt 'Hit "Enter" to exit...'
Exit-PSSession
}
}
if (!(Get-Module -ListAvailable -Name AzureAD)){
Write-Output("This tool requires AzureAD PS-Module to be installed. Installing...")
try {
Install-Module AzureAD
}
catch
{
Write-Output("Error, unable to install AzureAD. Try running Powershell as administrator and executing the following...")
Write-Output("Install-Module AzureAD")
Read-Host -prompt 'Hit "Enter" to exit...'
Exit-PSSession
}
}
Import-Module MSOnline
Import-Module AzureAD
}
function check-import{
if(!(Get-Module -Name raindance)){
Write-Host "[!]Do not execute as a script! "
Write-Host "-> Start this tool with 'Import-Module .\raindance.ps1'"
Read-Host -prompt "Press enter to continue..."
Exit-PSSession
}
}
function Rain-Help{
$help_text = @"
--------------_LOG IN_--------------
[*] Use this command first to begin your magical journey into the land of Office :D
Rain-Login | Log into Office365, AzureAD & Exchange
-----------_GET COMMANDS_-----------
[*] These commands gather data and store it in memory to be recalled later by the show commands
==> Use the "-verbose" option to return ALL output, including empty/useless stuff
==> BE PATIENT! These commands take a while to complete. The more info, the longer it takes.
==> Wait a few minutes and hit space if the console appears to hang. It's just thinking ;)
Rain-GetAll | Get all user, group, role, & admin information at once (Takes a long time)
Rain-GetUsers | Get all user information (MUST BE RUN FIRST)"
Rain-GetDevices| Get all active devices on the AzureAD Domain with currently logged in sessions
Rain-GetRoles | Get all user roles (O365 permissions) details (MUST BE RUN SECOND)
Rain-GetGroup | Get all distribution/security group details
Rain-GetGroupMembers | Get all members of distribution groups (MUST HAVE RUN Rain-GetGroup)
Rain-GetAdmins | Get all administrative users
-----------_SHOW COMMANDS_-----------
[*] These commands show the data you've gathered up. Very quick, very clean. :)
Rain-Show <object> | Show gathered information currently in memory. Options below.
|
|-> Users
|-> Devices
|-> Roles
|-> Groups
|-> GroupMembers
|-> Admins
|-> GlobalAdmins
Example: 'Rain-Show Admins'
-----------_DUMP COMMANDS_------------
[*] Dump currently gathered information to a csv file(s) or txt file.
==> DumpAll to txt format will dump all information to a SINGLE, formatted file.
==> DumpAll CSV will create 1 csv file per list (user.csv, admins.csv, etc)
Rain-DumpAll <path> <type> | Dumps all gathered information to csv (default) or txt formatted files. (Files are auto-named)
Rain-DumpUsers <filepath> <type> | Dumps all user information to csv (default) or txt formatted files
Rain-DumpDevices <filepath> <type>| Dumps all gathered device sessions to csv (default) or txt formatted files.
Rain-DumpRoles <filepath> <type> | Dumps all role information to csv (default) or txt formatted files
Rain-DumpAdmins <filepath <type> | Dumps all administrator (and global admins) to csv (default) or txt formatted files
Rain-DumpGroups <filepath> <type> | Dumps all security & distribution groups to csv (default) or txt formatted files
-----------_OTHER COMMANDS_------------
[*] Commands that divulge other information about the domain
Rain-Company | Get information about the organization along with some policy information (alias for Get-MsolCompanyInformation)
"@
Write-Host $help_text
}
function Rain-Debug{
$debug_text = @"
---------_VARIABLES AVAILABLE_---------
Feel free to manipulate these variables to get more verbose output once they have been instantiated.
Please note, these are global variables, and must be re-declared any time values are re-assigned.
O_USERS - Return output of users gathered by Rain-GetUsers
O_ROLES - Return output of roles gathered by Rain-GetRoles
O_GROUPS - Return output of mailing groups gathered by Rain-GetGroups
O_ADMINS - Return output of administrators (not global admin) gathered by Rain-GetAdmins
O_GADMINS - Return output of global administrators gathered by Rain-GetAdmins
"@
}
function Rain-Login{
<#
.Description
Log into MS Online (O365/Exchange) Services
.Example
Rain-Login -user [email protected]
Enter target password: **************
[+] Successfully Logged In
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory=$False)]
[string]$user
)
Write-Host '****** Welcome to RainDance! ******'
Write-Verbose 'Attempting to Authenticate...'
if(!$user){
$user = Read-Host -Prompt "Enter your target username"
}
$password = Read-Host -Prompt "Enter target password" -AsSecureString
$creds = New-Object -typename System.Management.Automation.PSCredential -argumentlist $user, $password
$password = $NULL
Write-Host "[*] ATTEMPTING TO GET PSSESSION WITH EXCHANGE"
try{
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $creds -Authentication Basic -AllowRedirection
Import-PSSession $Session
Write-Host "[+] Success! You have access to exchange online mail!"
}
catch [System.Exception]{
Write-Host "[-] Login to Exchange Online failed. Either the user does not have access or is not licensed for Outlook"
}
Write-Host "[*] ATTEMPTING O365 LOGIN!"
try{
Connect-MsolService -Credential $creds -ErrorAction Stop
$Global:LOGGED_IN_USER = $user
Write-Host "[+] Successfully Logged In!"
Write-Host "[*] Gathering general domain info..."
$Global:O_DOMAINS = @(Get-MSOLDomain | Select-Object $_.Name)
$Global:Licenses = Get-MsolSubscription
$current_user_role = Get-MsolUserRole -UserPrincipalName $user
if(!($current_user_role)){
Write-Host "[-] Your current user has no administrative permissions."
}
else{
Write-Host "[+] Your current user has the following administrative privileges!"
Write-Output $current_user_role
}
Write-Host "[*] You currently have access to the following domains:"
Write-Output $O_DOMAINS.Name
Write-Host "[*] This company currently has the following products in use... n"
Write-Output $Licenses.SkuPartNumber
}
catch [System.Exception] {
Write-Host "O365 - Authentication Error!"
Write-Host "2FA may be enforced, or powershell is disabled for this user."
Write-Host "To be sure, use Connect-MsolService manually from powershell."
Write-Host "If successful, set $Global:LOGGED_IN_USER = '[email protected]' to continue."
}
Write-Host "---------------------------------------------------------- n"
try{
Write-Host "[*] ATTEMPTING AZURE ACTIVE DIRECTORY LOGIN!"
Connect-AzureAD -Credential $creds -ErrorAction Continue
Write-Host "[+] Successfully authenticated to Azure!"
}
catch {
Write-Host "Unable to Log into Azure AD. Either it is not provisioned, or you do not have access."
}
return Get-Header
}
function check-login{
if ($LOGGED_IN_USER -eq $NULL){
Write-Host "[-] Woah cowboy. You gotta login first."
return $False
}
else{
return $True
}
}
function Rain-GetUsers(){
[CmdletBinding()]
param
(
[Parameter(Mandatory=$False)]
[Switch]$All,
[Int]$MaxResults
)
if(!(check-login)){Break}
Write-Host "[+] Gathering Usernames and details..."
$users = @()
Get-MSOLUser @psBoundParameters | ForEach-Object {
if ($_.IsLicensed -eq $True){
$item = [Ordered]@{
Username=$_.UserPrincipalName
Name=$_.DisplayName
SignIn=$_.SignInName
Department=$_.Department
Title=$_.Title
Phone=$_.PhoneNumber
Mobile=$_.MobilePhone
Office=$_.Office
City=$_.City
State=$_.State
Location=$_.UsageLocation
LastPasswordChange=$_.LastPasswordChangeTimestamp
LastDirSync=$_.LastDirSyncTime
ObjectId=$_.ObjectId
}
$users += New-Object PSObject -Property $item
if ($users.length % 100 -eq 0){
Write-Host "[+] $($users.length) Users Collected"
}
if ($users.length -gt 1000){
Write-Host "[*] More than 1000 users have been found so far. This may take a while. Don't stop the script, even if it appears to hang"
}
}
}
$Global:O_USERS = $users
Write-Host "[+] User collection complete. $($users.length) total users collected. Use 'Rain-Show Users' command to view data."
if($verbose){
return $users
}
}
function Rain-DumpUsers{
param(
[Parameter(Mandatory=$True, ValueFromPipeline=$True, position=1)]
[string]$outfile,
[Parameter(Mandatory=$False,ValueFromPipeline=$True, position=2)]
[ValidateSet("csv","txt")]
[string]$format = 'csv'
)
if($format -eq "csv"){
$O_USERS | Sort-Object -Property Username | Export-Csv -path $outfile -NoTypeInformation
}
if($format -eq "txt"){
$O_USERS | Sort-Object -Property Username | Format-Table > $outfile
}
}
function Rain-GetRoles{
if(!(check-login)){Break}
Write-Host "[+] Gathering User Roles & Members..."
$roles = @()
Get-MSOLRole | ForEach-Object {
if($_.IsEnabled){
if($_.Name.contains("Admin")){
$item = [Ordered]@{
Name=$($_.Name)
ObjectId=$($_.ObjectID)
Description=$($_.Description)
IsAdmin=$True
}
$roles += New-Object PSObject -Property $item
}
else{
$item = [Ordered]@{
Name=$($_.Name)
ObjectId=$($_.ObjectID)
Description=$($_.Description)
IsAdmin=$False
}
$roles += New-Object PSObject -Property $item
}
}
}
if($O_ROLES.length -eq 0){
$Global:O_ROLES = $roles
}
Write-Host "[+] Role collection complete. Use 'Rain-Show Roles' command to view data."
if($verbose){
return $roles
}
}
function Rain-DumpRoles{
param(
[Parameter(Mandatory=$True, ValueFromPipeline=$True, position=1)]
[string]$outfile,
[Parameter(Mandatory=$False,ValueFromPipeline=$True, position=2)]
[ValidateSet("csv","txt")]
[string]$format = 'csv'
)
if($format -eq "csv"){
$O_ROLES | Sort-Object -Property Username | Export-Csv -path $outfile -NoTypeInformation
}
if($format -eq "txt"){
$O_ROLES | Sort-Object -Property Username | Format-Table > $outfile
}
}
function Rain-GetAdmins(){
if(!(check-login)){Break}
Write-Host "[+] Gathering Administrator Accounts..."
$admins = @()
$Global_admins = @()
$admin_roles = $O_ROLES | Where-Object{$_.IsAdmin -eq $True}
foreach($admin_role in $admin_roles){
if($admin_role.Name -eq "Company Administrator"){
$Global_admins += Get-MsolRoleMember -All -RoleObjectID $admin_role.ObjectId
}
else{
$admins += Get-MsolRoleMember -All -RoleObjectId $admin_role.ObjectId
}
Write-Host "================$($admin_role.Name)================"
Write-Output $(Get-MSOLRoleMember -RoleObjectID $admin_role.ObjectId)
}
$Global:O_ADMINS = $admins
$Global:O_GADMINS = $Global_admins
Write-Host "[+] Admins collection Complete. Use 'Rain-Show Admins' or 'Rain-Show GlobalAdmins' command to view data."
if($verbose){
return $admins
return $Global_admins
}
}
function Rain-DumpAdmins{
param(
[Parameter(Mandatory=$True, ValueFromPipeline=$True, position=1)]
[string]$outfile,
[Parameter(Mandatory=$False,ValueFromPipeline=$True, position=2)]
[ValidateSet("csv","txt")]
[string]$format = 'csv'
)
if($format -eq "csv"){
$O_ADMINS | Sort-Object -Property Username | Export-Csv -path $outfile -NoTypeInformation
}
if($format -eq "txt"){
$O_ADMINS | Sort-Object -Property Username | Format-Table > $outfile
}
}
function Rain-GetGroup{
if(!(check-login)){Break}
Write-Host "[+] Gathering Mailing & Distribution Groups..."
$groups = Get-MsolGroup -All
if($O_GROUPS.length -eq 0){
$Global:O_GROUPS = $groups
}
Write-Host "[+] Group collection Complete. Use 'Rain-Show Groups' command to view data."
if($verbose){
return $groups
}
}
function Rain-DumpGroups{
param(
[Parameter(Mandatory=$True, ValueFromPipeline=$True, position=1)]
[string]$outfile,
[Parameter(Mandatory=$False,ValueFromPipeline=$True, position=2)]
[ValidateSet("csv","txt")]
[string]$format = 'csv'
)
if($format -eq "csv"){
$O_GROUPS | Sort-Object -Property Username | Export-Csv -path $outfile -NoTypeInformation
}
if($format -eq "txt"){
$O_GROUPS | Sort-Object -Property Username | Format-Table > $outfile
}
}
function Rain-GetGroupMembers{
if(!($O_Groups)){Write-Host "[-] Groups have not been gathered yet! Run Rain-GetGroup first."}
else{
Write-Host "[+] Gathering Group Members..."
$group_member_list = @()
foreach($group in $O_GROUPS){
$g = Get-MsolGroupMember -GroupObjectId $group.ObjectId
$group_info = [ordered]@{
GroupName=$($group.DisplayName)
Users=$($g)
}
$group_member_list += New-Object PSObject -property $group_info
}
$Global:O_GROUPMEMBERS = $group_member_list
Write-Host {"[+] Group Member collection Complete. Use 'Rain-Show GroupMembers' command to view data."}
if($verbose){
return $group_member_list
}
}
}
function Rain-GetDevices{
if(!(check-login)){break}
Write-Host "[+] Gathering active devices..."
$device_list = @()
$azure_devices = Get-AzureADDevice
foreach($device in $azure_devices){
$owner = Get-AzureADDeviceRegisteredOwner -ObjectId $device.ObjectId
$item = [Ordered]@{
Hostname=$($device.DisplayName)
OS=$($device.DeviceOSType)
Version=$($device.DeviceOSVersion)
Trust=$($device.DeviceTrustType)
ObjectId=$($device.ObjectId)
Owner=$($owner.DisplayName)
Username=$($owner.UserPrincipalName)
}
$device_list += New-Object PSObject -Property $item
}
$Global:O_DEVICES = $device_list
if($verbose){
return $devices_list
}
}
function Rain-DumpDevices{
param(
[Parameter(Mandatory=$True, ValueFromPipeline=$True, position=1)]
[string]$outfile,
[Parameter(Mandatory=$False,ValueFromPipeline=$True, position=2)]
[ValidateSet("csv","txt")]
[string]$format = 'csv'
)
if($format -eq "csv"){
$O_DEVICES | Sort-Object -Property Hostname | Export-Csv -path $outfile -NoTypeInformation
}
if($format -eq "txt"){
$O_DEVICES | Sort-Object -Property Hostname | Format-Table > $outfile
}
}
function Rain-GetAll{
if(!(check-login)){Break}
Write-Host("Gathering ALL of the Rain!")
if($verbose){
Rain-GetUsers -verbose
Rain-GetDevices -verbose
Rain-GetRoles -verbose
Rain-GetAdmins -verbose
Rain-GetGroup -verbose
Rain-GetGroupMembers -verbose
}
Rain-GetUsers
Rain-GetDevices
Rain-GetRoles
Rain-GetAdmins
Rain-GetGroup
Rain-GetGroupMembers
}
function Rain-Show{
param(
[Parameter (Mandatory=$True, ValueFromPipeline=$True, Position=1)]
[ValidateSet("Users","Devices","Roles","Groups","GroupMembers","Admins","GlobalAdmins")]
[string]$type,
[string]$search
)
if($type -eq "Users"){
if($O_USERS -eq $NULL){
Write-Host "No Users gathered yet..."
Break
}
$O_USERS | Sort-Object -Property Username | Format-Table
}
elseif($type -eq "Roles"){
if($O_ROLES -eq $NULL){
Write-Host "No Roles gathered yet..."
Break
}
$O_ROLES | Sort-Object -Property Username | Format-Table
}
elseif($type -eq "Groups"){
if($O_GROUPS -eq $NULL){
Write-Host "No Groups gathered yet..."
Break
}
$O_GROUPS | Sort-Object -Property Username | Format-Table
}
elseif($type -eq "GroupMembers"){
if($O_GROUPMEMBERS -eq $NULL){
Write-Host "No Group Members gathered yet..."
Break
}
$search = Read-Host -prompt "Enter group to list members of... [blank = ALL GROUPS]"
if($search -eq $NULL){
$O_GROUPMEMBERS | Sort-Object -Property GroupName
}
else{
$selection = $O_GROUPMEMBERS | Select-Object * | Where-Object {$_.GroupName -like "*$($search)*"}
foreach($group in $selection){
"==============$($group.GroupName)=============="
$group.Users | Sort-Object -Property DisplayName | Format-Table
}
}
}
elseif($type -eq "Admins"){
if($O_ADMINS -eq $NULL){
Write-Host "No Admins gathered yet..."
Break
}
$O_ADMINS | Sort-Object -Property Username | Format-Table
}
elseif($type -eq "GlobalAdmins"){
if($O_GADMINS -eq $NULL){
Write-Host "No Global Admins gathered yet..."
Break
}
$O_GADMINS | Sort-Object -Property Username | Format-Table
}
elseif($type -eq "Devices"){
if($O_DEVICES -eq $NULL){
Write-Host "No devices have been gathered yet or no active sessions exist..."
break
}
$O_DEVICES | Sort-Object -Property Hostname | Format-Table
}
else{
Write-Host "Use one of the following types: Users, Roles, Groups, Admins"
}
}
function Rain-DumpAll{
[CmdletBinding()]
param
(
[Parameter(Mandatory=$True, ValueFromPipeline=$True, position=1,
HelpMessage="Enter a path to drop files into")]
[string]$path,
[Parameter(Mandatory=$False, ValueFromPipeline=$True, position=2,
HelpMessage="Format of output file (csv or txt)")]
[string]$format = 'csv'
)
if(!(test-path $path)){
New-Item -ItemType Directory -Force -Path $path | Out-Null
}
if($format -eq 'txt'){
$outfile = [io.path]::combine($path, "Rain_dump.txt")
"========================+USERS+========================" > $outfile
$O_USERS | Sort-Object -Property Username | Format-Table >> $outfile
"=======================+DEVICES+=======================" >> $outfile
$O_DEVICES | Sort-Object -Property Hostname | Format-Table >> $outfile
"========================+ROLES+========================" >> $outfile
$O_ROLES | Sort-Object -Property Username | Format-Table >> $outfile
"========================+GROUPS+=======================" >> $outfile
$O_GROUPS | Sort-Object -Property Username | Format-Table >> $outfile
"====================+GLOBAL ADMINS+====================" >> $outfile
$O_GADMINS | Sort-Object -Property Username | Format-Table >> $outfile
}
else{
$prefix = "Rain_"
$userfile = $prefix + "users.csv"
$rolefile = $prefix + "roles.csv"
$groupfile = $prefix + "groups.csv"
$adminfile = $prefix + "admins.csv"
$fullpaths = @($userfile, $rolefile, $groupfile, $adminfile)
foreach($i in $fullpaths){
$full = [io.path]::combine($path, $i)
if($i -like "*user*"){Rain-DumpUsers $full $format}
elseif($i -like "*role*"){Rain-DumpRoles $full $format}
elseif($i -like "*group*"){Rain-DumpGroups $full $format}
elseif($i -like "*admin*"){Rain-DumpAdmins $full $format}
}
}
Write-Host {"[+] ---COMPLETE---"}
}
function Rain-Company{
if(!($COMPANY)){
$Global:COMPANY = Get-MsolCompanyInformation
}
return $COMPANY
}
# Shows logged in user and domain information
function Get-Header{
Write-Host ('============================= Welcome to Rain Dance =============================')
if($LOGGED_IN_USER){
Write-Output $("Current Domain: {0} | Alternate domains: {1}" -f $O_DOMAINS[0].Name, ($O_DOMAINS.Length - 1))
Rain-Company
}
else{
Write-Output "Not logged in. Run Rain-Login to get started."
}
}
# Declare Main Variables as global (I'm sorry...powershell forces me to do horrible things :C )
function Rain-Main{
Load-Modules
$Global:LOGGED_IN_USER = $NULL
$Global:O_Groups = $NULL
$Global:O_DOMAINS = @()
$Global:O_ADMINS = @()
$Global:O_GADMINS = @()
$Global:O_USERS = @()
$Global:O_ROLES = @()
$Global:O_DEVICES = @()
Get-Banner
check-import
Rain-Login
Get-Header
}
Rain-Main