-
Notifications
You must be signed in to change notification settings - Fork 139
Expand file tree
/
Copy pathmonkey365.psm1
More file actions
136 lines (117 loc) · 5.12 KB
/
Copy pathmonkey365.psm1
File metadata and controls
136 lines (117 loc) · 5.12 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
Set-StrictMode -Version Latest
$script:ScriptPath = $PSScriptRoot
# Import localized data
$LocalizedDataParams = @{
BindingVariable = 'message';
FileName = 'localized.psd1';
BaseDirectory = (Join-Path $PSScriptRoot 'core/utils');
}
#Import localized data
Import-LocalizedData @LocalizedDataParams;
function Get-MonkeySourceFile {
param(
[Parameter(Mandatory)]
[string] $RelativePath
)
$path = Join-Path $PSScriptRoot $RelativePath
If ([System.IO.File]::Exists($path) -and ([System.IO.Path]::GetExtension($path) -eq '.ps1')) {
return $path
}
throw "Source file not found: $RelativePath"
}
Function Get-MonkeySourceFiles {
param(
[Parameter(Mandatory)]
[string] $RelativePath
)
$path = Join-Path $PSScriptRoot $RelativePath
If (-not [System.IO.Directory]::Exists($path)) {
return
}
[System.IO.Directory]::EnumerateFiles(
$path,
'*',
[System.IO.SearchOption]::AllDirectories
) | Sort-Object
}
# Import core functions
$sourceFolders = @(
'core/api/auth'
'core/tenant'
'core/collector'
'core/utils'
'core/subscription'
'core/init'
'core/import'
'core/output'
'core/tasks'
'core/watcher'
)
$sourceFolders.ForEach({
ForEach ($file in Get-MonkeySourceFiles -RelativePath $_) {
If ([System.IO.Path]::GetExtension($file) -ne '.ps1') {
continue
}
. $file
}
})
$script:azure_plugins = @(Get-MonkeySupportedService -Azure)
$script:m365_plugins = @(Get-MonkeySupportedService -Microsoft365)
Function Get-MonkeyAzurePlugins {
If (-not $script:azure_plugins) {
$script:azure_plugins = Get-MonkeySupportedService -Azure
}
Write-Host ($script:azure_plugins | Out-String)
return $script:azure_plugins
}
Function Get-MonkeyM365Plugins {
If (-not $script:m365_plugins) {
$script:m365_plugins = Get-MonkeySupportedService -Microsoft365
}
return $script:m365_plugins
}
# Import core functions
$sourceFiles = @(
'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/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/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'
) | Select-Object -Unique
$sourceFiles.ForEach({. (Get-MonkeySourceFile -RelativePath $_)})
# Import Monkey365
. (Get-MonkeySourceFile -RelativePath 'Invoke-Monkey365.ps1')