Get-Mailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox,SharedMailbox | Group-Object -Property:Database | Select-Object Name,Count | Sort-Object Name | Format-Table -Auto
One-liners:
Show all users in Active Directory with “password never expires”:
get-aduser -filter * -properties Name, PasswordNeverExpires | where { $_.passwordNeverExpires -eq "true" } | where {$_.enabled -eq "true"} | Format-Table -Property Name, PasswordNeverExpires -AutoSize
Show last login time, in sorted format for computerobjects:
Get-ADComputer -Filter * -Properties * | Sort LastLogonDate | FT Name, LastLogonDate -Autosize
Show last login time, in sorted format for userobjects:
Get-ADUser -Filter * -Properties * | Sort LastLogonDate | FT Name, LastLogonDate -Autosize
Getting number of Excahnge mailboxes, with or wirhout shared:
Get-Mailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox,SharedMailbox | Group-Object -Property:Database | Select-Object Name,Count | Sort-Object Name | Format-Table -Auto
For removing a email alias, already “stamped” on your users in Exchange via email address policies:
$allmailboxes = get-mailbox
$allmailboxes |% {$a = $_.emailaddresses; $b = $_.emailaddresses; foreach ($e in $a) {if ($e.tostring() -match “removethisdomain.com”) {$b -= $e;}}$_ | set-mailbox -emailaddresses $b}
Show all AD users with Displayname and Email Address:
Get-ADUser -Filter * -Properties DisplayName, EmailAddress, Title | select DisplayName, EmailAd
dress