PowerShell - Exchange - Export PST for disabled UserMailboxes AD Accounts - 90 days RRS feed

  • Question

  • Hi,

    I'm a beginner in scripting. 

    I want to make a script to export PST for AD Users disabled since 90 days with a mailbox attached. (AD account disabled, not the Exchange one)

    I have found a command to get the list but not with the "90 days" condition :

    get-user -resultsize unlimited | ?{$_.useraccountcontrol -like "*accountdisabled*" -and $_.recipienttype -eq "usermailbox" -and $ -notlike "Discovery*"}

    It's almost perfect because it is just "UserMailbox" and no "DiscoveryMailboxes". Get-User is for Exchange only.

    I have found elsewhere a cmdlet to get all the AD accounts disabled since 90 days :

    get-aduser -filter 'enabled -eq $false' -Properties samaccountname,lastlogondate | Where-object {$_.lastlogondate -lt (get-date).AddDays(-90)} | select userprincipalname

    The problem is that it uses the Get-ADUser cmdlet, not the Get-User one... And I have public folders and Discovery Mailboxes too...

    Is there a way to pipe a PowerShell command to the "get-user" one in order to store the results in a variable ?

    I want to use it after for the New-MailboxExportRequest cmdlet.

    I wish you understand my English. Thank you for your help ! :)

    • Edited by Jérôme DUMET Wednesday, May 30, 2018 4:25 AM
    • Moved by Bill_Stewart Friday, July 27, 2018 8:46 PM This is not "scripts on demand"
    Wednesday, May 30, 2018 4:24 AM

All replies