Multithreading 使用运行空间在powershell中实现多线程

Multithreading 使用运行空间在powershell中实现多线程,multithreading,powershell,exchange-server,Multithreading,Powershell,Exchange Server,我想将Exchange 2010管理单元加载到运行空间 $sessionstate = [system.management.automation.runspaces.initialsessionstate]::CreateDefault() $sessionstate.ImportPSSnapIn("Microsoft.Exchange.Management.PowerShell.E2010","") ImportPSSnapin查找第二个PSSnapInException类型的参数,但我不

我想将Exchange 2010管理单元加载到运行空间

$sessionstate = [system.management.automation.runspaces.initialsessionstate]::CreateDefault()
$sessionstate.ImportPSSnapIn("Microsoft.Exchange.Management.PowerShell.E2010","")

ImportPSSnapin查找第二个PSSnapInException类型的参数,但我不确定如何将其放入powershell。

您试图实现的是什么?MS不支持在实际的EMS外壳之外加载该管理单元,您最好对Exchange服务器的远程管理会话使用invoke命令。我编写了一个powershell脚本,该脚本将在启用审核的邮箱上执行同步操作,并将结果放在一个文件中。我想更改我已经拥有的脚本,并希望对其进行多线程处理。因此,我想要一个运行空间,并将Exchange管理单元加载到运行空间中。在我的主代码中,我将查找已启用审核的邮箱,然后希望将控制权转移到scriptblock,该scriptblock可以查找已启用审核的邮箱中的所有事件并将写入文件。您使用的exchange cmdlet是什么?$mailboxes=Get Mailboxe-Resultsize unlimited-Filter{RecipientTypeDetails-ne DiscoveryMailbox}其中{$\.auditenabled-eq'true'}$accesslog=Search MailboxAuditLog$\.alias-StartDate$prevDate-Enddate$dateNow-ShowDetails