Una piattaforma stabile di e-mail, calendario e collaborazione sviluppata da Microsoft, progettata per comunicazione e gestione dei dati di livello enterprise.Argomenti vari che non rientrano in categorie specifiche.
Welcome to the Microsoft Q&A platform!
I will be using a user who has not logged in for 7 days as an example, you can try the following script:
$cutoffDate = (Get-Date).AddDays(-30)
$mailboxes = Get-Mailbox -ResultSize Unlimited
$inactiveUsers = @()
foreach ($mailbox in $mailboxes) {
$lastLogonTime = (Get-MailboxStatistics -Identity $mailbox.Alias).LastLogonTime
if ($lastLogonTime -lt $cutoffDate) {
$userInfo = New-Object PSObject -Property @{
DisplayName = $mailbox.DisplayName
UserPrincipalName = $mailbox.UserPrincipalName
LastLogonTime = $lastLogonTime
}
$inactiveUsers += $userInfo
}
}
$inactiveUsers | Export-Csv -Path "C:\InactiveUsers.csv" -NoTypeInformation
Write-Output "succeed:C:\InactiveUsers.csv"
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".