03 / INCIDENT TRIAGE WORKFLOWS · LESSON 11

Review privileged access exports

Apply explicit review rules to exported account data without confusing string values with booleans.

12 min · learn at your pace

Read the export's schema

This fixture contains lowercase strings true and false. CSV has no native boolean type: Import-Csv returns those strings unchanged. Casting a non-empty string directly to [bool] produces true, even when the text says false. Compare the text explicitly or use a deliberate boolean parser.

[bool]'false'       # True: the string is not empty
[bool]::Parse('false')  # False: the word is parsed

Separate the rules

The fictional organisation wants two review queues: disabled accounts that retain privileged membership, and privileged accounts without recorded approval. These are distinct reasons. One account can trigger both, so independent if statements are appropriate; an elseif would suppress the second reason.

Do not include ordinary non-privileged accounts just because they lack privileged-access approval. The privilege condition scopes both rules.

Emit one finding per account and reason, preserving the export's record ID. The account name helps the reviewer, while the source ID keeps the result traceable.

This lesson reads a snapshot. It does not connect to Active Directory, disable users, remove group memberships, or make changes to a real environment. A review finding needs owner confirmation and current context before any administrative action. Browser checks assess the exported data logic only.

Try an example.ps1
Import-Csv '/home/user/accounts.csv' | Select-Object Account, Enabled, Privileged, Approved
YOUR TURN

Put it into practice.

Read accounts.csv. For privileged accounts only, emit RecordId, Account, and Reason for each applicable rule: Enabled false → DisabledPrivileged; Approved false → UnapprovedPrivileged. An account meeting both rules must produce two findings. Values are the strings true/false.

See an explained solution
One way to solve it.ps1
foreach ($account in Import-Csv '/home/user/accounts.csv') {
    if ($account.Privileged -eq 'true') {
        if ($account.Enabled -eq 'false') { [pscustomobject]@{ RecordId=$account.RecordId; Account=$account.Account; Reason='DisabledPrivileged' } }
        if ($account.Approved -eq 'false') { [pscustomobject]@{ RecordId=$account.RecordId; Account=$account.Account; Reason='UnapprovedPrivileged' } }
    }
}

Explicit string comparisons avoid the non-empty-string boolean trap. Independent rules preserve both review reasons for retired-owner.