This project is read-only.

'Access Denied' trying to stop IIS7 app pool

Aug 10, 2009 at 9:00 PM

I am trying to use the WMI task to stop an IIS7 app pool (or the Iis7AppPool class, but it wouldn't work either).  I have searched all over for why this will not work, and did find this post, which mentions using "PacketPrivacy" as the AuthenticationLevel in WMI (  I can run some of the other WMI example tasks remotely, but not any to do with the WebAdministration.  The event log error on the target machine confirmed this issue:

Access to the root\WebAdministration namespace was denied because the namespace is marked with RequiresEncryption but the script or application attempted to connect to this namespace with an authentication level below Pkt_Privacy. Change the authentication level to Pkt_Privacy and run the script or application again.

Is there something I can do in order to get this to work with the current version of the extension pack, or am I just doing something wrong?  If not, I would like to suggest the ability to enable this authentication mode.  I have more details below.  Thanks!!

Here is my error from MSBuild:

Build started 8/10/2009 3:53:02 PM.
Project "C:\MSBuildTesting\stoppool.proj" on node 0 (default targets).
  Stopping R23 AppPool
C:\MSBuildTesting\stoppool.proj(8,4): error : ManagementException: Access denie
d \r
C:\MSBuildTesting\stoppool.proj(8,4): error :
Done Building Project "C:\MSBuildTesting\stoppool.proj" (default targets) -- FA


"C:\MSBuildTesting\stoppool.proj" (default target) (1) ->
(All target) ->
  C:\MSBuildTesting\stoppool.proj(8,4): error : ManagementException: Access den
ied \r
C:\MSBuildTesting\stoppool.proj(8,4): error :

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.18

Here is my build file contents:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="All"  xmlns="">
<Import Project="C:\Program Files\MSBuild\ExtensionPack\MSBuild.ExtensionPack.tasks"/>

<Target Name="All">
    <Message Text="Stopping R23 AppPool" />

   <MSBuild.ExtensionPack.Management.Wmi TaskAction="Execute"
      Method="Stop" Namespace="\root\WebAdministration" Instance="Name='R23'"
      MachineName="" UserName="Administrator" UserPassword="mypwd">

<!--    <MSBuild.ExtensionPack.Web.Iis7AppPool TaskAction="Stop" Name="R23"
      MachineName="" UserName="Administrator" UserPassword="mypwd" />-->

    <Message Text="DONE!" />



Aug 11, 2009 at 10:20 PM

Mike, thanks for this. I'm setting up an environemnt to repro. I'll let you know how i get along.



Aug 24, 2009 at 4:51 PM


Did you get a chance to try to reproduce this one?  Thanks!



Aug 27, 2009 at 8:32 AM

Hi Michael

Sorry for the delay. I didn't manage to repro in a w2k8 environment, though I've made a note to look into exposing Authentication in the base WMI options (as soon as I can get some time!).... Mike

Aug 27, 2009 at 2:50 PM

Yeah, who knows what is different between our environments.  If I can set that authentication option though, then maybe it would work for my case.  If you are able to add that in someday, I can test it out on my end.  Thanks for your time!

Jun 11, 2010 at 8:14 PM
Any hope for this? I need to stop a 2008 AppPool remotely from a Server 2003 build ... and this looked like the only way until it didn't work because of the authentication.
Jun 12, 2010 at 11:05 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Jun 12, 2010 at 11:07 AM

Sorry, this fell off my radar! Copied to workitem so it can be tracked better. I'll try look soon, but a bit tied up with MSBuild Explorer 2.0 at the moment...


Jun 14, 2010 at 4:13 PM

Hi, coudl you let me know if resolves this for you.