David Huby’s Blog Technical and business stuff

19Jan/111

Administering IIS using Powershell and WMI

I was using the string Get-WmiObject -namespace "root\MicrosoftIISv2" -class "IIsWebService" to obtain a reference to the IIS Web Service, and recieving the following error:

PS E:\Projects\AllenAndUnwin\Build> Get-WmiObject -class IIsWebService -Namespace "root\MicrosoftIISv2"
Get-WmiObject : Invalid namespace
At line:1 char:14
+ Get-WmiObject <<<< -class IIsWebService -Namespace "root\MicrosoftIISv2"
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

WMI Scripting needed to be installed for IIS. The installation procedure is slightly different for IIS 6 and 7:

- on a machine with IIS 6 installed, open add/remove programs and navigate to "Internet Information Services" > "Web Management Tools" > "IIS 6 Management Compatibility", then install "IIS 6 WMI Compatibility".
- on IIS 7, configure the Web Server (IIS) role and install "IIS 6 WMI Compatibility" under "IIS Management Console" > "IIS 6 Management Compatibility"

Comments (1) Trackbacks (0)
  1. So I tried this and then restarted IIS.
    Now I get a new error: Provider load failure

    Output:
    PS C:\Users\the-user> Get-WMIObject -class IISApplicationPoolSetting -namespace “root\microsoftiisv2″ -authentication 6
    Get-WmiObject : Provider load failure
    At line:1 char:15
    + Get-WMIObject <<<< -class IISApplicationPoolSetting -namespace "root\microsoftiisv2" -authentication 6
    + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand


Leave a comment


No trackbacks yet.