Exception thrown when creating a website via Invoke-Command

6

I'm calling 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 is created successfully in IIS on the remote machine. 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'm receiving this message and how I can resolve it?

iis
powershell
asked on Stack Overflow May 18, 2012 by James Hay

1 Answer

14

Can you try :

$var = New-Website ...

Not sure but New-Website return an object that PowerShell remote session try to serialize unsuccesfully.

answered on Stack Overflow May 18, 2012 by JPBlanc • edited May 18, 2012 by JPBlanc

User contributions licensed under CC BY-SA 3.0