Security Policy Errors

Find a Least-Privilege Microsoft 365 Role for Read-Only PowerShell Commands

Adam DavisAdam Davis Nov 20, 2026 868 views

Question details

Identify the least-privilege access needed to read Microsoft 365 users and a domain password policy through PowerShell without granting configuration changes or access to global administrator accounts.

Least-Privilege Microsoft 365 Access for Read-Only PowerShell Commands
Product
Microsoft 365, Microsoft Entra ID, and Microsoft Graph PowerShell
Device & OS
not provided
Scenario
A user needs to list directory users and inspect a domain password policy using PowerShell.
Observed behavior
The desired access is read-only and should not permit changes or expose global administrator accounts.
Before you start

Identify which commands and user properties are required, and confirm whether the user must be prevented from reading global administrator account information. The legacy MSOnline PowerShell module is retired, so plan to use Microsoft Graph PowerShell instead.

Solution 1Recommended

Review Microsoft Graph Permissions for Read-Only Queries

Use Microsoft Graph PowerShell to query users and domain password policy properties, then verify whether its tenant-wide read scope meets your security requirements.

Microsoft Graph permissions and Microsoft Entra roles are separate controls. The delegated permissions below provide read access, but listing all users can include global administrator accounts. They do not satisfy a requirement to hide those accounts.

Password Administrator is not a read-only role: it can reset passwords for certain accounts. Do not assign it solely to run these queries without verifying the permissions and scope.

1
Review the access requirement

In the Microsoft Entra admin center, review the required directory access with an administrator. If global administrator accounts must be hidden, do not grant tenant-wide user read access; consult Microsoft Entra support about an appropriately scoped approach.

2
Install Microsoft Graph PowerShell

Open PowerShell and run Install-Module Microsoft.Graph -Scope CurrentUser. If prompted, review and approve the repository installation.

3
Connect with read permissions

Run Connect-MgGraph -Scopes "User.Read.All","Domain.Read.All". An administrator may need to consent to these delegated permissions; request only the permission needed for each query.

4
List users

Run Get-MgUser -All -Property Id,DisplayName,UserPrincipalName | Select-Object Id,DisplayName,UserPrincipalName. This can return global administrator accounts as well as other users.

5
Read the domain policy

Replace contoso.com with the verified domain and run Get-MgDomain -DomainId contoso.com -Property Id,PasswordValidityPeriod,PasswordNotificationWindowInDays | Select-Object Id,PasswordValidityPeriod,PasswordNotificationWindowInDays.

Review Microsoft Graph Permissions for Read-Only Queries
Filtering is not an access restriction: Removing administrator accounts from displayed results does not prevent a user with tenant-wide read permission from querying those accounts. Verify the effective permissions and any role requirements before granting consent.
Free Microsoft Office alternative

Use WPS Office for Microsoft 365 Documents

WPS Office is a free, lightweight alternative for working with Office documents in a familiar interface. Its format compatibility helps you move existing files seamlessly, although it does not manage Microsoft Entra roles or PowerShell permissions.

Review exported user lists in WPS SpreadsheetOpen and edit Microsoft Excel XLSX filesWork with Word and PowerPoint file formatsNavigate a familiar interface in a lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Can Password Administrator run the commands without being able to make changes?

Password Administrator is not a read-only role because it can reset passwords for certain accounts. Review the role's current permissions in Microsoft Entra documentation before assigning it.

What replaces Get-MsolPasswordPolicy?

Use Get-MgDomain in Microsoft Graph PowerShell to read domain properties such as PasswordValidityPeriod and PasswordNotificationWindowInDays. The MSOnline module is retired.

Can I list all users while preventing access to global administrator accounts?

Tenant-wide user read access can include global administrator accounts. Filtering the results is not a security boundary; consult Microsoft Entra support about a scoped approach that meets the restriction.

Do I need administrator consent for Microsoft Graph permissions?

The delegated User.Read.All and Domain.Read.All permissions generally require administrator consent. Review the requested scopes and grant consent only for the queries the user needs.