Skip to content

Commit 3cf4cad

Browse files
committed
update O365Object
1 parent 1bd2401 commit 3cf4cad

5 files changed

Lines changed: 21 additions & 69 deletions

File tree

core/init/Get-ExecutionInfo.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Function Get-ExecutionInfo{
132132
Debug = $O365Object.debug;
133133
InformationAction = $O365Object.InformationAction;
134134
}
135-
$pic = Get-MonkeyGraphAADProfilePhoto @p
135+
$pic = Get-MonkeyMSGraphProfilePhoto @p
136136
}
137137
if($null -ne $pic){
138138
$user_pic = ('data:image/png;base64,{0}' -f $pic)

core/init/Get-MonkeyCollector.ps1

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,6 @@ Function Get-MonkeyCollector{
8080
#Set empty array
8181
$allCollectors = [System.Collections.Generic.List[System.Management.Automation.PSObject]]::new()
8282
}
83-
#Get Api Type
84-
Try{
85-
$useMsGraph = [System.Convert]::ToBoolean($O365Object.internal_config.entraId.useMsGraph)
86-
$useAADOldAPIForUsers = [System.Convert]::ToBoolean($O365Object.internal_config.entraId.getUsersWithAADInternalAPI)
87-
}
88-
Catch{
89-
$useMsGraph = $true;
90-
$useAADOldAPIForUsers = $false;
91-
}
9283
}
9384
Process{
9485
If($allCollectors.Count -gt 0){
@@ -124,26 +115,7 @@ Function Get-MonkeyCollector{
124115
[void]$entraIdCollectors.Add($msGraphCollectors)
125116
}
126117
}
127-
ElseIf($useMsGraph -eq $false -and $O365Object.isConfidentialApp -eq $false){
128-
#Load Old Graph collectors
129-
If ($graphCollectors -is [System.Collections.IEnumerable] -and $graphCollectors -isnot [string]){
130-
[void]$entraIdCollectors.AddRange($graphCollectors)
131-
}
132-
ElseIf ($graphCollectors.GetType() -eq [System.Management.Automation.PSCustomObject] -or $graphCollectors.GetType() -eq [System.Management.Automation.PSObject]) {
133-
[void]$entraIdCollectors.Add($graphCollectors)
134-
}
135-
#Load Entra ID internal API collectors
136-
If ($apiPortalCollectors -is [System.Collections.IEnumerable] -and $apiPortalCollectors -isnot [string]){
137-
[void]$entraIdCollectors.AddRange($apiPortalCollectors)
138-
}
139-
ElseIf ($apiPortalCollectors.GetType() -eq [System.Management.Automation.PSCustomObject] -or $apiPortalCollectors.GetType() -eq [System.Management.Automation.PSObject]) {
140-
[void]$entraIdCollectors.Add($apiPortalCollectors)
141-
}
142-
}
143-
ElseIf($useMsGraph -and $O365Object.isConfidentialApp -eq $false){
144-
Foreach($_collector in $entraIdCollectors.GetEnumerator()){
145-
[void]$collectors.Add($eidCollector);
146-
}
118+
Else{
147119
#Load MSGraph collectors
148120
If ($msGraphCollectors -is [System.Collections.IEnumerable] -and $msGraphCollectors -isnot [string]){
149121
[void]$entraIdCollectors.AddRange($msGraphCollectors)
@@ -158,34 +130,6 @@ Function Get-MonkeyCollector{
158130
ElseIf ($apiPortalCollectors.GetType() -eq [System.Management.Automation.PSCustomObject] -or $apiPortalCollectors.GetType() -eq [System.Management.Automation.PSObject]) {
159131
[void]$entraIdCollectors.Add($apiPortalCollectors)
160132
}
161-
#Check if should load old AAD collector for users
162-
If($useAADOldAPIForUsers){
163-
#Remove MSGraph user collector
164-
$entraIdCollectors = $entraIdCollectors.Where({$_.collectorName -ne "Get-MonkeyAADUser"});
165-
#Add graph users collector
166-
$OlduserCollector = @($graphCollectors).Where({$_.collectorName -eq "Get-MonkeyADUser"});
167-
If($OlduserCollector.Count -gt 0){
168-
Foreach($_collector in $OlduserCollector){
169-
[void]$entraIdCollectors.Add($_collector)
170-
}
171-
}
172-
#Add policies
173-
$policiesCollector = @($graphCollectors).Where({$_.collectorName -eq "Get-MonkeyADPolicy"});
174-
If($policiesCollector.Count -gt 0){
175-
Foreach($_collector in $policiesCollector){
176-
[void]$entraIdCollectors.Add($_collector)
177-
}
178-
}
179-
}
180-
}
181-
Else{
182-
#Load MSGraph collectors
183-
If ($msGraphCollectors -is [System.Collections.IEnumerable] -and $msGraphCollectors -isnot [string]){
184-
[void]$entraIdCollectors.AddRange($msGraphCollectors)
185-
}
186-
ElseIf ($msGraphCollectors.GetType() -eq [System.Management.Automation.PSCustomObject] -or $msGraphCollectors.GetType() -eq [System.Management.Automation.PSObject]) {
187-
[void]$entraIdCollectors.Add($msGraphCollectors)
188-
}
189133
}
190134
#Add discovered collectors
191135
Foreach($eidCollector in $entraIdCollectors.GetEnumerator()){

core/init/Get-MonkeyUserAgent.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ Function Get-MonkeyUserAgent{
3636

3737
[CmdletBinding()]
3838
Param()
39-
$userAgent = $version = $manifest = $null;
40-
$monkeymod = Get-Module -Name monkey365 -ErrorAction Ignore
39+
$userAgent = $manifest = $null;
40+
#Set Empty version
41+
$version = [System.String]::Empty;
42+
$monkeymod = Get-Module -Name monkey365 -ErrorAction Ignore | Select-Object -First 1
4143
#Get version
4244
if($null -ne $monkeymod){
4345
$version = $monkeymod.Version.ToString()

core/init/Initialize-MonkeyLogger.ps1

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Function Initialize-MonkeyLogger{
5151
if($null -ne $fileLogger -and $null -ne $fileLogger.configuration.filename){
5252
$isRoot = [System.IO.Path]::IsPathRooted($fileLogger.configuration.filename)
5353
if(-NOT $isRoot){
54-
$log_path = ("{0}/log/{1}" -f $ScriptPath, $fileLogger.configuration.filename)
54+
$log_path = ("{0}/log/{1}" -f $O365Object.Localpath, $fileLogger.configuration.filename)
5555
$fileLogger.configuration.filename = $log_path
5656
}
5757
#Add file logger
@@ -63,8 +63,6 @@ Function Initialize-MonkeyLogger{
6363
If($O365Object.internal_config.logging.loggers){
6464
$loggers+=$O365Object.internal_config.logging.loggers
6565
}
66-
#Set LogQueue var
67-
New-Variable -Name MonkeyLogQueue -Scope Script -Value $O365Object.MonkeyLogQueue -Force
6866
#Start logging
6967
If($loggers){
7068
$l_param = @{
@@ -75,7 +73,6 @@ Function Initialize-MonkeyLogger{
7573
Verbose = $O365Object.verbose;
7674
Debug = $O365Object.debug;
7775
}
78-
$status = Start-Logger @l_param
7976
}
8077
Else{
8178
$l_param = @{
@@ -85,14 +82,16 @@ Function Initialize-MonkeyLogger{
8582
Verbose = $O365Object.verbose;
8683
Debug = $O365Object.debug;
8784
}
88-
$status = Start-Logger @l_param
8985
}
86+
#Initialize Logger
87+
$status = Start-Logger @l_param
88+
#Check status
9089
If($status -eq $false){
9190
$msg = @{
9291
MessageData = ($message.LoggerError);
9392
callStack = (Get-PSCallStack | Select-Object -First 1);
9493
logLevel = 'warning';
95-
InformationAction = $InformationAction;
94+
InformationAction = $O365Object.InformationAction;
9695
Tags = @('LoggerError');
9796
}
9897
Write-Warning @msg

core/init/New-O365Object.ps1

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ Function New-O365Object{
328328
('{0}/core/modules/monkeyhttpwebrequest' -f $ScriptPath),
329329
('{0}/core/modules/monkeyjob' -f $ScriptPath),
330330
('{0}/core/modules/monkeyutils' -f $ScriptPath),
331+
('{0}/core/modules/monkeycloudutils' -f $ScriptPath),
331332
('{0}/core/api/m365/sharepointonline/utils/enum.ps1' -f $ScriptPath)
332333
('{0}/core/tasks/Initialize-MonkeyScan.ps1' -f $ScriptPath)
333334
)
@@ -377,7 +378,15 @@ Function New-O365Object{
377378
userPrincipalName = $null;
378379
userId = $null;
379380
orgRegions = $null;
380-
Tenant = $null;
381+
Tenant = [PsCustomObject]@{
382+
tenantName = $null;
383+
tenantId = $null;
384+
companyInfo = $null;
385+
sku = $null;
386+
domains = $null;
387+
myDomain = $null;
388+
licensing = $null;
389+
};
381390
tenantOrigin = $null;
382391
Collectors = $null;
383392
Licensing = $null;
@@ -446,8 +455,6 @@ Function New-O365Object{
446455
ruleset = $ruleSet;
447456
rulesPath = $rulesPath;
448457
Compress = $MyParams.Compress;
449-
useMSGraphForAAD = [System.Convert]::ToBoolean($internal_config_json.entraId.useMsGraph);
450-
useOldAADAPIforUsers = [System.Convert]::ToBoolean($internal_config_json.entraId.getUsersWithAADInternalAPI)
451458
}
452459
#Create new object
453460
$MonkeyObj = New-Object -TypeName PSCustomObject -Property $tmp_object

0 commit comments

Comments
 (0)