2012-05-18 19 views
6

Tôi gọi lệnhngoại lệ ném khi tạo một trang web thông qua Invoke-Command

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 } 

Trang web này được tạo thành công trong IIS trên máy từ xa. Tuy nhiên, một thông báo ngoại lệ được hiển thị khi powershell trả về:

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 

Có ai biết tại sao tôi nhận được thông báo này và cách tôi có thể giải quyết không?

Trả lời

14

Bạn có thể thử:

$var = New-Website ... 

Không chắc nhưng New-Website trả về một đối tượng mà PowerShell phiên thử từ xa để serialize unsuccesfully.

+0

Tuyệt vời. Cảm ơn! –

+5

+1. Piping nó để null cũng hoạt động: '| Out-Null' –

Các vấn đề liên quan