To check the last sign-in date of an Azure AD user with PowerShell, you can use the `Get-AzureADAuditSignInLogs` cmdlet. This cmdlet retrieves the sign-in logs for Azure AD users and can be filtered to get the last sign-in date for a specific user or all users [1][5].
Here's an example PowerShell script that retrieves the last sign-in date for all users in Azure AD:
```powershell
Connect-AzureAD
$users = Get-AzureADUser -All $true
foreach ($user in $users) {
$signInLogs = Get-AzureADAuditSignInLogs -UserId $user.ObjectId -Top 1
if ($signInLogs.Count -gt 0) {
$lastSignIn = $signInLogs[0].createdDateTime
} else {
$lastSignIn = "Never"
}
Write-Output "$($user.DisplayName): $lastSignIn"
}
```
This script first connects to Azure AD using `Connect-AzureAD`. It then retrieves all users in Azure AD using `Get-AzureADUser`. For each user, it retrieves the sign-in logs using `Get-AzureADAuditSignInLogs` and filters to get the most recent sign-in log. If there are no sign-in logs for the user, it sets the last sign-in date to "Never". Finally, it outputs the user's display name and last sign-in date [1].
Note that you need to have the AzureAD PowerShell module installed and authenticated to run this script. You can install the module using the following command:
```powershell
Install-Module AzureAD
```
You also need to have the appropriate permissions to access the sign-in logs for Azure AD users [1][5].