-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathmonkey365.psm1
148 lines (135 loc) · 4.18 KB
/
monkey365.psm1
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
#Set-StrictMode -Off #-Version Latest
Set-StrictMode -Version Latest
$LocalizedDataParams = @{
BindingVariable = 'message';
FileName = 'localized.psd1';
BaseDirectory = "{0}/{1}" -f $PSScriptRoot, "core/utils";
}
#Import localized data
Import-LocalizedData @LocalizedDataParams;
<#
$internal_functions = @(
'/core/analysis',
'/core/collector',
'/core/init',
'/core/utils',
'/core/html',
'/core/tasks',
'/core/watcher',
'/core/api/auth',
'/core/import',
'/core/office',
'/core/output',
'/core/tenant',
'/core/api/EntraID/graph',
'/core/api/EntraID/msgraph',
'/core/subscription'
'/core/api/azure/',
'/core/api/m365/MicrosoftTeams/',
'/core/api/m365/ExchangeOnline/'
'/core/api/m365/SharePointOnline/',
'/core/api/m365/M365AdminPortal/'
)
#>
<#
$internal_functions = @(
'/core/api/auth',
'/core/analysis',
'/core/init',
#'/core/collector',
'/core/utils',
'/core/html',
'/core/tasks',
'/core/watcher',
'/core/import',
#'/core/office',
#'/core/output',
'/core/tenant',
'/core/api/EntraID/graph',
'/core/api/EntraID/msgraph',
'/core/subscription'
# '/core/api/azure/',
#'/core/api/m365/MicrosoftTeams/',
#'/core/api/m365/ExchangeOnline/'
#'/core/api/m365/SharePointOnline/',
#'/core/api/m365/M365AdminPortal/'
)
#>
$internal_modules = @(
'core/modules/monkeyhttpwebrequest'
'core/modules/monkeyutils',
'core/modules/monkeylogger'
'core/modules/monkeyexcel',
'core/modules/psmarkdig',
'core/modules/monkeyruleset',
'core/modules/monkeyhtml',
'core/modules/monkeyast',
'core/modules/monkeyjob'
)
$internal_modules.ForEach({Import-Module ("{0}{1}{2}" -f $PSScriptRoot,[System.IO.Path]::DirectorySeparatorChar, $_.ToString()) -Force})
$msal_modules = @(
'core/modules/monkeycloudutils',
'core/modules/monkeymsalauthassistant'
)
$msal_modules.ForEach({Import-Module ("{0}{1}{2}" -f $PSScriptRoot,[System.IO.Path]::DirectorySeparatorChar, $_.ToString()) -Scope Global -Force})
New-Variable -Name ScriptPath -Value $PSScriptRoot -Scope Script -Force
#Get Azure plugins
$cmds = [System.IO.Directory]::EnumerateFiles(("{0}/core/collector" -f $PSScriptRoot),"*.ps1","AllDirectories")
$p = @{
ScriptBlock = {Get-MonkeySupportedService -Azure};
ImportModules = ("{0}/core/modules/monkeyast" -f $PSScriptRoot);
ImportCommands = $cmds;
ImportVariables = @{"ScriptPath" = $PSScriptRoot};
}
[void](Start-MonkeyJob @p)
Get-MonkeyJob | Wait-MonkeyJob
$azure_plugins = Get-MonkeyJob | Receive-MonkeyJob
#Remove Job
Get-MonkeyJob | Remove-MonkeyJob
New-Variable -Name azure_plugins -Value $azure_plugins -Scope Script -Force
#Get Microsoft 365 plugins
$p = @{
ScriptBlock = {Get-MonkeySupportedService -M365};
ImportModules = ("{0}/core/modules/monkeyast" -f $PSScriptRoot);
ImportCommands = $cmds;
ImportVariables = @{"ScriptPath" = $PSScriptRoot};
}
[void](Start-MonkeyJob @p)
Get-MonkeyJob | Wait-MonkeyJob
$m365_plugins = Get-MonkeyJob | Receive-MonkeyJob
New-Variable -Name m365_plugins -Value $m365_plugins -Scope Script -Force
#Remove Job
Get-MonkeyJob | Remove-MonkeyJob
$internal_functions = @(
'/core/init',
'/core/utils',
'/core/collector',
'/core/api/auth',
'/core/html',
'/core/office',
'/core/tasks',
'/core/analysis',
'/core/import',
'/core/output',
'/core/api/EntraID/msgraph',
'/core/tenant',
'/core/subscription',
'/core/api/azure',
'/core/api/EntraID/graph/api',
'/core/api/EntraID/graph/helpers/user',
'/core/api/azure/resourcemanagement/api',
'/core/api/azure/resourcemanagement/helpers/tenant',
'/core/api/m365/MicrosoftTeams/',
'/core/api/m365/ExchangeOnline/'
'/core/api/m365/SharePointOnline/',
'/core/api/m365/M365AdminPortal/'
)
$all_files = $internal_functions.ForEach({
if([System.IO.Directory]::Exists(("{0}{1}" -f $PSScriptRoot,$_))){
[System.IO.Directory]::EnumerateFiles(("{0}{1}" -f $PSScriptRoot,$_),"*.ps1",[System.IO.SearchOption]::AllDirectories)
}
})
$all_files = $all_files.Where({$_.EndsWith('ps1')})
$all_files.ForEach({. $_})
$monkey = ("{0}/Invoke-Monkey365.ps1" -f $PSScriptRoot)
. $monkey