Category Archives: Exchange

Microsoft Exchange Posts

Add a list of users to a Distribution Group with log file

This script will add a list of users in a text file to Distribution group and output the results to a log file.

Import-Module ActiveDirectory ## Use AD Snapin
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin ## Use Exchange 2007 Snapin
$AdminSessionADSettings.ViewEntireForest = $true ##Search Entire Forest

Get-Content ‘C:\Userlist.txt’ | %{
$User = $_
Try {
Add-DistributionGroupMember ‘GroupName’ -Member $User -EA STOP
Echo $User $_.exception.Message
} | Out-File C:\scriptlog.txt

Facebooktwittergoogle_pluslinkedinby feather

Get ActiveSync Details for users in an OU

The below script will show ActiveSync details for users in an OU, this script also only reports devices that have synced after a specified date.

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin

Get-Mailbox -ResultSize:Unlimited -OrganizationalUnit domain.local/OU | ? {$_.Organizationalunit -eq "domain.local/OU "} | ForEach {Get-ActiveSyncDeviceStatistics -Mailbox:$_.Identity} | Where {$_.LastSuccessSync -gt '01/01/2014'} | ft -AutoSize Identity,DeviceType,DeviceID,DeviceModel,LastSuccessSync
Facebooktwittergoogle_pluslinkedinby feather

Get Users AD Account from EMail Address

This script will take a list of email address and return the users AD info, I have enabled View Entire Forest, in case your are in a multi domain environment.

Import-Module ActiveDirectory
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
$AdminSessionADSettings.ViewEntireForest = $true
Get-Content C:\EmailList.txt | Get-Mailbox | FT SamAccountName,Alias,PrimarySMTP
Facebooktwittergoogle_pluslinkedinby feather