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
@@ -2254,6 +2254,11 @@ Function Install-SOAPrerequisites {
2254
2254
}
2255
2255
2256
2256
If($EntraAppCheck-eq$True) {
2257
+
# Check if the InitialDomain was not provided, which is required when skipping delegated connection entirely
2258
+
if (($null-ne$GraphClientId-and$PromptForApplicationSecret-eq$true) -and$null-eq$InitialDomain) {
2259
+
Exit-Script
2260
+
throw"The GraphClientId and PromptForApplicationSecret parameters were used, but InitialDomain was not specified. Re-run the script with the InitialDomain parameter"
2261
+
}
2257
2262
2258
2263
# Get the cloud environment if not provided
2259
2264
if (-not$CloudEnvironment) {
@@ -2288,7 +2293,8 @@ Function Install-SOAPrerequisites {
2288
2293
}
2289
2294
2290
2295
$mgContext= (Get-MgContext).Scopes
2291
-
if ($mgContext-notcontains'Application.ReadWrite.All'-or ($mgContext-notcontains'Organization.Read.All'-and$mgContext-notcontains'Directory.Read.All') -or ($PromptForApplicationSecret)) {
2296
+
# Skip delegated connection if providing GraphClientId and the App Secret manually, otherwise evaluate whether the correct scope was requested
2297
+
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)) {
2292
2298
Write-Host"$(Get-Date) Connecting to Graph with delegated authentication..."
2293
2299
if ($null-ne (Get-MgContext)){Disconnect-MgGraph|Out-Null}
2294
2300
$connCount=0
@@ -2327,9 +2333,6 @@ Function Install-SOAPrerequisites {
2327
2333
if (Get-MgContext) {
2328
2334
Write-Host"$(Get-Date) Checking Microsoft Entra enterprise application..."
# Prompt for the client secret needed to connect to the application
@@ -2374,6 +2360,7 @@ Function Install-SOAPrerequisites {
2374
2360
while ($null-eq$SSCred-or$SSCred.Length-eq0) {
2375
2361
# UserName is a required parameter for Get-Credential but it's value is not used elsewhere in the script
2376
2362
$SSCred= (Get-Credential-Message "Enter the app registration's client secret into the password field."-UserName "Microsoft Security Assessment").Password
2363
+
Start-Sleep1# Add a delay to allow to aborting to console
2377
2364
}
2378
2365
} else {
2379
2366
# Reset secret
@@ -2384,20 +2371,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.
2395
+
if ($GraphClientId-and$PromptForApplicationSecret) {
2396
+
$EntraApp=Invoke-MgGraphRequest-Method GET -Uri "$GraphHost/v1.0/applications(appId=`'$GraphClientId`')"
2397
+
}
2398
+
2399
+
# 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