Last active
December 15, 2015 07:59
-
-
Save ringe/5227717 to your computer and use it in GitHub Desktop.
Say you want to export all your Exchange mailboxes to PST files, but would like to know which Active Directory "Windows" user names the mailboxes belongs to. Turns out it's not straightforward, unless there's something I don't get. First: Export a list of all AD users by their name, including their username - the one used in "DOMAIN\username", y…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Then this in Exchange Management Shell | |
$Location = "\\server\pstexport" | |
New-Item -path $Location -name "migrate.txt" -type File -force | |
Add-Content "$Location\migrate.txt" "datasourceuser,destinationuser" | |
# Create a hash table of Exchange mailboxes | |
$mailboxes = @{} | |
Get-Mailbox | Select-Object name, alias | | |
ForEach-Object { $mailboxes.Add($_.name, $_.alias) } | |
$reader = [System.IO.File]::OpenText("c:\allusers.txt") | |
try { for(;;) { | |
$line = $reader.ReadLine() | |
if ($line -eq $null) { break } | |
# process the line | |
$name, $SamAccountName = $line.Split(",") | |
$ss = $name, $SamAccountName, $alias | |
$alias = $mailboxes.Get_Item("$name") | |
$ismbx = $mailboxes.ContainsKey($name) | |
$notspecial = $alias -notmatch [regex]::escape("{") | |
if (($ismbx) -and ($notspecial)) { | |
New-MailboxExportRequest -Mailbox $alias -FilePath "$Location\$alias.pst" | |
Add-Content "$Location\migrate.txt" "$alias.pst,$SamAccountName" | |
} | |
} } | |
finally { | |
$reader.Close() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run this in the Active Directory Module for Powershell | |
Get-ADUser -Filter * -Properties Name | | |
select-object name,SamAccountName | | |
convertto-csv -NoTypeInformation | | |
% { $_ -replace '"', ""} | | |
out-file c:\allusers.txt -fo -en unicode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Maybe you find use for this with Zarafa: | |
http://doc.zarafa.com/trunk/Migration_Manual/en-US/html-single/ | |
Download the tool here: | |
http://download.zarafa.com/community/final/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great project to export mailboxes by identifying Active directory user name. However exchange server gets corrupted or peoples want an automated way to export exchange mailboxes into pst file then help of an excellent exchange edb converter ( http://www.pcvita.com/export-exchange-mailbox.html ) is much appreciated. As I know, this is a way only to export mailboxes from offline or dismounted or corrupted edb file.