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!
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"
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |