Find a Least-Privilege Microsoft 365 Role for Read-Only PowerShell Commands
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.

- 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.
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.
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.
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.
Open PowerShell and run Install-Module Microsoft.Graph -Scope CurrentUser. If prompted, review and approve the repository installation.
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.
Run Get-MgUser -All -Property Id,DisplayName,UserPrincipalName | Select-Object Id,DisplayName,UserPrincipalName. This can return global administrator accounts as well as other users.
Replace contoso.com with the verified domain and run Get-MgDomain -DomainId contoso.com -Property Id,PasswordValidityPeriod,PasswordNotificationWindowInDays | Select-Object Id,PasswordValidityPeriod,PasswordNotificationWindowInDays.

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.

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.




