logo
search
Microsoft 365 Error Codes

Fix PowerShell Microsoft Graph 404 Error for User lastSignInDate

Maira MehtabMaira Mehtab Sep 20, 2026 868 views

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.
Before you start

Verify that your PowerShell environment has the latest Microsoft Graph PowerShell SDK installed and ensure your script is targeting the correct API endpoint.

Solution 1Recommended

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.

1
Check Required Permissions

Ensure that your managed identity or App Registration has the 'AuditLog.Read.All' and 'Directory.Read.All' permissions assigned in the Azure Portal.

2
Grant Admin Consent

Navigate to Azure Active Directory > App registrations > API permissions, and click 'Grant admin consent' for your tenant.

3
Reconnect with Correct Scopes

Run 'Connect-MgGraph -Scopes "AuditLog.Read.All","Directory.Read.All"' to ensure your current PowerShell session has the appropriate scopes applied.

Free Microsoft Office alternative

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. 1. Download the Installer: Visit the official WPS Office website and click the free download button for your operating system.
  2. 2. Install WPS Office: Run the downloaded installation file and follow the simple on-screen instructions to set up the suite.
  3. 3. Open Your Files: Launch WPS Office and instantly open or edit your existing Microsoft Word, Excel, and PowerPoint files without formatting loss.
Seamlessly compatible with Microsoft Office formats including .docx, .xlsx, and .pptx.Lightweight software that installs quickly and runs smoothly on older or low-spec devices.Familiar user interface that requires zero learning curve for seamless migration.Built-in PDF editing tools available without requiring separate expensive subscriptions.
microsoft office alternative - wps office

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.