POWERSHELL

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

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close