TOOLS / READ-ONLY EXAMPLES

PowerShell audit
script examples.

Three original Microsoft Graph PowerShell examples for reviewing selected tenant configuration and registration data.

Read-only examples. Run them only in a tenant you are authorized to review, and handle the output as sensitive.

Provided as-is for planning and discussion. Test in non-production. Not legal, compliance or eligibility advice.

These commands are intended to read data only. They do not change tenant settings. Install the relevant Microsoft Graph PowerShell module separately before running an example. Microsoft Graph permissions can expose sensitive tenant information. Confirm your authorization, least-privilege access, data handling rules, module version, and output destination before running anything. Do not paste confidential or CUI data into this site.

Consent is tenant-wide if an administrator grants it. The first Connect-MgGraph asks for consent to the Microsoft Graph Command Line Tools app with the permissions requested. If an administrator ticks "Consent on behalf of your organization", that consent applies to everyone in the tenant and stays until it is removed under Enterprise applications in the Microsoft Entra admin center. The permissions in these examples need an administrator to grant them, so a reader role alone is not enough the first time. Each example ends with Disconnect-MgGraph, which signs out of the session; it does not remove a consent that was granted.

List Conditional Access policies

Required delegated permission: Policy.Read.All. The signed-in user also needs a supported Microsoft Entra role for this read, for example Global Reader, Security Reader, Security Administrator, or Conditional Access Administrator. The command is in the Microsoft.Graph.Identity.SignIns module.

Read-only warning: The command retrieves policy properties and does not edit policies. Policy data may be sensitive.

New to Microsoft Graph PowerShell? Try it in a test tenant first.

# Request read-only permission and connect interactively.
Connect-MgGraph -Scopes "Policy.Read.All"

# List policy names, identifiers, and state only.
Get-MgIdentityConditionalAccessPolicy -All |
    Select-Object DisplayName, Id, State

Disconnect-MgGraph

Microsoft Learn: Get-MgIdentityConditionalAccessPolicy. Last verified:

Review MFA registration details

Required delegated permission: AuditLog.Read.All. The signed-in user also needs a supported role, for example Reports Reader, Security Reader, Security Administrator, or Global Reader. The command is in the Microsoft.Graph.Reports module, and Microsoft notes the report does not work for disabled users. The report can expose personal and authentication-related information.

Read-only warning: The command reads registration report data. Limit access and protect any output under your organization's rules.

New to Microsoft Graph PowerShell? Try it in a test tenant first.

# Request the documented read permission and connect interactively.
Connect-MgGraph -Scopes "AuditLog.Read.All"

# Select summary fields for review. Handle results as sensitive data.
Get-MgReportAuthenticationMethodUserRegistrationDetail -All |
    Select-Object UserPrincipalName, IsMfaRegistered, IsMfaCapable,
        MethodsRegistered

Disconnect-MgGraph

Microsoft Learn: Get-MgReportAuthenticationMethodUserRegistrationDetail. Last verified:

List directory role assignments

Required delegated permission: RoleManagement.Read.Directory. The signed-in user also needs a supported role, for example Directory Readers, Global Reader, or Privileged Role Administrator. The command is in the Microsoft.Graph.Identity.Governance module.

Read-only warning: The commands read role names and active assignments. They do not grant or remove roles. Roles that people are only eligible for through Privileged Identity Management are not listed here.

New to Microsoft Graph PowerShell? Try it in a test tenant first.

# Request read-only permission and connect interactively.
Connect-MgGraph -Scopes "RoleManagement.Read.Directory"

# Look up role names once, so the output shows names instead of IDs.
# A few internal roles held by Microsoft's own apps have no listed name; their ID is shown instead.
$roleNames = @{}
Get-MgRoleManagementDirectoryRoleDefinition -All |
    ForEach-Object { $roleNames[$_.Id] = $_.DisplayName }

# List active role assignments with the role and the name of who holds it.
Get-MgRoleManagementDirectoryRoleAssignment -All -ExpandProperty Principal |
    Select-Object @{ n = "Role"; e = { if ($roleNames[$_.RoleDefinitionId]) { $roleNames[$_.RoleDefinitionId] } else { $_.RoleDefinitionId } } },
        @{ n = "AssignedTo"; e = { $_.Principal.AdditionalProperties.displayName } },
        DirectoryScopeId |
    Sort-Object Role

Disconnect-MgGraph

Microsoft Learn: Get-MgRoleManagementDirectoryRoleAssignment. Last verified:

Examples are independently written from public Microsoft documentation. No employer or customer code is included. Validate current command names, permissions, and output fields against the linked documentation before use.

Next step

These three reads are a small part of what our readiness assessment reviews. Every self-service package includes a read-only NIST SP 800-171 technical gap review of your Microsoft 365 tenant, run before and after the deployment.