Default Reasoning

Construction of sensible guesses when some useful information is lacking and no contradictory evidence is present…

  • Subscribe

  • Disclaimer

    This blog is personal. The views and opinions expressed here represent my own and not those of the people, institutions or organizations that I may or may not be related with unless stated explicitly. All blog post, white papers and manuals were written during the projects, mostly at a customer site and are scenario specific. Use at your own risk.
  • Meta

Archive for the ‘PowerShell’ Category

Export and Import Mailbox data to a PST file on Exchange Server 2007.

Posted by Marek.Z on 11 January 2010

This procedure describes how to export all mailboxes from one Exchange Server to a PST files and how to import the PST files to another Exchange Server in a different domain. Before you begin make sure that: 

  • You have a computer that has Outlook 2003 (SP2) or 2007, Exchange 2007 Management Tools (32-bit version), PowerShell and .NET Framework installed
  • Logon with an account that has Exchange Server Administrator and Local Administrator rights
  • You have full access to the users’ mailbox on both servers. See the note below on how to do it. 
  1. Start the Exchange Management Shell and type the following: [PS] C:\>Get-Mailbox –Database “<Exchange Server FQDN>\<Database Name>” | Export-Mailbox –PSTFolderPath C:\PSTFiles to export all users mailbox to a PST file. Press A for Yes to All. Depending on the size of your database, the export procedure could take a long time to complete.
  2. Now the mailboxes are exported to the PST files, make sure that the PST file name matches the alias of the users’ account in the other domain.
  3. Next, import the PST files to the other Exchange Server by typing the following: [PS] C:\>Get-Mailbox –Database “<Exchange Server FQDN>\<Database Name>” | Import-Mailbox –PSTFolderPath C:\PSTFiles and press A for Yes for All. Wait until the import operation completes.

Note:
To grant the Administrator Full Access rights on the database type the following command:
[PS] C:\>Get-Mailbox -Database “<Exchange Server FQDN>\<Database Name>” | Add-ADPermission -User Administrator -AccessRights GenericAll

Cheers!

- Marek.Z

Posted in Exchange 2007, Microsoft, PowerShell, Scripting | 5 Comments »

Send an e-mail message from PowerShell.

Posted by Marek.Z on 30 June 2009

This small PowerShell script will send you an e-mail message to notify you about something. I used it as a monitor for a custom, non-Microsoft service running on Windows Server 2008. Whenever the service will stop for an unexpected reason, the support guys will quickly be notified about the failure. The PowerShell script looks like this:

$EmailFrom = “<e-mail address>@<yourdomain.com>”
$EmailTo = “<e-mail address>@<otherdomain.com>”
$Subject = “<Enter your subject here>”
$Body = “<Enter the body message here>”
$SmtpServer = “<Enter the FQDN of your SMTP server>”
$smtp = New-Object net.mail.smtpclient($SmtpServer)
$smtp.Send($EmailFrom, $EmailTo, $Subject, $Body)

According to Microsoft Scripting Guys, as a security measure, you can’t start a PowerShell script by double-clicking a .PS1 file. So if you want to run this script from a scheduled task or when a service failure occurs you can create a VBS script that calls the PowerShell script:

Set objShell = CreateObject(“WScript.Shell”)
objShell.Run(“powershell.exe c:\scripts\<script name.ps1>”)

You can copy and paste the code above to create the .PS1 and .VBS script files or you can download the PowerShell script here and the VBS Script here. Change the extension of the files .PS1 and .VBS accordingly.

One last thing; don’t forget to add the Windows PowerShell feature and to set the right PowerShell execution policy on your Windows Server 2008 system :-) .

Posted in PowerShell, Scripting, VBS | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.

Join 429 other followers