Fix PowerShell Microsoft Graph 404 Error for User lastSignInDate
Question details
A Microsoft Graph PowerShell script returns a 404 Not Found error when attempting to retrieve the lastSignInDate for a user that already exists in Azure Active Directory.
- Product
- Microsoft Graph PowerShell
- Device & OS
- not provided
- Scenario
- Running a PowerShell script to fetch user sign-in activity and logging data from Azure AD.
- Observed behavior
- The API call fails with a 404 Not Found error instead of returning the user's lastSignInDate, indicating a potential issue with the endpoint, permissions, or query syntax.
Verify that your PowerShell environment has the latest Microsoft Graph PowerShell SDK installed and ensure your script is targeting the correct API endpoint.
Verify API Permissions and Authentication Scopes
Ensure your PowerShell session or App Registration has the correct permissions required to read sign-in logs.
The lastSignInDate is part of the signInActivity resource. To read this property, your application must have specific permissions granted by an administrator, otherwise the Graph API may return a 404 or 403 error.
Ensure that your managed identity or App Registration has the 'AuditLog.Read.All' and 'Directory.Read.All' permissions assigned in the Azure Portal.
Navigate to Azure Active Directory > App registrations > API permissions, and click 'Grant admin consent' for your tenant.
Run 'Connect-MgGraph -Scopes "AuditLog.Read.All","Directory.Read.All"' to ensure your current PowerShell session has the appropriate scopes applied.
Consult the Microsoft PowerShell Community
Engage with specialists to review your specific script implementation and API response.
Switch to WPS Office for a Streamlined Document Experience
While resolving PowerShell and Azure AD API errors requires specialized IT administration, your daily document tasks shouldn't be complicated. WPS Office provides a free, lightweight, and highly compatible alternative to Microsoft Office for all your word processing, spreadsheet, and presentation needs.
- 1. Download the Installer: Visit the official WPS Office website and click the free download button for your operating system.
- 2. Install WPS Office: Run the downloaded installation file and follow the simple on-screen instructions to set up the suite.
- 3. Open Your Files: Launch WPS Office and instantly open or edit your existing Microsoft Word, Excel, and PowerPoint files without formatting loss.

Frequently Asked Questions
Why does Microsoft Graph return a 404 error for a user that exists?
A 404 error often occurs if the specific property, such as lastSignInDate, is queried using an incorrect endpoint, or if the calling application lacks the required scopes (like AuditLog.Read.All) to access sign-in logs, causing the resource to appear as 'not found' to the script.
Which endpoint should I use to get the lastSignInDate?
While sign-in activity is transitioning to the v1.0 endpoint, some environments or specific properties still require targeting the beta endpoint (https://graph.microsoft.com/beta/users) to successfully retrieve the signInActivity object.
How can I check my Microsoft Graph PowerShell module version?
You can check your installed module version by running the command 'Get-InstalledModule -Name Microsoft.Graph' in your PowerShell console. Keeping the module updated ensures compatibility with the latest API changes.




