How to export an entire OUs mailboxes to individual PST files?

Hi guys,

I have an OU where I put all my disabled past users when they leave the company.

Is there a PS script or command that will bulk export all users mailboxes from that OU to their own individual PST files?

We are using Exchange 2010 SP1 on Server 2008 x64 R2 Std ed.

Cheers,
AC
defectaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sumit GuptaSystem and Virtualization EngineerCommented:
Here's:

# Exchange 2010 SP1 Mailbox Export Script
 # Steve Goodman. Use at your own risk!
 
###############
 # Settings #
 ###############
 
# Pick ONE of the two below. If you choose both, it will use $Server.
 $Server = "server"
 $Database = ""
 $OU = ""
 
# Share to export mailboxes to. Needs R/W by Exchange Trusted Subsystem
 # Must be a UNC path as this is run by the CAS MRS service.
 $ExportShare = "\\server\share"
 
# After each run a report of the exports can be dropped into the directory specified below. (The user that runs this script needs access to this share)
 # Must be a UNC path or the full path of a local directory.
 $ReportShare = "\\server\share"
 
# Shall we remove the PST file, if it exists beforehand? (The user that runs this script needs access to the $ExportShare share)
 # Valid values: $true or $false
 $RemovePSTBeforeExport = $false
 
###############
 # Code #
 ###############
 
if ($Server)
 {
 if (!(Get-ExchangeServer $Server -ErrorAction SilentlyContinue))
 {
 throw "Exchange Server $Server not found";
 }
 if (!(Get-MailboxDatabase -Server $Server -ErrorAction SilentlyContinue))
 {
 throw "Exchange Server $Server does not have mailbox databases";
 }
 $Mailboxes = Get-Mailbox -Server $Server -ResultSize Unlimited
 } elseif ($Database) {
 if (!(Get-MailboxDatabase $Database -ErrorAction SilentlyContinue))
 {
 throw "Mailbox database $Database not found"
 }
 $Mailboxes = Get-Mailbox -Database $Database -ResultSize Unlimited
 } elseif ($OU) {
 $Mailboxes = Get-Mailbox -OrganizationalUnit $OU -ResultSize Unlimited
 }

 if (!$Mailboxes)
 {
 throw "No mailboxes found"
 }
 
 
if (!$Mailboxes.Count)
 {
 throw "This script does not support a single mailbox export."
 }
 
# Pre-checks done
 
# Make batch name
 $date=Get-Date
 $BatchName = "Export_$($date.Year)-$($date.Month)-$($date.Day)_$($date.Hour)-$($date.Minute)-$($date.Second)"
 
Write-Output "Queuing $($Mailboxes.Count) mailboxes as batch '$($BatchName)'"
 
# Queue all mailbox export requests
 foreach ($Mailbox in $Mailboxes)
 {
 
if ($RemovePSTBeforeExport -eq $true -and (Get-Item "$($ExportShare)\$($Mailbox.Alias).PST" -ErrorAction SilentlyContinue))
 {
 Remove-Item "$($ExportShare)\$($Mailbox.Alias).PST" -Confirm:$false
 }
 New-MailboxExportRequest -BatchName $BatchName -Mailbox $Mailbox.Alias -FilePath "$($ExportShare)\$($Mailbox.Alias).PST"
 }
 
Write-Output "Waiting for batch to complete"
 
# Wait for mailbox export requests to complete
 while ((Get-MailboxExportRequest -BatchName $BatchName | Where {$_.Status -eq "Queued" -or $_.Status -eq "InProgress"}))
 {
 
sleep 60
 }
 
# Write reports if required
 if ($ReportShare)
 {
 Write-Output "Writing reports to $($ReportShare)"
 $Completed = Get-MailboxExportRequest -BatchName $BatchName | Where {$_.Status -eq "Completed"} | Get-MailboxExportRequestStatistics | Format-List
 if ($Completed)
 {
 $Completed | Out-File -FilePath "$($ReportShare)\$($BatchName)_Completed.txt"
 }
 $Incomplete = Get-MailboxExportRequest -BatchName $BatchName | Where {$_.Status -ne "Completed"} | Get-MailboxExportRequestStatistics | Format-List
 if ($Incomplete)
 {
 $Incomplete | Out-File -FilePath "$($ReportShare)\$($BatchName)_Incomplete_Report.txt"
 }
 }
 
# Remove Requests
 Write-Output "Removing requests created as part of batch '$($BatchName)'"
 Get-MailboxExportRequest -BatchName $BatchName | Remove-MailboxExportRequest -Confirm:$false

Open in new window


Edit $OU to specify your specific OU at the top of the script. I've not tested this, just edited it as I cut and pasted it in.

you can also check this link
http://www.stevieg.org/2010/07/using-the-exchange-2010-sp1-mailbox-export-features-for-mass-exports-to-pst/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Praveen BalanSolution ArchitectCommented:
You may use the below powershell script to export the PSTs,


