Articles

Simple Exchange 2010 Export Script- ExchangeManagement Shell

December 11, 2012 at 14:03:39
Specs: Server 2008

I would like to modify an old script (keep in mind half of s--- is in Exchange Management Shell and the other half regular commands)

Essentially I am looking to pull from active directory the display name and export the mailbox to a share while naming the file with "displayname" and "lanID"

The lan id will be manually supplied. I am open to suggestions on better ways to do this. I am looking for the .pst files to be easily identified without looking up the user. Thus grabbing the display name from AD.

for /f "tokens=2*" %%a in ('net user "%LanID%" /domain ^| find /i "Full Name"') do set DisplayName=%%b"
New-MailboxExportRequest -Mailbox LANID -FilePath "\\share\d$\export\"%displayname%-%LanID%.pst
"

It took me forever to piece together what I have so far. I am a noob.

Thank you!


See More: Simple Exchange 2010 Export Script- ExchangeManagement Shell

Report •


#1
December 13, 2012 at 09:52:56

CMD and Powershell don't mix particularly well, so your best bet is to stick to one environment. PowerShell's the obvious choice, as the Exchange bits require PowerShell.

This is untested, as I don't have access to the Exchange cmdlets.

$user = ([ADSISearcher]"(&(ObjectClass=user)(name=$env:LanID))").FindOne()
New-MailboxExportRequest -Mailbox $user.Properties.cn -FilePath "\\share\d$\export\$($user.Properties.displayname)-$($user.Properties.cn).pst"

How To Ask Questions The Smart Way


Report •
Related Solutions


Ask Question