Wednesday, July 11, 2012

Exporting Exchange Mailboxes Using Powershell

So we’re doing a mail migration and I want to export the source mailboxes just in case things go awry. We’re using the Quest Exchange Migration manager tool and it’s a magic piece of software – having said that I want the mailboxes backed up in PST format in case a user says a message is missing.

On Exchange 2007 and newer the old Exmerge software is no longer available. It’s been replaced by the powershell commandlet export-mailbox.

Using the command is the easy bit, getting the software in place is the hard bit. For starters you need to run this commandlet of a 32 bit machine. You need the Exchange Management Tools installed on there which in turn relies on IIS. The tools also depend on a local Outlook installation to do all the MAPI work in exporting a mailbox to PST.

Once you’ve got all the above installed the export process is really simple. Using the command below:

Get-Mailbox -Server <server> -sortby Alias | export-mailbox –PSTFolderPath <pstpath>

Breaking the above command down, first we’re getting all the mailboxes on a given server and sorting them by alias. We then pipe the mailboxes to the export-mailbox commandlet which, as the name implies exports the mailbox to a PST file.

There’s a lot of options to the export-mailbox commandlet and the above does the basic export the entire mailbox. It’s possible to do a lot more including exporting messages based on timestamps and content.

Handy Exchange Powershell Commands

I’m really loving the power of powershell (bad pun?) to manage Exchange. Once you’ve got your head around a few basic commands you can do a lot with this tool.

On a side note – don’t get me started on all the features that have been removed from the GUI. Don’t get me wrong, I’m a fan of the command line but when you’re doing a task once the GUI is often faster and easier!

 

Handy Exchange Powershell Query #1 – Give an account full control on all mailboxes

Get-Mailbox | Add-MailboxPermission -User <account> -AccessRights Fullaccess -InheritanceType all

Handy Exchange Powershell Query #2 – Give an account full control at the mail database level

Get-MailboxDatabase | Add-ADPermission -user internal\svc-quest-int -AccessRights GenericAll  

Handy Exchange Powershell Query #3 – Get an item account of a user’s mailbox

get-mailboxStatistics –Identity <alias>

Handy Exchange Powershell Query #4 – Set the default storage quota policy on all mailboxes

get-mailbox | set-mailbox -UseDatabaseQuotaDefaults $true

How To Add Cores To A VMWare Guest

Why would you want to do this? I’ll tell you why. Some software is licensed by the socket meaning you can load up the number of cores you use and still pay for only the sockets used. For example, a single quad-core CPU would cost the same as a single core processor and still cost the same. Windows Standard and SQL Server Standard editions are typical examples of software that works this way.

This leads us to a new problem. When you add CPUs to a VMWare guest it adds the new CPUs as sockets rather than cores. Which in turn means that if you assign 8 CPUs to a Windows Standard server you will only see 4 CPUs!

imageThe way around this is to tell VMWare to present the vCPUs as cores rather than sockets. To do this we change the number of CPUs to the total desired amount. This number must be a multiple of 2 (eg. 2,4,8,16). In this example we’ll use 8 as the total number of cores we want presented to the operating system.

The second number we need to know is how many cores we want to present per socket. This number must divide evenly into the total number of vCPUs listed above. In our example we’ll choose 4 – Ie. 4 cores by 2 sockets –> 8 cores. VMware will automatically determine the number of sockets required by dividing the total number of CPUs (cores) requested by the number of cores per socket specified.

image

This number is assigned to the Configuration Parameter cpuid.corespersocket. This option is found under the guest settings under Options –> Advanced –> General and then click on Configuration Parameters. Add a new row to the bottom called cpuid.corespersocket and set the value as desired (4 in this case).

Save your settings are restart the virtual machine. Opening task manager should now show 8 cores coming from 2 sockets.

Troubleshooting A Failing MSI Install

So I was installing an application the other day when I got the following error message:

The installer was interrupted before Application could be installed. You need to restart the installer to try again.
Click "Close" to exit.

Not very helpful huh? Luckily there’s a way to get more information. It involves running the msiexec command explicitly so that it generates a logfile with more details on how the execution failed. The command looks like this:

msiexec /package <package.msi>" /l*vx "c:\setup.log"

The /l switch tells msiexec to log installation information to the logfile specified. A lot of information can get piped into this logfile but nonetheless its a handy way to find out what’s happening inside the installation process.