2012-05-18 39 views
6

建立一個網站時,我調用命令異常通過調用命令

Invoke-Command -computername remotepc { 
Import-Module WebAdministration; 
New-Website -Name www.somesite.com -ApplicationPool www.somesite.com -hostHeader www.somesite.com -physicalPath c:\inetpub\wwwroot } 

網站成功創建在IIS中的遠程計算機上拋出。但是,PowerShell返回時會顯示一條異常消息:

Invalid class string (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING)) 
    + CategoryInfo   : NotSpecified: (:) [New-Website], COMException 
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.IIs.PowerShell.Provider.NewWebsite 
    Command 

有誰知道我爲什麼收到此消息以及如何解決它?

回答

14

你可以嘗試:

$var = New-Website ... 

不知道,但New-Website返回的PowerShell遠程會話嘗試unsuccesfully序列化一個對象。

+0

太棒了。謝謝! –

+5

+1。將它配置爲null也是可行的:'| OUT-Null' –