Exchange 2007 view all the Send-As permissions

When you want an overview of all the Send-As permissions configured on all the mailboxes in your environment, you can use the following command in the Exchange Management Console.

Get-Mailbox | Get-ADPermission | where {($_.ExtendedRights -like “*Send-As*”) -and -not ($_.User -like “NT AUTHORITY\SELF”)} | Ft -wrap


When you want the Send-As permissions configured on one specific mailbox, you can add the -identity switch. For example:

Get-Mailbox -identity systeembeheer | Get-ADPermission | where {($_.ExtendedRights -like “*Send-As*”) -and -not ($_.User -like “NT AUTHORITY\SELF”)} | Ft -wrap


Exchange 2007 create new Storage Groups with Mailbox Database

After a default Exchange 2007 SP1 installation, there is one Storage Group with one Mailbox Database available and mounted. You have to change the logfile path and database path manually. If you use the following script, you can create one, two, three, four (or more) Storage Groups and Databases fully automatic. Let’s say you’ve installed a new Exchagne 2007 server with three partitions.

# This script creates two storage groups named SG1 and SG2, with mailbox stores MB1 and MB2, and finally mounts them.
# C: – Operating System
# D: – Exchange Logfiles/Systemfiles
# E: – Exchange Databases

# Environment variables
$server = “srv-ex01”
$logfilepath = “D:\Log”
$mbxfilepath = “E:\Database”

# Creating the Storage Groups and Mailbox Stores
foreach (
$i in (1,2,3,4)
new-storagegroup -name SG$i -server $server -logfolderpath “$logfilepath\SG$i” -systemfolderpath “$logfilepath\SG$i”
foreach (
$i in (1,2,3,4)
new-mailboxdatabase -storagegroup $server\SG$i -name MB$i -edbfilepath “$mbxfilepath\MB$i\MB$i.edb”
mount-database MB$i

Exchange 2007 Send Mailbox sizes with PowerShell

It could be verry usefull to receive a overview of all the mailbox sizes in your environments every day, week or month. You can see verry quickly when a users mailbox is growing to fast….The easiest way is to automate this, so i’ve made a PowerShell script to do this for me 🙂

$body = Get-MailboxStatistics | sort-object -descending totalItemSize | ft DisplayName, @{expression={$_.totalitemsize.value.ToMB()};label=”Mailbox Size(MB)”}, itemcount, lastlogontime | out-string

$From = “administrator@e2k7.local”
$to = “m.swinkels@e2k7.local”
$server = “srv-ex01.e2k7.local”
$subject = “Mailbox overview – srv-ex01.e2k7.local”
$msg = new-object System.Net.Mail.MailMessage $From, $to, $subject, $body
$client = new-object System.Net.Mail.SmtpClient $Server

Copy this script into Notepad and save it as MailboxSizes.ps1. You can schedule this script to run every day, or every week using the following command:

C:\WINDOWS\system32\Windowspowershell\v1.0\powershell.exe -PSConsoleFile “D:\ExchSvr\Bin\exshell.psc1” C:\Scripts\MailboxSizes.ps1

The path to Powershell.exe needed to run the script

-PSConsoleFile “D:\ExchSvr\Bin\exshell.psc1”
Loads the specified Windows PowerShell console file. To create a console file
(Change the path to the installation path of Exchange 2007 in your environment)

The path to the script.
(Change the path where you save the script)

When you try to run the script, you may receive an error “Client was not authenticated”.  You have to add the Exchange 2007 Server to an Relay Connector, so that this server can send e-mail without authentication. If you’ve done this and run the script, you’ll receive the following e-mail.


Exchange 2007 mailbox size script V5

Maybe some of you now, Glen Scales has made a PowerShell script to view the mailbox sizes in an Exchange 2007 environment. You can download this script at his blog Script.

It’s a great script, to overview the current mailboxsizes, items, growth history, quota used. Watch the screenshot below, to see the great script of scripting guru Glen 😉

Export Distribution Group details

When you have multiple Distribution Groups in your Exchange 2007 environments and you need an overview of the members per Distribution Group, you want to script this action. Whit the following script you can export all Distribution Groups in an Organizational Unit with the following information: Groupname, Primary SMTP address, Members. This will save a lot of time, while you don’t have to click around all your groups in Active Directory 🙂

All you have to change is the OU$=”edir”.

If your Organizational Unit is called “Distribution Groups“, it will be: OU$=”Distribution Groups”


## This script will get all distrobution Groups and print out
## the Group Name and Members alias and Primary smtp address
## Example
## groupName: Group.Name
## alias               PrimarySmtpAddress
## —-              ——————
## Group.Alias    Group@primarySmtpAddress 
## groupsMembers:
## alias               PrimarySmtpAddress
## —-              ——————
## User.Alias      User@primarySmtpAddress

##input OU path above

foreach($group in Get-DistributionGroup -OrganizationalUnit $Ou)
write-output “GroupName:$group ”
Get-DistributionGroup $group | ft alias,primarysmtpaddress
Write-output “GroupsMembers:”
Get-DistributionGroupMember $group | ft alias,primarysmtpaddress
write-output ‘ ‘

Here you can see the output of the script in the Exchange 2007 test environment.

Total users per storage group

With the following script you can create an overview of all users in the different storage groups. Handy to see how many mailboxes you have in your Exchange 2007 environment 😉

write-host -fore yellow “This script will get each mailboxdatabase and the current user count ”
foreach($name in get-mailboxdatabase)
write-output “$name”
$count=(get-mailbox -database $name).count
if($count -eq $null)
{ write-host -fore red “Empty Database, no users”
{ write-output $count }
write-host -fore yellow “The system has a total of “$user=(get-mailbox -resultsize:unlimited).count
write-host -fore red $user


The output of this script you can see below:

Changing displaynames

After a default Exchange 2003/2007 installation, the Global Address List is displayed as GivenName, SirName. Most of our customers want to change this in SirName, GiveName, so that the users can search on the SirName instead of the GivenName.

With the following script you can change the displaynames of all userobjects in the Domain, or in an Organizational Unit.

The only thing you have to change is: ‘LDAP://OU=edir, DC=e2k7 ,DC=local’. Let’s say your domain is company.lan and the Organizational Unit where the userobject are placed is CompanyUsers, it would be:

“LDAP://OU=CompanyUsers, DC=company, DC=lan’

   On Error Resume Next
 Set con = CreateObject(“ADODB.Connection”)
 con.Provider = “ADsDSOObject”
 set command = CreateObject(“ADODB.Command”)
 set command.ActiveConnection = con
 command.CommandText = “SELECT adsPath, samAccountName,Sn, givenName, DisplayName, userAccountControl FROM ‘LDAP://OU=edir, DC=e2k7 ,DC=local’ WHERE  objectClass = ‘user’ AND samAccountName <> ‘Administrator’ AND samAccountName <> ‘*$’ AND userAccountControl <> 514  ORDER BY samAccountName”
 Set rs = command.Execute
 While not rs.EOF
  set oUser = GetObject(GebruikersNaam)
  oUser.Displayname = rs.fields(“Sn”).value & CHR(44) &” ” &  rs.fields(“givenName”).value
  Set oUser = Nothing
 Set con = nothing
 MSGBox “Klaar!”