Posts

Get smallest Exchange Database in PowerShell

SNAGHTML1ca684c

I needed to adapt some scripts that create a user with mailbox for Exchange 2010. The existing scripts had a hardcoded database for new mailboxes.

I wanted the mailbox to be created in the smallest database, but how do we determine this?

For Exchange 2010 this is fairly easy using PowerShell:

# Add Exchange Snapins
if ((Get-PSSnapin | where {$_.Name -match "Exchange.Management"}) -eq $null) { Add-PSSnapin Microsoft.Exchange.Management.* }

# Get largest possible size
$size = [Microsoft.Exchange.Data.ByteQuantifiedSize]::MaxValue.ToBytes()
foreach ($db in Get-MailboxDatabase -Status)
{
	Write-Host "Database:" $db.Name "Size:" $db.DatabaseSize.ToBytes()

	# Is the Database smaller than previous smallest size
	if ( $db.DatabaseSize.ToBytes() -lt $size )
	{
		# This database is smaller, store size and db
		$size = $db.DatabaseSize.ToBytes()
		$ExDB = $db
	}
}

Write-Host "Smallest Database:" $ExDB.Name "Size:" $ExDB.DatabaseSize.ToBytes()

Set Exchange Product Key with PowerShell

SNAGHTML1ca684c

By default Exchange 2007 and 2010 are installed in Trial mode so before going into production you need to enter the Product Key.

The Exchange Management Console will warn you if one or more servers are still in trial mode:

image

Read more

PowerShell script to set Exchange Static RPC Ports

SNAGHTML1ca684c

I am currently working on an Exchange migration from 2003 to 2010. For the implementation of a load balancing solution for the CAS/HUB servers I needed to set Static RPC Ports for the RPC Client Access Service and the Exchange Address Book Service.

The procedure of changing these ports is described on the Technet Wiki: Configure Static RPC Ports on an Exchange 2010 Client Access Server

Since I am lazy I decided to do this with a PowerShell script that would automatically do this for all CAS/HUB servers in my 2010 environment.

Read more

AD Internals: Reset RID Allocation Pool

imageA few days ago I wrote about how RID Allocation Pools work in Active Directory (see AD Internals: Display RID Allocation Pools)

The article includes a script to dump all RID information for the whole domain. I will be using this script, rIDump.ps1 in this article.

In my test environment I had a problem with the RID Allocation Pool on one of the Domain Controllers. I noticed this because I had some duplicate SID’s in the domain.

So I needed to force this Domain Controller to re-allocate a block of RID’s and I wrote a PowerShell script, rIDAlloc.ps1,  to do that:

Before I go on with the script I will explain how we can force a Domain Controller to re-allocate a RID Pool.

First we need to obtain the Domain SID, we can do this by grabbing the objectSid attribute:

$objDomain = New-Object System.DirectoryServices.DirectoryEntry
$objDomainSid = $objDomain.objectSid

Then we need to write the Domain Sid to a special attribute called invalidateRidPool on the directory root (RootDSE).

Read more

Exchange 2010 well-known object entry install error

SNAGHTML1ca684cToday I was testing the installation of Exchange 2010 in a VMWare sandbox environment. We created the sandbox to test migration from a 2003 AD and Exchange environment to 2008 R2 with Exchange 2010.

We used a P2V to get real copies of the Active Directory and the AD upgrade to 2008 R2 was already tested.

But during the Exchange installation in the sandbox I got the following error:

The well-known object entry on the otherWellKnownObjects attribute in the container object CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=zorg,DC=local points to an invalid DN or a deleted object.  Remove the entry, and then rerun the task.

Read more

Exchange 2010 Mailboxsize List with PowerShell

PowerShell is an very powerful script engine that can help you to manage Microsoft platforms, but also VMware and Citrix Products.

Today we are going to use PowerShell to create an list of all the mailboxes in our Exchange 2010 organization. The extra information we want is the number of items in the mailbox and the total size of the mailbox. We want to present this data to our management so we want save the output.

The command in PowerShell we use to accomplish this is:

Get-MailboxStatistics –Server %MAILBOXSERVERNAME% | Sort-Object -Property TotalItemSize -Descending |   Format-Table DisplayName,TotalItemSize,ItemCount > C:OUTPUTOUTPUT.TXT

RE: Installing Windows Features with Windows PowerShell

Recently my colleague Robin Plomp wrote an article about installing features in Window Server 2008 R2 (or Windows 7) with Windows PowerShell scripts:

“I ‘m a big fan of the new version of the Windows server platform. I’ve recently deployed 6 Windows 2008 (64) R2 servers. On one of the servers I am going to install Microsoft Office Communicator 2007 R2. One of the prerequisites is .NET Framework 3.5 SP1. This can be installed in the ServerManager under Features. This means you have to scroll down a long list of Windows Features. There has to be an easier way.
Enter the world of Windows PowerShell!”

Read more

Although PowerShell is a great tool for installing features, or performing other tasks, it isn’t necessary for automated installation of features.
Enter the world op “Deployment Image Servicing and Management(DISM)” or dism.exe (located in the system folder)!!!
Read more

Uitbreiden Email Address Policies

Stel je beheerd de email omgeving van een nationaal bedrijf. Als standaard uitgaand emailadres gebruikt men j.klaassen@bedrijf.nl.

Het bedrijf heeft internationale ambities en wilt graag internationaal gaan adverteren met een .com, .eu, en een .co.uk adres.

Voor het uitbreiden van de Email Address Policy binnen Exchange 2007 gebruik je de Exchange Management Shell (PowerShell)

Het aanpassen van Email Address Policy gebeurt in twee stappen, eerst voer je de wijziging door en daarna laat je de policy ‘lopen’ tegen beschikbare mailboxen.
Bij het samenstellen van het PowerShell commando moet je onthouden dat dit commando de bestaande policy overschrijft, dus de adresdefinities in de reeds bestaande policy moet je hier ook in opnemen anders ben je deze kwijt.

Read more