voxpupuli/puppet-iis

Cannot find type [Microsoft.Web.Administration.ServerManager]

Closed this issue · 3 comments

Hi,

Im trying to setup the app pool user and password, its failing due to not initializing the system assembly.

https://github.com/voxpupuli/puppet-iis/blob/master/manifests/manage_app_pool.pp#L221

Above you can see it calls this:
$iis = new-object Microsoft.Web.Administration.ServerManager

If you do that by just importing the webadministration module it will fail:

PS C:\Windows\system32> Import-Module WebAdministration
PS C:\Windows\system32> $iis = new-object Microsoft.Web.Administration.ServerManager
new-object : Cannot find type [Microsoft.Web.Administration.ServerManager]: verify that the assembly containing this
type is loaded.
At line:1 char:8
+ $iis = new-object Microsoft.Web.Administration.ServerManager
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

This system call needs to be added to make this work:
[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.Web.Administration”)

I've briefly added a fix here: https://github.com/dzeleski/puppet-iis/blob/master/manifests/manage_app_pool.pp

Will test and pull once im done with testing.

I guess we can close this now?

Works for me, thanks for merging!