-
Notifications
You must be signed in to change notification settings - Fork 137
Expand file tree
/
Copy pathmonkey365.psm1
More file actions
127 lines (120 loc) · 5.82 KB
/
monkey365.psm1
File metadata and controls
127 lines (120 loc) · 5.82 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
#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_modules = @(
'core/modules/monkeylogger',
'core/modules/monkeycloudutils',
'core/modules/monkeyutils',
'core/modules/monkeyhttpwebrequest',
'core/modules/psmarkdig',
'core/modules/monkeyhtml',
'core/modules/monkeyjob',
'core/modules/monkeyruleset',
'core/modules/psocsf',
'core/modules/monkeyoutput'
)
$internal_modules.ForEach({Import-Module ("{0}{1}{2}" -f $PSScriptRoot,[System.IO.Path]::DirectorySeparatorChar, $_.ToString()) -Force})
New-Variable -Name ScriptPath -Value $PSScriptRoot -Scope Script -Force
#Get Azure plugins
$cmds = [System.IO.Directory]::EnumerateFiles(("{0}/core/collector" -f $PSScriptRoot),"*.ps1",[System.IO.SearchOption]::AllDirectories)
$modules = @(
("{0}/core/modules/monkeyutils" -f $PSScriptRoot)
)
$p = @{
ScriptBlock = {Get-MonkeySupportedService -Azure};
ImportCommands = $cmds;
ImportModules = $modules;
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 -Microsoft365};
ImportModules = $modules;
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/api/auth',
'core/tenant',
'core/collector',
'core/utils',
'core/subscription',
'core/init',
'core/import',
'core/output',
'core/tasks',
'core/watcher'
)
$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({. $_})
#Internal files
$internal_files = @(
'core/api/azure/resourcemanagement/api/Get-MonkeyRMObject.ps1',
'core/api/azure/resourcemanagement/helpers/tenant/Get-MonkeyAzTenant.ps1',
'core/api/azure/resourcemanagement/helpers/subscription/Get-MonkeyAzSubscription.ps1',
'core/api/azure/resourcemanagement/helpers/subscription/Get-MonkeyAzClassicAdministrator.ps1',
'core/api/azure/resourcemanagement/helpers/rbac/Get-MonkeyAzIAMPermission.ps1',
'core/api/azure/resourcemanagement/helpers/rbac/Get-MonkeyAzRoleAssignmentForObject.ps1',
'core/api/azure/resourcemanagement/helpers/rbac/Get-MonkeyAzRoleDefinitionObject.ps1',
'core/api/azure/resourcemanagement/helpers/general/Get-MonkeyAzResourceGroup.ps1',
'core/api/azure/resourcemanagement/helpers/general/Get-MonkeyAzResource.ps1',
'core/api/azure/resourcemanagement/helpers/general/Get-MonkeyAzProviderOperation.ps1',
'core/api/entraid/msgraph/api/Get-MonkeyMSGraphObject.ps1',
'core/api/entraid/msgraph/helpers/general/Get-MonkeyMSGraphOrganization.ps1',
'core/api/entraid/msgraph/helpers/general/Get-MonkeyMSGraphSuscribedSku.ps1',
'core/api/entraid/msgraph/helpers/general/Get-MonkeyMSGraphSuscribedSku.ps1',
'core/api/entraid/msgraph/helpers/domain/Get-MonkeyMSGraphDomain.ps1',
'core/api/entraid/msgraph/helpers/general/Test-CanRequestGroup.ps1',
'core/api/entraid/msgraph/helpers/general/Test-CanRequestUser.ps1',
'core/api/entraid/msgraph/helpers/general/Get-MonkeyMSGraphDirectoryObjectById.ps1',
'core/api/entraid/msgraph/helpers/general/Get-MonkeyMSGraphProfilePhoto.ps1',
'core/api/entraid/msgraph/helpers/users/Get-MonkeyMSGraphUser.ps1',
'core/api/entraid/msgraph/helpers/groups/Get-MonkeyMSGraphGroup.ps1',
'core/api/entraid/msgraph/helpers/groups/Get-MonkeyMSGraphGroupTransitiveMember.ps1',
'core/api/entraid/msgraph/helpers/serviceprincipals/Get-MonkeyMSGraphAADServicePrincipal.ps1',
'core/api/entraid/msgraph/helpers/directoryrole/Get-MonkeyMSGraphEntraDirectoryRole.ps1',
'core/api/entraid/msgraph/helpers/directoryrole/Get-MonkeyMSGraphEntraRoleAssignment.ps1',
'core/api/entraid/msgraph/helpers/directoryrole/Get-MonkeyMSGraphObjectDirectoryRole.ps1',
'core/api/m365/exchangeonline/helpers/Get-PSExoModuleFile.ps1',
'core/api/m365/exchangeonline/api/ConvertTo-ExoRestCommand.ps1',
'core/api/m365/exchangeonline/api/Get-PSExoAdminApiObject.ps1',
'core/api/m365/microsoftteams/api/Get-MonkeyTeamsObject.ps1',
'core/api/m365/microsoftteams/helpers/service/Get-MonkeyTeamsServiceDiscovery.ps1',
'core/api/m365/microsoftteams/helpers/service/Test-TeamsConnection.ps1',
'core/api/m365/sharepointonline/csom/api/Invoke-MonkeyCSOMRequest.ps1',
'core/api/m365/sharepointonline/csom/api/Invoke-MonkeyCSOMDefaultRequest.ps1',
'core/api/m365/sharepointonline/csom/helpers/site/Get-MonkeyCSOMSite.ps1',
'core/api/m365/sharepointonline/csom/helpers/site/Get-MonkeyCSOMSiteProperty.ps1',
'core/api/m365/sharepointonline/utils/Test-IsUserSharepointAdministrator.ps1',
'core/api/m365/sharepointonline/utils/Test-SiteConnection.ps1',
'core/scan/Invoke-AzureScanner.ps1',
'core/scan/Invoke-EntraIDScanner.ps1',
'core/scan/Invoke-M365Scanner.ps1'
)
$internal_files = $internal_files.ForEach({[System.IO.FileInfo]::new(("{0}/{1}" -f $PSScriptRoot,$_))})
$internal_files.ForEach({. $_.FullName})
$monkey = ("{0}/Invoke-Monkey365.ps1" -f $PSScriptRoot)
. $monkey