Exception thrown when creating a website using the Invoke-Command

I call the 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 } 

The website was successfully created in IIS on a remote computer. However, an exception message is displayed when powershell returns:

 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 

Does anyone know why I am receiving this message and how can I solve it?

+6
source share
1 answer

Can you try:

 $var = New-Website ... 

Not sure, but New-Website returns an object that the remote PowerShell session is trying to serialize unsuccessfully.

+14
source

Source: https://habr.com/ru/post/916086/


All Articles