• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 389
  • Last Modified:

Backup users mails into Pst's. exchange 2007.

Hi,

Backup users mails into Pst's. exchange 2007.
Each users Pst into a separate newly created folder with the user name.
Record the success or failures into a txt file. That's a log.
Has to run on disabled user accounts only. I need to mention an Ou where i have these users and all has to be done one after the other.

regards
sharath
0
bsharath
Asked:
bsharath
  • 6
  • 4
  • 4
1 Solution
 
endital1097Commented:
Get-Mailbox -OrganizationalUnit contoso.com/OU/Disabled | Export-Mailbox -PstFolderPath c:\PSTfiles >c:\PSTfiles\export.log
0
 
bsharathAuthor Commented:
I get this

You are running on a 64-bit computer. To export to or import from a .pst file,
you must be running a 32-bit computer that has Outlook 2003 SP2 or later instal
led.
At line:1 char:1

I tried on a 32 bit machines where i have exchange pack and powershell 2.0 but it did not run
0
 
endital1097Commented:
you must have the exchange management tools and outlook installed on the machine where you will run this
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
bsharathAuthor Commented:
I get this

Export-Mailbox : A parameter cannot be found that matches parameter name 'PstFolderPath'.
At line:1 char:128
+ Get-Mailbox -OrganizationalUnit "th.local/Offices/nai/Users/
Fgues" | Export-Mailbox -PstFolderPath <<<<  c:\PSTfiles >c:\PSTfiles\export.log
    + CategoryInfo          : InvalidArgument: (:) [Export-Mailbox], Parameter
   BindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.Exchange.Manage
   ment.RecipientTasks.ExportMailbox
0
 
endital1097Commented:
try manually typing the command and using <tab> so type
export-mail<TAB> -pst<TAB>

it should autocomplete the correct values

the syntax looks good in your example
0
 
bsharathAuthor Commented:
I dont get any as when click tab
export-mail
0
 
endital1097Commented:
are you using the exchange management shell
0
 
GusGallowsCommented:
The problem is, you are specifying a file where it should just be the path. Try it this way:

$List = @(Get-Mailbox -OrganizationalUnit "th.local/Offices/nai/Users/Fgues")
foreach ($item in $list)
{
   
$mb = $item
   $output = "c:\PSTfiles"
   $logfile = "c:\PSTfiles\export.log"
   export-Mailbox -Identity $mb -PSTFolderPath $output -GlobalCatalog 'YourGC.com' -BadItemLimit 100 -confirm:$false|Out-File $logFile -Append
}
0
 
GusGallowsCommented:
Whoops, hit enter too soon. Forgot to create the new folders. Here is the completed code. Make sure you are using a Mail-Enabled account to run this and that it has rights to veiw all mailboxes.

$List = @(Get-Mailbox -OrganizationalUnit "th.local/Offices/nai/Users/Fgues")
foreach ($item in $list)
{
   
      $mb = $item
      $mbx = Get-mailbox $item
      $dn = $mbx.Displayname
      $Output = "c:\PSTfiles\" + $dn
      New-Item $dn -type directory
      $logfile = "c:\PSTfiles\export.log"
      export-Mailbox -Identity $mb -PSTFolderPath $output -GlobalCatalog 'YourGC.com' -BadItemLimit 100 -confirm:$false|Out-File $logFile -Append
}
0
 
GusGallowsCommented:
one correction, It should read:

New-Item $Output -type directory

not  New-Item $dn -type directory
0
 
endital1097Commented:
you should be able to do this with a one liner
Get-Mailbox -OrganizationalUnit "th.local/Offices/nai/Users/Fgues" | foreach-object { export-mailbox $_.name -pstfolderpath C:\PSTfiles | Out-File C:\PSTfiles\export.log -Append -NoClobber
0
 
GusGallowsCommented:
I don't use one-liners if I can help it. Just easier (for me) to read if it is laid out in a more traditional scripting style.  Plus the one liner does not address his need for writing the PSTs to new folders named after the users.
0
 
endital1097Commented:
good catch on the indiividual folders... i didn't see that part
0
 
bsharathAuthor Commented:
Hi
I get this error when run

Export-Mailbox : A parameter cannot be found that matches parameter name 'PSTFolderPath'.
At C:\Export.ps1:11 char:50
0

Featured Post

What Security Threats Are We Predicting for 2018?

Cryptocurrency, IoT botnets, MFA, and more! Hackers are already planning their next big attacks for 2018. Learn what you might face, and how to defend against it with our 2018 security predictions.

  • 6
  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now