Quantcast
Channel: Exchange Server 2013 - General Discussion forum
Viewing all articles
Browse latest Browse all 13303

Script to search Two OU's and disable mailboxes that 160 days without logging in.

$
0
0

I have been tasked with setting up a scheduled job to disable mailboxes that have not logged in in the last 160 days from users that are in two particular OU's and then output the usernames that have been disabled for auditing purposes.

I have started piecing this together but keep running into roadblocks. Has anyone done anything similar to this?

Below is what I have so far.

@(
"stormontvail.org/_users/graveyard"
"stormontvail.org/_users/disabled"
) | % {
Get-MailBox -ResultSize Unlimited  -OrganizationalUnit $_ | Get-MailboxStatistics -resultsize unlimited |? {$_.Lastlogontime -lt (get-date).AddDays(-160)} > C:\Scripts\MailboxCleanup\log\CleanupLog.txt

I do apologize but I am a novice scripter so be gentle with me.

Also this is Exchange 2010.



Viewing all articles
Browse latest Browse all 13303

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>