header1   header
header
header : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
IMPORTANT: PowerShellCommunity.org is moving! - Wednesday, August 15, 2012

PowerShellCommunity.org is moving!  This community software, and the hardware that it sits on, are no longer serving the purposes of this community.  As a result, we have decided to move this community to a new home at PowerShell.org.  PowerShell.org is already up and running with the new community software and in its new location, so please post any new questions that you have on the forums over there instead of posting them on this site.  We've already started getting some great questions from members of the community over there so please, come on over and join us!

While we are going through this transition, this site will remain up for the short term.  New posts may no longer be created on these forums, however replies to existing posts are allowed so that users who posted questions don't have to re-post the same question on the new site.

[UPDATE 28/02/2013] New user registration has been disabled and forums have now been switched to read-only, including for existing posts since all threads that were started should now be completed. If you have a question about content on this site or about PowerShell in general, head over to PowerShell.org and ask it there where there are people actively using the site and answering questions.

If you have any questions, please let us know on the PowerShell.org site.

Thank you,

Kirk "Poshoholic" Munro

 
Programmatically export mailbox via Powershell - error -2147219963
Last Post 16 Dec 2011 07:13 AM by Marco Shaw. 1 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
zantoroUser is Offline
New Member
New Member
Posts:1
Avatar

--
16 Dec 2011 05:34 AM
    Dear All,
    we are trying to automate the user account management using Powershell to handle all interactions with Exchange 2007.
    The powershell commands are launched from a webservice developed in ASP.NET (C#).

    The project is practically over aside from the export of the mailbox.

    When I try to execute the following command:
    export-mailbox -identity "Mister x" -baditemlimit 1147483648 -pstfolderpath "d:\path\MisterX.pst"
    We get an error:
    Export-Mailbox error results: Error was found for MisterX (MisterX@MisteryComp.net) because: An unknown error has occurred., error code: -2147219963

    The same command runs fine from the exchange powershell console (same user, same server)
    We also noticed the command completes successfully if I first run the exact same command directly on powershell (from the same server) and then leave the console window open.
    If I close the console, the application starts failing again with the same error.
    If I run the application pool that owns the webservice with Domain Admin account, everything works fine but the user I would like to use has all the necessary rights.

    I get the feeling Powershell in order to function properly needs a session open in a specific way that I do not understand.

    Here following the relevant portion of code:
    RunspaceConfiguration runspaceConf = RunspaceConfiguration.Create();
    PSSnapInException PSException = null;
    PSSnapInInfo info = runspaceConf.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", out PSException);
    Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConf);
    runspace.Open();

    System.Management.Automation.SwitchParameter spConfirmYes;
    int iNbmaxerreurs = 1147483648;
    spConfirmYes = false; //Always False

    Pipeline pipelineEM = runspace.CreatePipeline();

    pipelineEM.Commands.Add("Export-Mailbox");
    pipelineEM.Commands[0].Parameters.Add("Identity", MailID.ToString());
    pipelineEM.Commands[0].Parameters.Add("BadItemLimit", iNbmaxerreurs);
    pipelineEM.Commands[0].Parameters.Add("Confirm", spConfirmYes);
    pipelineEM.Commands[0].Parameters.Add("PSTFolderPath", sExportfilePath.ToString() + ExportfileName.ToString() + ".pst");

    // Result Recuperation:
    System.Collections.ObjectModel.Collection psobjResults;
    System.Collections.ObjectModel.Collection objResultserror;

    psobjResults = pipelineEM.Invoke();

    objResultserror = pipelineEM.Error.ReadToEnd();
    Marco ShawUser is Offline
    Veteran Member
    Veteran Member
    Posts:1684
    Avatar

    --
    16 Dec 2011 07:13 AM
    You will need to review the information from:
    PS> help export-mailbox -full

    There are several pre-reqs to using export-mailbox. Exporting to a PST also has other requirements like having Outlook installed...
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Many thanks to our original sponsors: Quest Software • SAPIEN Technologies • Compellent • Microsoft footer
    footer   footer