You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -2256,6 +2256,11 @@ Function Install-SOAPrerequisites {
2256
2256
}
2257
2257
2258
2258
If($EntraAppCheck-eq$True) {
2259
+
# Check if the InitialDomain was not provided, which is required when skipping delegated connection entirely
2260
+
if (($null-ne$GraphClientId-and$PromptForApplicationSecret-eq$true) -and$null-eq$InitialDomain) {
2261
+
Exit-Script
2262
+
throw"The GraphClientId and PromptForApplicationSecret parameters were used, but InitialDomain was not specified. Re-run the script with the InitialDomain parameter"
2263
+
}
2259
2264
2260
2265
# Get the cloud environment if not provided
2261
2266
if (-not$CloudEnvironment) {
@@ -2290,7 +2295,8 @@ Function Install-SOAPrerequisites {
2290
2295
}
2291
2296
2292
2297
$mgContext= (Get-MgContext).Scopes
2293
-
if ($mgContext-notcontains'Application.ReadWrite.All'-or ($mgContext-notcontains'Organization.Read.All'-and$mgContext-notcontains'Directory.Read.All') -or ($PromptForApplicationSecret)) {
2298
+
# Skip delegated connection if providing GraphClientId and the App Secret manually, otherwise evaluate whether the correct scope was requested
2299
+
if ($mgContext-notcontains'Application.ReadWrite.All'-or ($mgContext-notcontains'Organization.Read.All'-and$mgContext-notcontains'Directory.Read.All') -and ($null-eq$GraphClientId-or$PromptForApplicationSecret-ne$true)) {
2294
2300
Write-Host"$(Get-Date) Connecting to Graph with delegated authentication..."
2295
2301
if ($null-ne (Get-MgContext)){Disconnect-MgGraph|Out-Null}
2296
2302
$connCount=0
@@ -2329,9 +2335,6 @@ Function Install-SOAPrerequisites {
2329
2335
if (Get-MgContext) {
2330
2336
Write-Host"$(Get-Date) Checking Microsoft Entra enterprise application..."
# Prompt for the client secret needed to connect to the application
@@ -2376,6 +2362,7 @@ Function Install-SOAPrerequisites {
2376
2362
while ($null-eq$SSCred-or$SSCred.Length-eq0) {
2377
2363
# UserName is a required parameter for Get-Credential but it's value is not used elsewhere in the script
2378
2364
$SSCred= (Get-Credential-Message "Enter the app registration's client secret into the password field."-UserName "Microsoft Security Assessment").Password
2365
+
Start-Sleep1# Add a delay to allow to aborting to console
2379
2366
}
2380
2367
} else {
2381
2368
# Reset secret
@@ -2386,20 +2373,52 @@ Function Install-SOAPrerequisites {
if ($ConnCount-gt5) {$ConnectionVerbose=@{Verbose=$true}} # Suppress Verbose output for the first 5 attempts, but display when connection is taking longer
# If the Delegated permissions were skipped, then the EntraApp has not yet been collected. Specifying the App ID allows the Application.ReadWrite.OwnedBy permission to be sufficient.
2397
+
if ($GraphClientId-and$PromptForApplicationSecret) {
2398
+
$EntraApp=Invoke-MgGraphRequest-Method GET -Uri "$GraphHost/v1.0/applications(appId=`'$GraphClientId`')"
2399
+
}
2400
+
2401
+
# Check if redirect URIs not set for existing app because DoNotRemediate is True. Needs to be evaulated after switching to Application permissions for scenarios where Delegated is not used.
0 commit comments