foreach ($i in (Get-Mailbox -ResultSize Unlimited|Where {$_.OrganizationalUnit -eq "domain.local/OU_Name"})) { New-MailboxExportRequest -Mailbox $i -FilePath "\\ExchSrv1\pst\$($i.Alias).pst" }

ensure that you have created the share \\ExchSrv1\pst

refer the article below, I have explained it in detail.

http://www.exchangedictionary.com/index.php/Exchange-Dictionary/how-to-export-mailboxes-to-pst-exchange-server-2010.html


-Praveen
0
defectaAuthor Commented:
Thanks Steve for your extremely thorough reply.

Stupid question but I thought it best to ask rather than to assume, this doesn't remove content from the targeted mailboxes does it? It merely exports a copy out? I.e. if it doesn't work as expected I can try again without risk of losing data?
0
Webinar: Miercom Evaluates Wi-Fi Security

It's not just about Wi-Fi connectivity anymore. A wireless security breach can cost your business large amounts of time, trouble, and expense. Plus, hear first-hand from Miercom how WatchGuard's Wi-Fi security stacks up against the competition in our upcoming webinar!

Praveen BalanSolution ArchitectCommented:
the export-pst using  New-MailboxExportRequest will not remove data, it will just copy the data.

-Praveen
0
Sumit GuptaSystem and Virtualization EngineerCommented:
yes, you can try it without fear of loosing data. its just for export.
0
defectaAuthor Commented:
Ok so I dont appear to have the command required to do the mailbox exports.

