Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

HI,

I have a powershell deployment script that downloads files from svn into a directory and then updates the IIS settings to point the site at the new folder. It has been running fine, until some updates were made to the server. Now, when I try and run the script it errors out on

[Void][Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")
$serverManager = New-Object Microsoft.Web.Administration.ServerManager

The error is

New-Object : Exception calling ".ctor" with "0" argument(s): 
"Retrieving the COM class factory for component with CLSID {B15183DD-75F9-42DF-8E57-C8B57692F134} failed due to the following error: 80040154."
At C:\Users\administrator.LAYERXNETWORKS\AppData\Local\Temp\2\e72ec49f-353f-4dc0-877c-ef67f6b49bab.ps1:2 char:28
+ $serverManager = New-Object <<<<  Microsoft.Web.Administration.ServerManager
    + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvocationException
    + FullyQualifiedErrorId :    ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

I ahve read that this error is generally caused by the class not being installed.

The server is running Windows 2008 R2 with IIS 7.5

share|improve this question
    
Do you try to look if the COM companent CLSID {B15183DD-75F9-42DF-8E57-C8B57692F134} is registered in you registry and that the DLL it reference is loadable. Do you pay attention to load your script with the correct Powershell (32Bits versus 64 bits). –  JPBlanc Apr 1 '11 at 6:57

2 Answers 2

up vote 3 down vote accepted

Make sure you load the correct bit-wise version of PowerShell. If you're running the 64 bit version then you'll get the exception described.

You need to use the 32bit (Windows PowerShell (x86)) version of PowerShell to consume Microsoft.Web.Administration.

share|improve this answer
    
Thanks. I'm not sure why this problem only occurred after the updates were applied. I've been running the script on the server for months without any issues, although I suppose its possible some setup I did when I first created the script was removed during the updates and I've forgotten about it. –  Ryan French Apr 3 '11 at 21:57

Just as an extra to the answer, I found issues with using the x86 powershell console, and in the end found that using

[System.Reflection.Assembly]::LoadFrom( "C:\windows\system32\inetsrv\Microsoft.Web.Administration.dll" )

rather than

[Void][Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")

It ran fine.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.