Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I recycle an IIS AppPool with Powershell?
    text
    copied!<p>I haven't really done any Windows scripting at all, so I am at a loss on how to pull this one off. Anyway, basically what we want to do is have a script that will take an argument on which IIS AppPool to recycle. I have done some research on Google and haven't had much success on getting things to work.</p> <p>Here is what I am trying now:</p> <pre><code>$appPoolName = $args[0] $appPool = get-wmiobject -namespace "root\MicrosoftIISv2" -class "IIsApplicationPools" Where-Object {$_.Name -eq "W3SVC/APPPOOLS/$appPoolName"} $appPool.Recycle() </code></pre> <p>and the error I get:</p> <pre><code>Get-WmiObject : A parameter cannot be found that matches parameter name '$_.Name -eq "W3SVC/APPPOOLS/$appPoolName"'. </code></pre> <p>Anyway, it would be nice if I also knew how to debug things like this. I already fixed one bug with the original script by doing gwmi -namespace "root\MicrosoftIISv2" -list. Any other tips like that one would be great.</p> <p>Thanks!</p> <p><strong>Update</strong>: Here is some more info</p> <pre><code>$appPool = gwmi -namespace "root\MicrosoftIISv2" -class "IISApplicationPools" | Get-Member . TypeName: System.Management.ManagementObject#root\MicrosoftIISv2\IIsApplicationPools Name MemberType Definition ---- ---------- ---------- Caption Property System.String Caption {get;set;} Description Property System.String Description {get;set;} InstallDate Property System.String InstallDate {get;set;} Name Property System.String Name {get;set;} Status Property System.String Status {get;set;} __CLASS Property System.String __CLASS {get;set;} __DERIVATION Property System.String[] __DERIVATION {get;set;} __DYNASTY Property System.String __DYNASTY {get;set;} __GENUS Property System.Int32 __GENUS {get;set;} __NAMESPACE Property System.String __NAMESPACE {get;set;} __PATH Property System.String __PATH {get;set;} __PROPERTY_COUNT Property System.Int32 __PROPERTY_COUNT {get;set;} __RELPATH Property System.String __RELPATH {get;set;} __SERVER Property System.String __SERVER {get;set;} __SUPERCLASS Property System.String __SUPERCLASS {get;set;} ConvertFromDateTime ScriptMethod System.Object ConvertFromDateTime(); ConvertToDateTime ScriptMethod System.Object ConvertToDateTime(); Delete ScriptMethod System.Object Delete(); GetType ScriptMethod System.Object GetType(); Put ScriptMethod System.Object Put(); gwmi -namespace "root\MicrosoftIISv2" -class "IISApplicationPools" __GENUS : 2 __CLASS : IIsApplicationPools __SUPERCLASS : CIM_LogicalElement __DYNASTY : CIM_ManagedSystemElement __RELPATH : IIsApplicationPools.Name="W3SVC/AppPools" __PROPERTY_COUNT : 5 __DERIVATION : {CIM_LogicalElement, CIM_ManagedSystemElement} __SERVER : IRON __NAMESPACE : root\MicrosoftIISv2 __PATH : \\IRON\root\MicrosoftIISv2:IIsApplicationPools.Name="W3SVC/A ppPools" Caption : Description : InstallDate : Name : W3SVC/AppPools Status : </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload