Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting error "CmdletInvocationException was unhandled" when Exporting Exchange Mailboxes with C#
    primarykey
    data
    text
    <p>I am receiving CmdletInvocationException was unhandled, Cannot invoke this function because the current host does not implement it.</p> <p>when i replace the Export-Mailbox cmdlet with a get-command as a test I get no errors. </p> <p>Here is my sample code. When i run sScript1, its runs just fine, when i run sScript2 thats when i get the error. When im on my testing machine i did the get-excommand and I couldnt find the export-mailbox cmdlet.</p> <pre><code> public void RunPowerShell() { Cursor.Current = Cursors.WaitCursor; RunspaceConfiguration rsConfig = RunspaceConfiguration.Create(); PSSnapInException snapInException = null; Runspace runSpace; //create the runspace runSpace = RunspaceFactory.CreateRunspace(rsConfig); runSpace.Open(); rsConfig.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", out snapInException); Pipeline pipeLine = runSpace.CreatePipeline(); //Add-MailboxPermission -Identity " + FromEmailAccount.Text + " -User Administrator -AccessRights FullAccess String sScript1 = "Add-MailboxPermission -Identity " + ToEmailAccount.Text + " -User Administrator -AccessRights FullAccess"; String sScript2 = "Export-Mailbox -Identity " + FromEmailAccount.Text + " -TargetMailbox " + ToEmailAccount.Text + " -TargetFolder " + ToEmailAccount.Text + " -Confirm:$false"; //pipeLine.Commands.AddScript(sScript1); pipeLine.Commands.AddScript(sScript2); Collection&lt;PSObject&gt; commandResults = pipeLine.Invoke(); //loop through the results of the command and load the SamAccountName into the list foreach (PSObject results in commandResults) { //MessageBox.Show(results.ToString(), @"test"); } pipeLine.Dispose(); runSpace.Close(); MessageBox.Show(@"complete", @"Done"); Cursor.Current = Cursors.Default; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload