Help cannot fin cmd

%3CLINGO-SUB%20id%3D%22lingo-sub-1119960%22%20slang%3D%22fr-FR%22%3EHelp%20cannot%20end%20cmd%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1119960%22%20slang%3D%22fr-FR%22%3E%3CP%3EHi%3C%2FP%3E%3CP%3EI%20try%20to%20get%20some%20data%20from%20Office%20365%20usage%2C%20which%20are%20not%20available%20in%20Microsoft%20365%20Usage%20Analytics.%3C%2FP%3E%3CP%3EWhich%20cmd%20powershell%20will%20get%20me%20the%20mailboxes%20that%20did%20not%20logon%20since%203%20months%3F%20Six%20months%3F%2012%20months%3F%20(I%20don't%20want%20to%20fix%20a%20specific%20date)%3F%20Which%20cmd%20powershell%20will%20Get%20me%20the%20number%20of%20generic%20Mailboxes%3F%20The%20number%20of%20Mailboxes%20without%20any%20License%3F%20Number%20of%20account%20without%20License%3F%26nbsp%3BThe%20number%20of%20Mailboxes%20per%20License%20(E1%2C%20E3...)%3F%20State%20of%20Accounts%3F%20State%20of%20Licenses%20and%20date%20of%20renewing%3F%20Top%2010%20target%20spam%20users%3F%20Who%20are%20the%20spamers%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%20this%20to%20get%20the%20mailboxes%20that%20did%20not%20logged%20since%20the%20date.%20But%2C%20I%20do%20not%20want%20a%20fixed%20date.%20I%20want%20it%20for%20every%203%20last%20month%20for%20example.%20I%20try%20to%20automatize%3C%2FP%3E%3CP%3EGet-Mailbox%20Get-MailboxStatistics%20Where-Object%20.%20LastLogontime%20-lt%20%2209%2F01%2F2019%22%20Select%20DisplayName%20Out-File%20C%3A-Users-GIDOT-AuditLogonMailboxApria.xls%3C%2FP%3E%3CP%3EThanks%20in%20advance%20for%20any%20help.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1119960%22%20slang%3D%22fr-FR%22%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPower%20BI%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1124973%22%20slang%3D%22en-US%22%3ERe%3A%20Help%20cannot%20fin%20cmd%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1124973%22%20slang%3D%22en-US%22%3E%3CP%3EGet-Mailbox%20%7C%20Get-MailboxStatistics%20%7C%20Where-Object%20%7B%24_.LastLogontime%20-lt%20((get-date).addmonths(-3))%7D%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20%5Bdatetime%5D%20object%20has%20many%20methods%20available.%26nbsp%3B%20By%20adding%20a%20negative%20number%2C%20you're%20going%20%22back%20in%20time%22.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAddDays%3CBR%20%2F%3EAddHours%3CBR%20%2F%3EAddMilliseconds%3CBR%20%2F%3EAddMinutes%3CBR%20%2F%3EAddMonths%3CBR%20%2F%3EAddSeconds%3CBR%20%2F%3EAddTicks%3CBR%20%2F%3EAddYears%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi,

I try to get some data from Office 365 usage, that are not available in Microsoft 365 Usage Analytics.

Which cmd powershell will Get me the mailboxes that did not logon since 3 month? 6 month? 12 month? (I do not want to fixe a specific date)? Which cmd powershell will Get me the number of generic Mailboxes ? The number of Mailboxes without any License ? Number of account without License ? The number of Mailboxes per License (E1, E3...) ? State of Accounts ? State of Licenses and date of renewing ? Top 10 target spam users ? Who are the spamers ?

 

I tried this to get the mailboxes that did not logged since the date. But, I do not want a fixed date. I want it for every 3 last month for example. I try to automatize

Get-Mailbox | Get-MailboxStatistics | Where-Object {$_.LastLogontime -lt "09/01/2019"} | Select DisplayName | Out-File C:\Users\GIDOT\AuditLogonMailboxApria.xls

Thanks in advance for any help.

1 Reply

Get-Mailbox | Get-MailboxStatistics | Where-Object {$_.LastLogontime -lt ((get-date).addmonths(-3))}

The [datetime] object has many methods available.  By adding a negative number, you're going "back in time".

 

AddDays
AddHours
AddMilliseconds
AddMinutes
AddMonths
AddSeconds
AddTicks
AddYears