[PS] C:\Windows\system32>New-MailboxExportRequest -Mailbox user -FilePath "\\server\Exports\user.pst"
The term 'New-MailboxExportRequest' is not recognized as the name of a cmdlet, function, script file, or operable progr
am. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:25
+ New-MailboxExportRequest <<<<  -Mailbox user -FilePath "\\server\Exports\user.pst"
    + CategoryInfo          : ObjectNotFound: (New-MailboxExportRequest:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Open in new window


I thought we were fully patched and on the latest version of Exchange.

Stupid question: What is the best way to check that?
EDIT: Noob mistake. I think its becuase I am executing the command with a different user than the one I gave the privilleges to. Will report back.
0
Praveen BalanSolution ArchitectCommented:
The error seems to be because of the permission issues,

add the account used for PST export to the role "Mailbox Import Export", you may use below cmdlet syntax.

New-ManagementRoleAssignment –Role "Mailbox Import Export" –User account_name

to get the exchange version, use Get-ExchangeServer |fl Name,AdminDisplayVersion
0
defectaAuthor Commented:
yep got it. thx.
0
defectaAuthor Commented:
So i have been able to successfully export a single mailbox to a specified network share but running the customised script I am getting the following error.

Queuing 27 mailboxes as batch 'Export_2013-9-26_15-40-19'
The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

The server or share name specified in the path may be invalid, or the file could be locked.
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
    + FullyQualifiedErrorId : ADDAABCD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

Waiting for batch to complete
Writing reports to \\server\export
Removing requests created as part of batch 'Export_2013-9-26_15-40-19'

Open in new window


I counted the number of mailboxes in the OU I am trying to export and there are 29 but the script is saying it can only find 27. I'm obviously doing something wrong but I dont know what. And if it was permissions I wouldn't have thought I would be able to have exported that single mailbox would I?

Here is a copy of the script im using with the server details etc anonymised for security.

# Exchange 2010 SP1 Mailbox Export Script
 # Steve Goodman. Use at your own risk!
 
###############
 # Settings #
 ###############
 
# Pick ONE of the two below. If you choose both, it will use $Server.
 $Server = ""
 $Database = ""
 $OU = "Disabled Users"
 
# Share to export mailboxes to. Needs R/W by Exchange Trusted Subsystem
 # Must be a UNC path as this is run by the CAS MRS service.
 $ExportShare = "\\server\export"
 
# After each run a report of the exports can be dropped into the directory specified below. (The user that runs this script needs access to this share)
 # Must be a UNC path or the full path of a local directory.
 $ReportShare = "\\server\export"
 
# Shall we remove the PST file, if it exists beforehand? (The user that runs this script needs access to the $ExportShare share)
 # Valid values: $true or $false
 $RemovePSTBeforeExport = $false
 
###############
 # Code #
 ###############
 
if ($Server)
 {
 if (!(Get-ExchangeServer $Server -ErrorAction SilentlyContinue))
 {
 throw "Exchange Server $Server not found";
 }
 if (!(Get-MailboxDatabase -Server $Server -ErrorAction SilentlyContinue))
 {
 throw "Exchange Server $Server does not have mailbox databases";
 }
 $Mailboxes = Get-Mailbox -Server $Server -ResultSize Unlimited
 } elseif ($Database) {
 if (!(Get-MailboxDatabase $Database -ErrorAction SilentlyContinue))
 {
 throw "Mailbox database $Database not found"
 }
 $Mailboxes = Get-Mailbox -Database $Database -ResultSize Unlimited
 } elseif ($OU) {
 $Mailboxes = Get-Mailbox -OrganizationalUnit $OU -ResultSize Unlimited
 }

 if (!$Mailboxes)
 {
 throw "No mailboxes found"
 }
 
 
if (!$Mailboxes.Count)
 {
 throw "This script does not support a single mailbox export."
 }
 
# Pre-checks done
 
# Make batch name
 $date=Get-Date
 $BatchName = "Export_$($date.Year)-$($date.Month)-$($date.Day)_$($date.Hour)-$($date.Minute)-$($date.Second)"
 
Write-Output "Queuing $($Mailboxes.Count) mailboxes as batch '$($BatchName)'"
 
# Queue all mailbox export requests
 foreach ($Mailbox in $Mailboxes)
 {
 
if ($RemovePSTBeforeExport -eq $true -and (Get-Item "$($ExportShare)\$($Mailbox.Alias).PST" -ErrorAction SilentlyContinue))
 {
 Remove-Item "$($ExportShare)\$($Mailbox.Alias).PST" -Confirm:$false
 }
 New-MailboxExportRequest -BatchName $BatchName -Mailbox $Mailbox.Alias -FilePath "$($ExportShare)\$($Mailbox.Alias).PST"
 }
 
Write-Output "Waiting for batch to complete"
 
# Wait for mailbox export requests to complete
 while ((Get-MailboxExportRequest -BatchName $BatchName | Where {$_.Status -eq "Queued" -or $_.Status -eq "InProgress"}))
 {
 
sleep 60
 }
 
# Write reports if required
 if ($ReportShare)
 {
 Write-Output "Writing reports to $($ReportShare)"
 $Completed = Get-MailboxExportRequest -BatchName $BatchName | Where {$_.Status -eq "Completed"} | Get-MailboxExportRequestStatistics | Format-List
 if ($Completed)
 {
 $Completed | Out-File -FilePath "$($ReportShare)\$($BatchName)_Completed.txt"
 }
 $Incomplete = Get-MailboxExportRequest -BatchName $BatchName | Where {$_.Status -ne "Completed"} | Get-MailboxExportRequestStatistics | Format-List
 if ($Incomplete)
 {
 $Incomplete | Out-File -FilePath "$($ReportShare)\$($BatchName)_Incomplete_Report.txt"
 }
 }
 
# Remove Requests
 Write-Output "Removing requests created as part of batch '$($BatchName)'"
 Get-MailboxExportRequest -BatchName $BatchName | Remove-MailboxExportRequest -Confirm:$false

Open in new window


Any ideas folks?
0
Pankaj_401Commented:
If you have their mailboxes either still existing on an Exchange server or if you have any offline EDB available which has their mailboxes in it, I can be done by some tools very easily and will create PSTs for these mailboxes. Connect back for any suggestions on such utility
0
Sumit GuptaSystem and Virtualization EngineerCommented:
This is set for all the users.. but for the time being, you can export the pst for remaining 2 users using command:

New-ManagementRoleAssignment –Role "Mailbox Import Export" –User Administrator

C:\>New-MailboxExportRequest -Mailbox alan.reid -FilePath \\esp-ho-ex2010a\pst\alan.reid.pst

C:\>Get-MailboxExportRequest

C:\>Get-MailboxExportRequest -Name MailboxExport | fl

C:\>Get-MailboxExportRequest | Get-MailboxExportRequestStatistics

C:\>Get-MailboxExportRequest | where {$_.status -eq "Completed"} | Remove-MailboxExportRequest

Reference: http://exchangeserverpro.com/export-mailboxes-exchange-server-2010-sp1/
0
defectaAuthor Commented:
Sumitgupta85, what is your post in response to? I don't see how that relates to my last question above.
0
Praveen BalanSolution ArchitectCommented:
Have you tried using the powershell cmdlet shared earlier in this discussion ?
0
defectaAuthor Commented:
Hi, PraveenBalan, no I have not, only because I was already pursuing the solution provided before yours. I will try that now as I dont seem to be getting anywhere with that one and yours appears to be much simpler.
0
defectaAuthor Commented:
I have tried the commandlet you provided changed the OU name and the server name for the exported PST files and after pausing for about 20 seconds it just returns me to the command prompt without any export requests being queued up. There are no errors or success messages reported. Executing
"Get-MailboxExportRequest | Get-MailboxExportRequestStatistics"

Open in new window

also returns just a command prompt without any messages without pause.

I am unsure on how to proceed given the complete lack of any error or success message.
0
Praveen BalanSolution ArchitectCommented:
post the complete cmdlet you have executed to comment on..

also execute below cmdlet and ensure that you get all users under the specified OU,

Get-Mailbox -ResultSize Unlimited|Where {$_.OrganizationalUnit -eq "domain.local/OU_Name"}

if the cmdlet completes without any error and no export, means there is some issue on the filtering criteria.
0
defectaAuthor Commented:
The commandlet I used is exactly the one you sent in your first reply but with the server name and OU changed.

Executing
Get-Mailbox -ResultSize Unlimited|Where {$_.OrganizationalUnit -eq "domain.local/OU_Name"}

Open in new window

doesn't return anything either.
But
Get-Mailbox -OrganizationalUnit "OU_Name" -ResultSize Unlimited

Open in new window

does.

So I tried this (without the domain name this time, like above)
Get-Mailbox -ResultSize Unlimited|Where {$_.OrganizationalUnit -eq "OU_Name"}

Open in new window

which didn't return any result again.

Is there a syntax error in the "where" string or something?

Actually, why cant my variation of your command be used instead of yours? It returns the same results, does it not?
0
Praveen BalanSolution ArchitectCommented:
I did not understand the reason for last sentence,

The above cmdlet will only gather the mailoboxes directly uder the OU, and will not show result of nested OU.

try below set of cmdlet and let me know the status,

Set-ADServerSettings -RecipientViewRoot domain.local/ToBeDeleted_OUName

and then execute Get-Mailbox
and see if you are able to see the mailboxes.

to set back to domain root level Set-ADServerSettings -RecipientViewRoot domain.local
0
defectaAuthor Commented:
I have followed your steps above and i was able to see the mailboxes for just the disabled users OU. I was also able to set it back to the root level of the domain and see the entire list of mailboxes using Get-Mailbox. But if I use
Get-Mailbox -ResultSize Unlimited|Where {$_.OrganizationalUnit -eq "domain.local/OU_Name"}

Open in new window

it again returns nothing.

What I mean by the last sentence was, is the command that I used to get the mailboxes from the secified OU
Get-Mailbox -OrganizationalUnit "OU_Name" -ResultSize Unlimited

Open in new window

able to be used instead of
Get-Mailbox -ResultSize Unlimited|Where {$_.OrganizationalUnit -eq "domain.local/OU_Name"}

Open in new window

?

Isn't the code inside the curly braces just a more complicated way of getting the same result? Or is it functionally different and replacing it for my version not possible for some reason I am yet to understand?
0
Jon BrelieSystem ArchitectCommented:
Looks like you still have a permissions issue on the share.  Make sure that the following users have RW on both share and NTFS permissions:

Exchange Trusted Subsystem
ExchangeServer (ie: the computer object that you are running the powershell command from)

When applying permissions for the exchange server, you have to select "object types" and check the box for computers too.  Otherwise you only get groups and users.
0
defectaAuthor Commented:
Sorry stupid question. What share? Where the Exchange mailstore resides?

Would you mind spelling out exactly how to fix the permissions you mention?

Thanks in advance.
0
Jon BrelieSystem ArchitectCommented:
As previously stated, you must export to a UNC path.  Thus, there must be something shared to access via UNC.  You must grant the listed objects Read/Write to both the NTFS permissions AND the Share permissions.

For example, you are exporting to \\myServer\EmailExports
Login to MyServer and browse to the folder shared out as "emailExports"
Right click, properties and click the sharing tab.  Modify share permissions as instructed
Then click the security tab and modify NTFS permissions as instructed.
0
defectaAuthor Commented:
Sorry thanks. ( I did preface with "stupid question". :P )
0
Jon BrelieSystem ArchitectCommented:
No such thing.  I was only recapping to make sure we hadn't missed a step.
0
defectaAuthor Commented:
So its all working now but I would like to make a change to the exported mailbox names to include the date. Reusing the $BatchName variable would be suitable.

@sumitgupta85: Is this the correct syntax for using the $BatchName variable in the file name?

# Queue all mailbox export requests
 foreach ($Mailbox in $Mailboxes)
 {
 
if ($RemovePSTBeforeExport -eq $true -and (Get-Item "$($ExportShare)\$($Mailbox.Alias)$($BatchName).PST" -ErrorAction SilentlyContinue))
 {
 Remove-Item "$($ExportShare)\$($Mailbox.Alias)$($BatchName).PST" -Confirm:$false
 }
 New-MailboxExportRequest -BatchName $BatchName -Mailbox $Mailbox.Alias -FilePath "$($ExportShare)\$($Mailbox.Alias)$($BatchName).PST"
 }
 
Write-Output "Waiting for batch to complete"

Open in new window

0
defectaAuthor Commented:
I answered my last question myself. I was correct with my code changes to add the export date to the name.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Exchange

From novice to tech pro — start learning today.