Skip to content

Device - 51013 - App Protection Policies block managed-app access when user re-authentication fails (disabled Entra ID accounts, blocked sign-ins, expired tokens)#1302

Open
aahmed-spec wants to merge 4 commits into
devfrom
test-51013
Open

Device - 51013 - App Protection Policies block managed-app access when user re-authentication fails (disabled Entra ID accounts, blocked sign-ins, expired tokens)#1302
aahmed-spec wants to merge 4 commits into
devfrom
test-51013

Conversation

@aahmed-spec

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings June 12, 2026 14:41
@aahmed-spec aahmed-spec changed the base branch from main to dev June 12, 2026 14:41
@aahmed-spec aahmed-spec self-assigned this Jun 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Zero Trust assessment test (51013) under the PowerShell test suite to evaluate whether Intune App Protection Policies enforce a block/wipe action when managed apps cannot re-authenticate the user (e.g., disabled accounts, blocked sign-ins, revoked/expired tokens), and surfaces the configuration in the report output.

Changes:

  • Introduces Test-Assessment-51013 to query iOS/Android managed app protection policies and evaluate appActionIfUnableToAuthenticateUser + assignment state.
  • Generates a markdown report table summarizing the auth-failure action and whether each policy would pass/fail.
  • Adds a matching Test-Assessment.51013.md description/remediation doc that plugs into Add-ZtTestResultDetail.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/powershell/tests/Test-Assessment.51013.ps1 New assessment test logic + Graph collection + result markdown table generation
src/powershell/tests/Test-Assessment.51013.md New assessment documentation and remediation links with %TestResult% placeholder

Comment thread src/powershell/tests/Test-Assessment.51013.ps1 Outdated
Comment thread src/powershell/tests/Test-Assessment.51013.ps1 Outdated
Comment thread src/powershell/tests/Test-Assessment.51013.ps1 Outdated
Comment thread src/powershell/tests/Test-Assessment.51013.ps1 Outdated
@aahmed-spec aahmed-spec marked this pull request as ready for review June 15, 2026 19:06
@aahmed-spec aahmed-spec added ready for review PR is ready for review and merging and removed ready for review PR is ready for review and merging labels Jun 15, 2026
@aahmed-spec aahmed-spec marked this pull request as draft June 16, 2026 04:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread src/powershell/tests/Test-Assessment.51013.ps1
Comment thread src/powershell/tests/Test-Assessment.51013.ps1
@aahmed-spec aahmed-spec marked this pull request as ready for review June 18, 2026 18:21
@aahmed-spec aahmed-spec added the ready for review PR is ready for review and merging label Jun 18, 2026

@alexandair alexandair left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aahmed-spec Please, address my feedback.

$androidRaw = Invoke-ZtGraphRequest -RelativeUri 'deviceManagement/managedDevices' -Filter "operatingSystem eq 'Android'" -Select 'id' -Top 1 -QueryParameters @{ '$count' = 'true' } -DisablePaging -ApiVersion v1.0 -ErrorAction Stop
$androidDeviceCount = [int]($androidRaw.'@odata.count')
}
catch {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error handling does not distinguish 401/403

The spec says Investigate when Q1/Q2/Q3 returns 401 or 403. The implementation marks any Graph error as Investigate.

Let's check with @KalwaniRavi if that's OK.


try {
$iosRaw = Invoke-ZtGraphRequest -RelativeUri 'deviceManagement/managedDevices' -Filter "operatingSystem eq 'iOS' or operatingSystem eq 'iPadOS'" -Select 'id' -Top 1 -QueryParameters @{ '$count' = 'true' } -DisablePaging -ApiVersion v1.0 -ErrorAction Stop
$iosDeviceCount = [int]($iosRaw.'@odata.count')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the explicit cast to [int] necessary?

$androidPolicies = @()

try {
$iosPolicies = @(Invoke-ZtGraphRequest -RelativeUri 'deviceAppManagement/iosManagedAppProtections' -Select 'id,displayName,appActionIfUnableToAuthenticateUser,isAssigned,deployedAppCount' -ApiVersion beta -ErrorAction Stop)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deployedAppCount is fetched, but never used.

try {
$iosPolicies = @(Invoke-ZtGraphRequest -RelativeUri 'deviceAppManagement/iosManagedAppProtections' -Select 'id,displayName,appActionIfUnableToAuthenticateUser,isAssigned,deployedAppCount' -ApiVersion beta -ErrorAction Stop)

Write-ZtProgress -Activity $activity -Status 'Getting Android app protection policies'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deployedAppCount is fetched, but never used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review PR is ready for review and merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants