2014-01-10 53 views
0

如果運行lync powershell命令「Get-CsUser」,我將得到異常。我與管理員和具有lync PowerShell的機器上運行應用程序。術語'Get-CsUser'不被識別爲cmdlet,函數,腳本文件或可操作程序的名稱

System.Management.Automation.CommandNotFoundException:術語 'GET-CsUser' 沒有被識別爲cmdlet,函數, 腳本文件的名稱,或可操作的程序。檢查名稱的拼寫,如果包含路徑,請檢查路徑是否正確,然後重試。 在 System.Management.Automation.CommandDiscovery.LookupCommandInfo(字符串 命令名,CommandOrigin commandOrigin)在 System.Management.Automation.CommandDiscovery.LookupCommandProcessor(字符串 命令名,CommandOrigin commandOrigin,Nullable`1 useLocalScope)
在 系統。 Management.Automation.Runspaces.Command.CreateCommandProcessor(的ExecutionContext 的ExecutionContext,的CommandFactory的CommandFactory,布爾addToHistory) 在 System.Management.Automation.Runspaces.LocalPipeline.CreatePipelineProcessor() 在System.Management.Automation.Runspaces.LocalPipeline.InvokeHelper( ) 在 System.Management.Automation.Runspaces.LocalPipeline.InvokeThreadProc()

示例代碼:

using (Runspace runspace = RunspaceFactory.CreateRunspace(initial)) 
{ 

      //// open it 
      runspace.Open(); 


      using (PowerShell ps = PowerShell.Create()) 
      { 
       ps.Runspace = runspace; 
       ps.AddScript("import-module 'C:\\Program Files\\Common Files\\Microsoft 
       ps.AddCommand("Get-CsUser"); 
       Collection<PSObject> results = ps.Invoke(); 
       foreach (PSObject obj in results) 
       { 
        stringBuilder.AppendLine(obj.ToString()); 
       } 
       runspace.Close(); 
      } 
} 

任何建議解決這一問題???

+2

http://stackoverflow.com/questions/17070747 /導入-的powershell模塊式-C-尖銳 –

回答

相關問題