@@ -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 ()){
0 commit comments