forked from silverhack/monkey365
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonkey365.psm1
53 lines (48 loc) · 1.61 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
#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;
#Load all modules
$Modules = @{
utils = '/core/utils/'
azure_api = '/core/api/azure/'
init = '/core/init/'
runspaces = '/core/tasks/'
auth = '/core/api/auth/'
analysis = '/core/analysis/'
office = '/core/office/'
html = '/core/html/'
o365_api = '/core/api/o365/'
watcher = '/core/watcher/'
output = '/core/output/'
import = '/core/import/'
}
#Import modules
foreach($module in $Modules.GetEnumerator()){
$metadata = [System.IO.File]::GetAttributes(("{0}{1}" -f $PSScriptRoot, $module.value))
if($metadata -band [System.IO.FileAttributes]::Directory){
$all_files = Get-ChildItem -Recurse -Path ("{0}{1}" -f $PSScriptRoot, $module.value) -File -Include "*.ps1" -ErrorAction SilentlyContinue
if($null -ne $all_files){
foreach ($mod in $all_files){
Write-Verbose ("Loading {0} module" -f $mod.FullName)
. $mod.FullName
}
}
}
else{
Write-Verbose ("Loading {0} module" -f $module.Name)
$tmp_module = ("{0}{1}" -f $PSScriptRoot, $module.value)
. $tmp_module.ToString()
}
}
#$ScriptPath = $PSScriptRoot
New-Variable -Name ScriptPath -Value $PSScriptRoot -Scope Script -Force
#Import ADAL/MSAL MODULES
Import-O365Lib
$monkey = ("{0}\Invoke-Monkey365.ps1" -f $PSScriptRoot)
. $monkey