![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | remote application pool recycle using WMI \ PowerShell I'm having some trouble finding the best method for recycling remote IIS6 application pools using PowerShell. In the past this has always been very easy using VB script: Function PoolRecycle(strServer) On Error Resume Next Err.Clear Dim objWMIService Dim colItems Dim objItem 'recycle application pool WScript.Echo "" Err.Clear Set objWMIService = GetObject _ ("winmgmts:{authenticationLevel=pktPrivacy}\\" _ & strServer & "\root\microsoftiisv2") 'connect to WMI Set colItems = objWMIService.ExecQuery("Select * From IIsApplicationPool") 'Step through the objects to be recycled For each objItem in colItems objItem.Recycle If err = 0 Then WScript.Echo(strServer & " - " & ObjItem.Name & " Recycled") PoolRecycle = "success" Else WScript.Echo("Unable to recycle the application pool on " & strServer) PoolRecycle = "failed" End If Next End Function I have attempted to duplicate the same thing in PowerShell, but I believe I am still running into an issue with the pktPrivacy authentication setting. The following code works when executing localy, but not on a remote host: Function PoolRecycle($strServerName) { $objWMI = [WmiSearcher] "Select * From IIsApplicationPool" $objWMI.Scope.Path = "\\" + $strServerName + "\root\microsoftiisv2" $objWMI.Scope.Options.Authentication = 6 $pools = $objWMI.Get() foreach ($pool in $pools) { $pool.recycle() if (!$?) { Write-Host $pool.name " - ERROR" } else { Write-Host $pool.name " - Recycled" } } } Any help or better ways of accomplishing this in PowerShell would be very much appreciated! Thanks Bill |
My System Specs![]() |
| | #2 (permalink) |
| | Re: remote application pool recycle using WMI \ PowerShell If you know the application pool name (the function returns true/false respectively: function Recycle-AppPool{ param([string]$server,[string]$appPool) ([WMI]"\\$server\root\MicrosoftIISv2:IIsApplicationPool.Name='W3SVC/AppPools/$appPool'").recycle(); if($? -ne 0}{$false} else {$true} } To get a list of application pool names: $computer = "your Server name/ip" gwmi -class IIsApplicationPool -namespace "root\MicrosoftIISv2" -computer $computer | % {$_.name} ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > I'm having some trouble finding the best method for recycling remote > IIS6 application pools using PowerShell. > > In the past this has always been very easy using VB script: > > Function PoolRecycle(strServer) > > On Error Resume Next > Err.Clear > Dim objWMIService > Dim colItems > Dim objItem > 'recycle application pool > WScript.Echo "" > Err.Clear > Set objWMIService = GetObject _ > ("winmgmts:{authenticationLevel=pktPrivacy}\\" _ > & strServer & "\root\microsoftiisv2") > 'connect to WMI > Set colItems = objWMIService.ExecQuery("Select * From > IIsApplicationPool") > 'Step through the objects to be recycled > For each objItem in colItems > objItem.Recycle > If err = 0 Then > WScript.Echo(strServer & " - " & ObjItem.Name & " Recycled") > PoolRecycle = "success" > Else > WScript.Echo("Unable to recycle the application pool on " & > strServer) > PoolRecycle = "failed" > End If > Next > End Function > > I have attempted to duplicate the same thing in PowerShell, but I > believe I am still running into an issue with the pktPrivacy > authentication setting. The following code works when executing > localy, but not on a remote host: > > Function PoolRecycle($strServerName) > { > $objWMI = [WmiSearcher] "Select * From IIsApplicationPool" > $objWMI.Scope.Path = "\\" + $strServerName + "\root\microsoftiisv2" > $objWMI.Scope.Options.Authentication = 6 > $pools = $objWMI.Get() > foreach ($pool in $pools) > { > $pool.recycle() > if (!$?) > { > Write-Host $pool.name " - ERROR" > } > else > { > Write-Host $pool.name " - Recycled" > } > } > } > Any help or better ways of accomplishing this in PowerShell would be > very much appreciated! > > Thanks > Bill |
My System Specs![]() |
| | #3 (permalink) |
| | Re: remote application pool recycle using WMI \ PowerShell Pinging the remote machine before trying to recycle pools is a recommended practice. Also, I wrote: gwmi -class IIsApplicationPool -namespace "root\MicrosoftIISv2" -computer $computer | % {$_.name} for those who are not familiar with gwmi and %, I should say that they are aliases for: gwmi = get-wmiobject % = foreach-object I should have written it like: get-wmiobject -class IIsApplicationPool -namespace "root\MicrosoftIISv2" -computer $computer | foreach-object {$_.name} ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > If you know the application pool name (the function returns true/false > respectively: > > function Recycle-AppPool{ > param([string]$server,[string]$appPool) > ([WMI]"\\$server\root\MicrosoftIISv2:IIsApplicationPool.Name='W3SVC/A > ppPools/$appPool'").recycle(); > if($? -ne 0}{$false} else {$true} > } > To get a list of application pool names: > > $computer = "your Server name/ip" > gwmi -class IIsApplicationPool -namespace "root\MicrosoftIISv2" > -computer > $computer | % {$_.name} > ----- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com Quote: >> I'm having some trouble finding the best method for recycling remote >> IIS6 application pools using PowerShell. >> >> In the past this has always been very easy using VB script: >> >> Function PoolRecycle(strServer) >> >> On Error Resume Next >> Err.Clear >> Dim objWMIService >> Dim colItems >> Dim objItem >> 'recycle application pool >> WScript.Echo "" >> Err.Clear >> Set objWMIService = GetObject _ >> ("winmgmts:{authenticationLevel=pktPrivacy}\\" _ >> & strServer & "\root\microsoftiisv2") >> 'connect to WMI >> Set colItems = objWMIService.ExecQuery("Select * From >> IIsApplicationPool") >> 'Step through the objects to be recycled >> For each objItem in colItems >> objItem.Recycle >> If err = 0 Then >> WScript.Echo(strServer & " - " & ObjItem.Name & " Recycled") >> PoolRecycle = "success" >> Else >> WScript.Echo("Unable to recycle the application pool on " & >> strServer) >> PoolRecycle = "failed" >> End If >> Next >> End Function >> I have attempted to duplicate the same thing in PowerShell, but I >> believe I am still running into an issue with the pktPrivacy >> authentication setting. The following code works when executing >> localy, but not on a remote host: >> >> Function PoolRecycle($strServerName) >> { >> $objWMI = [WmiSearcher] "Select * From IIsApplicationPool" >> $objWMI.Scope.Path = "\\" + $strServerName + "\root\microsoftiisv2" >> $objWMI.Scope.Options.Authentication = 6 >> $pools = $objWMI.Get() >> foreach ($pool in $pools) >> { >> $pool.recycle() >> if (!$?) >> { >> Write-Host $pool.name " - ERROR" >> } >> else >> { >> Write-Host $pool.name " - Recycled" >> } >> } >> } >> Any help or better ways of accomplishing this in PowerShell would be >> very much appreciated! >> Thanks >> Bill |
My System Specs![]() |
| | #4 (permalink) |
| | Re: remote application pool recycle using WMI \ PowerShell Shay, Thanks for the help, but I see the namespace "root\MicrosoftIISv2" operate differently when attempting to access it on a remote IIS6 computer (default W2K3 installs). The code examples you pointed out all work fine when targeting the namespace locally, but I recieve access denied messages when useing the same commands remotely. I have tried from multiple machines to multiple servers. The VB Script I supplied still works in all cases, which leads me to believe I am not setting the PowerShell WMI object authentication to use pktPrivacy correctly. Any advice would be appreciated. Thanks Bill "Shay Levi" wrote: Quote: > Pinging the remote machine before trying to recycle pools is a recommended > practice. > > Also, I wrote: > > gwmi -class IIsApplicationPool -namespace "root\MicrosoftIISv2" -computer > $computer | % {$_.name} > > for those who are not familiar with gwmi and %, I should say that they are > aliases for: > gwmi = get-wmiobject > % = foreach-object > > I should have written it like: > > get-wmiobject -class IIsApplicationPool -namespace "root\MicrosoftIISv2" > -computer $computer | foreach-object {$_.name} > > > > ----- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com > > > Quote: > > If you know the application pool name (the function returns true/false > > respectively: > > > > function Recycle-AppPool{ > > param([string]$server,[string]$appPool) > > ([WMI]"\\$server\root\MicrosoftIISv2:IIsApplicationPool.Name='W3SVC/A > > ppPools/$appPool'").recycle(); > > if($? -ne 0}{$false} else {$true} > > } > > To get a list of application pool names: > > > > $computer = "your Server name/ip" > > gwmi -class IIsApplicationPool -namespace "root\MicrosoftIISv2" > > -computer > > $computer | % {$_.name} > > ----- > > Shay Levi > > $cript Fanatic > > http://scriptolog.blogspot.com Quote: > >> I'm having some trouble finding the best method for recycling remote > >> IIS6 application pools using PowerShell. > >> > >> In the past this has always been very easy using VB script: > >> > >> Function PoolRecycle(strServer) > >> > >> On Error Resume Next > >> Err.Clear > >> Dim objWMIService > >> Dim colItems > >> Dim objItem > >> 'recycle application pool > >> WScript.Echo "" > >> Err.Clear > >> Set objWMIService = GetObject _ > >> ("winmgmts:{authenticationLevel=pktPrivacy}\\" _ > >> & strServer & "\root\microsoftiisv2") > >> 'connect to WMI > >> Set colItems = objWMIService.ExecQuery("Select * From > >> IIsApplicationPool") > >> 'Step through the objects to be recycled > >> For each objItem in colItems > >> objItem.Recycle > >> If err = 0 Then > >> WScript.Echo(strServer & " - " & ObjItem.Name & " Recycled") > >> PoolRecycle = "success" > >> Else > >> WScript.Echo("Unable to recycle the application pool on " & > >> strServer) > >> PoolRecycle = "failed" > >> End If > >> Next > >> End Function > >> I have attempted to duplicate the same thing in PowerShell, but I > >> believe I am still running into an issue with the pktPrivacy > >> authentication setting. The following code works when executing > >> localy, but not on a remote host: > >> > >> Function PoolRecycle($strServerName) > >> { > >> $objWMI = [WmiSearcher] "Select * From IIsApplicationPool" > >> $objWMI.Scope.Path = "\\" + $strServerName + "\root\microsoftiisv2" > >> $objWMI.Scope.Options.Authentication = 6 > >> $pools = $objWMI.Get() > >> foreach ($pool in $pools) > >> { > >> $pool.recycle() > >> if (!$?) > >> { > >> Write-Host $pool.name " - ERROR" > >> } > >> else > >> { > >> Write-Host $pool.name " - Recycled" > >> } > >> } > >> } > >> Any help or better ways of accomplishing this in PowerShell would be > >> very much appreciated! > >> Thanks > >> Bill > > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: remote application pool recycle using WMI \ PowerShell Bill I can't test it right now. Try this on the remote server(s ![]() 1. Start > Run > dcomcnfg > ENTER 2. In the left pane (Compnent Services.msc) expand "Component Services" > Computers 3. Right click "My Computer" 4. In the "Default Properties" tab tick the "Enable COM Internet Services on this computer" checkbox 5. Reboot remote server 6. Test again I can't recall if you need to add Access Permissions in the "COM Security" tab. ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > Shay, > > Thanks for the help, but I see the namespace "root\MicrosoftIISv2" > operate differently when attempting to access it on a remote IIS6 > computer (default W2K3 installs). > > The code examples you pointed out all work fine when targeting the > namespace locally, but I recieve access denied messages when useing > the same commands remotely. > > I have tried from multiple machines to multiple servers. The VB > Script I supplied still works in all cases, which leads me to believe > I am not setting the PowerShell WMI object authentication to use > pktPrivacy correctly. > > Any advice would be appreciated. > > Thanks > Bill > "Shay Levi" wrote: > Quote: >> Pinging the remote machine before trying to recycle pools is a >> recommended practice. >> >> Also, I wrote: >> >> gwmi -class IIsApplicationPool -namespace "root\MicrosoftIISv2" >> -computer $computer | % {$_.name} >> >> for those who are not familiar with gwmi and %, I should say that >> they are >> aliases for: >> gwmi = get-wmiobject >> % = foreach-object >> I should have written it like: >> >> get-wmiobject -class IIsApplicationPool -namespace >> "root\MicrosoftIISv2" -computer $computer | foreach-object {$_.name} >> >> ----- >> Shay Levi >> $cript Fanatic >> http://scriptolog.blogspot.com Quote: >>> If you know the application pool name (the function returns >>> true/false respectively: >>> >>> function Recycle-AppPool{ >>> param([string]$server,[string]$appPool) >>> ([WMI]"\\$server\root\MicrosoftIISv2:IIsApplicationPool.Name='W3SVC/ >>> A >>> ppPools/$appPool'").recycle(); >>> if($? -ne 0}{$false} else {$true} >>> } >>> To get a list of application pool names: >>> $computer = "your Server name/ip" >>> gwmi -class IIsApplicationPool -namespace "root\MicrosoftIISv2" >>> -computer >>> $computer | % {$_.name} >>> ----- >>> Shay Levi >>> $cript Fanatic >>> http://scriptolog.blogspot.com >>>> I'm having some trouble finding the best method for recycling >>>> remote IIS6 application pools using PowerShell. >>>> >>>> In the past this has always been very easy using VB script: >>>> >>>> Function PoolRecycle(strServer) >>>> >>>> On Error Resume Next >>>> Err.Clear >>>> Dim objWMIService >>>> Dim colItems >>>> Dim objItem >>>> 'recycle application pool >>>> WScript.Echo "" >>>> Err.Clear >>>> Set objWMIService = GetObject _ >>>> ("winmgmts:{authenticationLevel=pktPrivacy}\\" _ >>>> & strServer & "\root\microsoftiisv2") >>>> 'connect to WMI >>>> Set colItems = objWMIService.ExecQuery("Select * From >>>> IIsApplicationPool") >>>> 'Step through the objects to be recycled >>>> For each objItem in colItems >>>> objItem.Recycle >>>> If err = 0 Then >>>> WScript.Echo(strServer & " - " & ObjItem.Name & " Recycled") >>>> PoolRecycle = "success" >>>> Else >>>> WScript.Echo("Unable to recycle the application pool on " & >>>> strServer) >>>> PoolRecycle = "failed" >>>> End If >>>> Next >>>> End Function >>>> I have attempted to duplicate the same thing in PowerShell, but I >>>> believe I am still running into an issue with the pktPrivacy >>>> authentication setting. The following code works when executing >>>> localy, but not on a remote host: >>>> Function PoolRecycle($strServerName) >>>> { >>>> $objWMI = [WmiSearcher] "Select * From IIsApplicationPool" >>>> $objWMI.Scope.Path = "\\" + $strServerName + "\root\microsoftiisv2" >>>> $objWMI.Scope.Options.Authentication = 6 >>>> $pools = $objWMI.Get() >>>> foreach ($pool in $pools) >>>> { >>>> $pool.recycle() >>>> if (!$?) >>>> { >>>> Write-Host $pool.name " - ERROR" >>>> } >>>> else >>>> { >>>> Write-Host $pool.name " - Recycled" >>>> } >>>> } >>>> } >>>> Any help or better ways of accomplishing this in PowerShell would >>>> be >>>> very much appreciated! >>>> Thanks >>>> Bill |
My System Specs![]() |
| | #6 (permalink) |
| | Re: remote application pool recycle using WMI \ PowerShell Hi Shay, I have tested this and it still does not resolve the issue. I guess I must be missing something. The fact that the VB Script works and the PowerShell does not, leads me to believe that I have an issue with my script and not the security on the target server. I may have to use PowerShell to call the actual .Net class instead of using the built in commands. Funny, I would have never believed that something as simple as recycling a remote application pool would be so hard ![]() Thanks again for the help. Bill "Shay Levi" wrote: Quote: > Bill > > I can't test it right now. Try this on the remote server(s ![]() > > 1. Start > Run > dcomcnfg > ENTER > 2. In the left pane (Compnent Services.msc) expand "Component Services" > > Computers > 3. Right click "My Computer" > 4. In the "Default Properties" tab tick the "Enable COM Internet Services > on this computer" checkbox > 5. Reboot remote server > 6. Test again > > I can't recall if you need to add Access Permissions in the "COM Security" > tab. > > > > ----- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com > > > Quote: > > Shay, > > > > Thanks for the help, but I see the namespace "root\MicrosoftIISv2" > > operate differently when attempting to access it on a remote IIS6 > > computer (default W2K3 installs). > > > > The code examples you pointed out all work fine when targeting the > > namespace locally, but I recieve access denied messages when useing > > the same commands remotely. > > > > I have tried from multiple machines to multiple servers. The VB > > Script I supplied still works in all cases, which leads me to believe > > I am not setting the PowerShell WMI object authentication to use > > pktPrivacy correctly. > > > > Any advice would be appreciated. > > > > Thanks > > Bill > > "Shay Levi" wrote: > > Quote: > >> Pinging the remote machine before trying to recycle pools is a > >> recommended practice. > >> > >> Also, I wrote: > >> > >> gwmi -class IIsApplicationPool -namespace "root\MicrosoftIISv2" > >> -computer $computer | % {$_.name} > >> > >> for those who are not familiar with gwmi and %, I should say that > >> they are > >> aliases for: > >> gwmi = get-wmiobject > >> % = foreach-object > >> I should have written it like: > >> > >> get-wmiobject -class IIsApplicationPool -namespace > >> "root\MicrosoftIISv2" -computer $computer | foreach-object {$_.name} > >> > >> ----- > >> Shay Levi > >> $cript Fanatic > >> http://scriptolog.blogspot.com > >>> If you know the application pool name (the function returns > >>> true/false respectively: > >>> > >>> function Recycle-AppPool{ > >>> param([string]$server,[string]$appPool) > >>> ([WMI]"\\$server\root\MicrosoftIISv2:IIsApplicationPool.Name='W3SVC/ > >>> A > >>> ppPools/$appPool'").recycle(); > >>> if($? -ne 0}{$false} else {$true} > >>> } > >>> To get a list of application pool names: > >>> $computer = "your Server name/ip" > >>> gwmi -class IIsApplicationPool -namespace "root\MicrosoftIISv2" > >>> -computer > >>> $computer | % {$_.name} > >>> ----- > >>> Shay Levi > >>> $cript Fanatic > >>> http://scriptolog.blogspot.com > >>>> I'm having some trouble finding the best method for recycling > >>>> remote IIS6 application pools using PowerShell. > >>>> > >>>> In the past this has always been very easy using VB script: > >>>> > >>>> Function PoolRecycle(strServer) > >>>> > >>>> On Error Resume Next > >>>> Err.Clear > >>>> Dim objWMIService > >>>> Dim colItems > >>>> Dim objItem > >>>> 'recycle application pool > >>>> WScript.Echo "" > >>>> Err.Clear > >>>> Set objWMIService = GetObject _ > >>>> ("winmgmts:{authenticationLevel=pktPrivacy}\\" _ > >>>> & strServer & "\root\microsoftiisv2") > >>>> 'connect to WMI > >>>> Set colItems = objWMIService.ExecQuery("Select * From > >>>> IIsApplicationPool") > >>>> 'Step through the objects to be recycled > >>>> For each objItem in colItems > >>>> objItem.Recycle > >>>> If err = 0 Then > >>>> WScript.Echo(strServer & " - " & ObjItem.Name & " Recycled") > >>>> PoolRecycle = "success" > >>>> Else > >>>> WScript.Echo("Unable to recycle the application pool on " & > >>>> strServer) > >>>> PoolRecycle = "failed" > >>>> End If > >>>> Next > >>>> End Function > >>>> I have attempted to duplicate the same thing in PowerShell, but I > >>>> believe I am still running into an issue with the pktPrivacy > >>>> authentication setting. The following code works when executing > >>>> localy, but not on a remote host: > >>>> Function PoolRecycle($strServerName) > >>>> { > >>>> $objWMI = [WmiSearcher] "Select * From IIsApplicationPool" > >>>> $objWMI.Scope.Path = "\\" + $strServerName + "\root\microsoftiisv2" > >>>> $objWMI.Scope.Options.Authentication = 6 > >>>> $pools = $objWMI.Get() > >>>> foreach ($pool in $pools) > >>>> { > >>>> $pool.recycle() > >>>> if (!$?) > >>>> { > >>>> Write-Host $pool.name " - ERROR" > >>>> } > >>>> else > >>>> { > >>>> Write-Host $pool.name " - Recycled" > >>>> } > >>>> } > >>>> } > >>>> Any help or better ways of accomplishing this in PowerShell would > >>>> be > >>>> very much appreciated! > >>>> Thanks > >>>> Bill > > |
My System Specs![]() |
| | #7 (permalink) |
| | Re: remote application pool recycle using WMI \ PowerShell Are you able to list the Application poll names? $server="server" $objWMI = [WmiSearcher] "Select * From IIsApplicationPool" $objWMI.Scope.Path = "\\$server\root\microsoftiisv2" $objWMI.Scope.Options.Authentication = [System.Management.AuthenticationLevel]::PacketPrivacy $pools = $objWMI.Get() $pools | foreach { $_.name } ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > Hi Shay, > > I have tested this and it still does not resolve the issue. > > I guess I must be missing something. The fact that the VB Script > works and the PowerShell does not, leads me to believe that I have an > issue with my script and not the security on the target server. > > I may have to use PowerShell to call the actual .Net class instead of > using the built in commands. > > Funny, I would have never believed that something as simple as > recycling a remote application pool would be so hard ![]() > > Thanks again for the help. > Bill > "Shay Levi" wrote: > Quote: >> Bill >> >> I can't test it right now. Try this on the remote server(s ![]() >> >> 1. Start > Run > dcomcnfg > ENTER >> 2. In the left pane (Compnent Services.msc) expand "Component >> Services" > >> Computers >> 3. Right click "My Computer" >> 4. In the "Default Properties" tab tick the "Enable COM Internet >> Services >> on this computer" checkbox >> 5. Reboot remote server >> 6. Test again >> I can't recall if you need to add Access Permissions in the "COM >> Security" tab. >> >> ----- >> Shay Levi >> $cript Fanatic >> http://scriptolog.blogspot.com Quote: >>> Shay, >>> >>> Thanks for the help, but I see the namespace "root\MicrosoftIISv2" >>> operate differently when attempting to access it on a remote IIS6 >>> computer (default W2K3 installs). >>> >>> The code examples you pointed out all work fine when targeting the >>> namespace locally, but I recieve access denied messages when useing >>> the same commands remotely. >>> >>> I have tried from multiple machines to multiple servers. The VB >>> Script I supplied still works in all cases, which leads me to >>> believe I am not setting the PowerShell WMI object authentication to >>> use pktPrivacy correctly. >>> >>> Any advice would be appreciated. >>> >>> Thanks >>> Bill >>> "Shay Levi" wrote: >>>> Pinging the remote machine before trying to recycle pools is a >>>> recommended practice. >>>> >>>> Also, I wrote: >>>> >>>> gwmi -class IIsApplicationPool -namespace "root\MicrosoftIISv2" >>>> -computer $computer | % {$_.name} >>>> >>>> for those who are not familiar with gwmi and %, I should say that >>>> they are >>>> aliases for: >>>> gwmi = get-wmiobject >>>> % = foreach-object >>>> I should have written it like: >>>> get-wmiobject -class IIsApplicationPool -namespace >>>> "root\MicrosoftIISv2" -computer $computer | foreach-object >>>> {$_.name} >>>> >>>> ----- >>>> Shay Levi >>>> $cript Fanatic >>>> http://scriptolog.blogspot.com >>>>> If you know the application pool name (the function returns >>>>> true/false respectively: >>>>> >>>>> function Recycle-AppPool{ >>>>> param([string]$server,[string]$appPool) >>>>> ([WMI]"\\$server\root\MicrosoftIISv2:IIsApplicationPool.Name='W3SV >>>>> C/ >>>>> A >>>>> ppPools/$appPool'").recycle(); >>>>> if($? -ne 0}{$false} else {$true} >>>>> } >>>>> To get a list of application pool names: >>>>> $computer = "your Server name/ip" >>>>> gwmi -class IIsApplicationPool -namespace "root\MicrosoftIISv2" >>>>> -computer >>>>> $computer | % {$_.name} >>>>> ----- >>>>> Shay Levi >>>>> $cript Fanatic >>>>> http://scriptolog.blogspot.com >>>>>> I'm having some trouble finding the best method for recycling >>>>>> remote IIS6 application pools using PowerShell. >>>>>> >>>>>> In the past this has always been very easy using VB script: >>>>>> >>>>>> Function PoolRecycle(strServer) >>>>>> >>>>>> On Error Resume Next >>>>>> Err.Clear >>>>>> Dim objWMIService >>>>>> Dim colItems >>>>>> Dim objItem >>>>>> 'recycle application pool >>>>>> WScript.Echo "" >>>>>> Err.Clear >>>>>> Set objWMIService = GetObject _ >>>>>> ("winmgmts:{authenticationLevel=pktPrivacy}\\" _ >>>>>> & strServer & "\root\microsoftiisv2") >>>>>> 'connect to WMI >>>>>> Set colItems = objWMIService.ExecQuery("Select * From >>>>>> IIsApplicationPool") >>>>>> 'Step through the objects to be recycled >>>>>> For each objItem in colItems >>>>>> objItem.Recycle >>>>>> If err = 0 Then >>>>>> WScript.Echo(strServer & " - " & ObjItem.Name & " Recycled") >>>>>> PoolRecycle = "success" >>>>>> Else >>>>>> WScript.Echo("Unable to recycle the application pool on " & >>>>>> strServer) >>>>>> PoolRecycle = "failed" >>>>>> End If >>>>>> Next >>>>>> End Function >>>>>> I have attempted to duplicate the same thing in PowerShell, but I >>>>>> believe I am still running into an issue with the pktPrivacy >>>>>> authentication setting. The following code works when executing >>>>>> localy, but not on a remote host: >>>>>> Function PoolRecycle($strServerName) >>>>>> { >>>>>> $objWMI = [WmiSearcher] "Select * From IIsApplicationPool" >>>>>> $objWMI.Scope.Path = "\\" + $strServerName + >>>>>> "\root\microsoftiisv2" >>>>>> $objWMI.Scope.Options.Authentication = 6 >>>>>> $pools = $objWMI.Get() >>>>>> foreach ($pool in $pools) >>>>>> { >>>>>> $pool.recycle() >>>>>> if (!$?) >>>>>> { >>>>>> Write-Host $pool.name " - ERROR" >>>>>> } >>>>>> else >>>>>> { >>>>>> Write-Host $pool.name " - Recycled" >>>>>> } >>>>>> } >>>>>> } >>>>>> Any help or better ways of accomplishing this in PowerShell would >>>>>> be >>>>>> very much appreciated! >>>>>> Thanks >>>>>> Bill |
My System Specs![]() |
| | #8 (permalink) |
| | Re: remote application pool recycle using WMI \ PowerShell Bill Just to clarify, I'm not able to recycle remote app pools, just list their names (Access denied). Even adding full security on IIsApplicationPool (WMI Properties) didn't resolve it. I'm still on it... ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > Are you able to list the Application poll names? > > $server="server" > $objWMI = [WmiSearcher] "Select * From IIsApplicationPool" > $objWMI.Scope.Path = "\\$server\root\microsoftiisv2" > $objWMI.Scope.Options.Authentication = > [System.Management.AuthenticationLevel]::PacketPrivacy > $pools = $objWMI.Get() > $pools | foreach { $_.name } > ----- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com Quote: >> Hi Shay, >> >> I have tested this and it still does not resolve the issue. >> >> I guess I must be missing something. The fact that the VB Script >> works and the PowerShell does not, leads me to believe that I have an >> issue with my script and not the security on the target server. >> >> I may have to use PowerShell to call the actual .Net class instead of >> using the built in commands. >> >> Funny, I would have never believed that something as simple as >> recycling a remote application pool would be so hard ![]() >> >> Thanks again for the help. >> Bill >> "Shay Levi" wrote: Quote: >>> Bill >>> >>> I can't test it right now. Try this on the remote server(s ![]() >>> >>> 1. Start > Run > dcomcnfg > ENTER >>> 2. In the left pane (Compnent Services.msc) expand "Component >>> Services" > >>> Computers >>> 3. Right click "My Computer" >>> 4. In the "Default Properties" tab tick the "Enable COM Internet >>> Services >>> on this computer" checkbox >>> 5. Reboot remote server >>> 6. Test again >>> I can't recall if you need to add Access Permissions in the "COM >>> Security" tab. >>> ----- >>> Shay Levi >>> $cript Fanatic >>> http://scriptolog.blogspot.com >>>> Shay, >>>> >>>> Thanks for the help, but I see the namespace "root\MicrosoftIISv2" >>>> operate differently when attempting to access it on a remote IIS6 >>>> computer (default W2K3 installs). >>>> >>>> The code examples you pointed out all work fine when targeting the >>>> namespace locally, but I recieve access denied messages when useing >>>> the same commands remotely. >>>> >>>> I have tried from multiple machines to multiple servers. The VB >>>> Script I supplied still works in all cases, which leads me to >>>> believe I am not setting the PowerShell WMI object authentication >>>> to use pktPrivacy correctly. >>>> >>>> Any advice would be appreciated. >>>> >>>> Thanks >>>> Bill >>>> "Shay Levi" wrote: >>>>> Pinging the remote machine before trying to recycle pools is a >>>>> recommended practice. >>>>> >>>>> Also, I wrote: >>>>> >>>>> gwmi -class IIsApplicationPool -namespace "root\MicrosoftIISv2" >>>>> -computer $computer | % {$_.name} >>>>> >>>>> for those who are not familiar with gwmi and %, I should say that >>>>> they are >>>>> aliases for: >>>>> gwmi = get-wmiobject >>>>> % = foreach-object >>>>> I should have written it like: >>>>> get-wmiobject -class IIsApplicationPool -namespace >>>>> "root\MicrosoftIISv2" -computer $computer | foreach-object >>>>> {$_.name} >>>>> ----- >>>>> Shay Levi >>>>> $cript Fanatic >>>>> http://scriptolog.blogspot.com >>>>>> If you know the application pool name (the function returns >>>>>> true/false respectively: >>>>>> >>>>>> function Recycle-AppPool{ >>>>>> param([string]$server,[string]$appPool) >>>>>> ([WMI]"\\$server\root\MicrosoftIISv2:IIsApplicationPool.Name='W3S >>>>>> V >>>>>> C/ >>>>>> A >>>>>> ppPools/$appPool'").recycle(); >>>>>> if($? -ne 0}{$false} else {$true} >>>>>> } >>>>>> To get a list of application pool names: >>>>>> $computer = "your Server name/ip" >>>>>> gwmi -class IIsApplicationPool -namespace "root\MicrosoftIISv2" >>>>>> -computer >>>>>> $computer | % {$_.name} >>>>>> ----- >>>>>> Shay Levi >>>>>> $cript Fanatic >>>>>> http://scriptolog.blogspot.com >>>>>>> I'm having some trouble finding the best method for recycling >>>>>>> remote IIS6 application pools using PowerShell. >>>>>>> >>>>>>> In the past this has always been very easy using VB script: >>>>>>> >>>>>>> Function PoolRecycle(strServer) >>>>>>> >>>>>>> On Error Resume Next >>>>>>> Err.Clear >>>>>>> Dim objWMIService >>>>>>> Dim colItems >>>>>>> Dim objItem >>>>>>> 'recycle application pool >>>>>>> WScript.Echo "" >>>>>>> Err.Clear >>>>>>> Set objWMIService = GetObject _ >>>>>>> ("winmgmts:{authenticationLevel=pktPrivacy}\\" _ >>>>>>> & strServer & "\root\microsoftiisv2") >>>>>>> 'connect to WMI >>>>>>> Set colItems = objWMIService.ExecQuery("Select * From >>>>>>> IIsApplicationPool") >>>>>>> 'Step through the objects to be recycled >>>>>>> For each objItem in colItems >>>>>>> objItem.Recycle >>>>>>> If err = 0 Then >>>>>>> WScript.Echo(strServer & " - " & ObjItem.Name & " Recycled") >>>>>>> PoolRecycle = "success" >>>>>>> Else >>>>>>> WScript.Echo("Unable to recycle the application pool on " & >>>>>>> strServer) >>>>>>> PoolRecycle = "failed" >>>>>>> End If >>>>>>> Next >>>>>>> End Function >>>>>>> I have attempted to duplicate the same thing in PowerShell, but >>>>>>> I >>>>>>> believe I am still running into an issue with the pktPrivacy >>>>>>> authentication setting. The following code works when executing >>>>>>> localy, but not on a remote host: >>>>>>> Function PoolRecycle($strServerName) >>>>>>> { >>>>>>> $objWMI = [WmiSearcher] "Select * From IIsApplicationPool" >>>>>>> $objWMI.Scope.Path = "\\" + $strServerName + >>>>>>> "\root\microsoftiisv2" >>>>>>> $objWMI.Scope.Options.Authentication = 6 >>>>>>> $pools = $objWMI.Get() >>>>>>> foreach ($pool in $pools) >>>>>>> { >>>>>>> $pool.recycle() >>>>>>> if (!$?) >>>>>>> { >>>>>>> Write-Host $pool.name " - ERROR" >>>>>>> } >>>>>>> else >>>>>>> { >>>>>>> Write-Host $pool.name " - Recycled" >>>>>>> } >>>>>>> } >>>>>>> } >>>>>>> Any help or better ways of accomplishing this in PowerShell >>>>>>> would >>>>>>> be >>>>>>> very much appreciated! >>>>>>> Thanks >>>>>>> Bill |
My System Specs![]() |
| | #9 (permalink) |
| | Re: remote application pool recycle using WMI \ PowerShell Hi Shay, Yeah, I can list the pools, but only after specifing the authentication setting. It's almost like it does not carry to the other objects. I appreciate the help. Thanks Bill "Shay Levi" wrote: Quote: > Bill > > Just to clarify, I'm not able to recycle remote app pools, just list their > names (Access denied). > Even adding full security on IIsApplicationPool (WMI Properties) didn't resolve > it. > I'm still on it... > > ----- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com > > > Quote: > > Are you able to list the Application poll names? > > > > $server="server" > > $objWMI = [WmiSearcher] "Select * From IIsApplicationPool" > > $objWMI.Scope.Path = "\\$server\root\microsoftiisv2" > > $objWMI.Scope.Options.Authentication = > > [System.Management.AuthenticationLevel]::PacketPrivacy > > $pools = $objWMI.Get() > > $pools | foreach { $_.name } > > ----- > > Shay Levi > > $cript Fanatic > > http://scriptolog.blogspot.com Quote: > >> Hi Shay, > >> > >> I have tested this and it still does not resolve the issue. > >> > >> I guess I must be missing something. The fact that the VB Script > >> works and the PowerShell does not, leads me to believe that I have an > >> issue with my script and not the security on the target server. > >> > >> I may have to use PowerShell to call the actual .Net class instead of > >> using the built in commands. > >> > >> Funny, I would have never believed that something as simple as > >> recycling a remote application pool would be so hard ![]() > >> > >> Thanks again for the help. > >> Bill > >> "Shay Levi" wrote: > >>> Bill > >>> > >>> I can't test it right now. Try this on the remote server(s ![]() > >>> > >>> 1. Start > Run > dcomcnfg > ENTER > >>> 2. In the left pane (Compnent Services.msc) expand "Component > >>> Services" > > >>> Computers > >>> 3. Right click "My Computer" > >>> 4. In the "Default Properties" tab tick the "Enable COM Internet > >>> Services > >>> on this computer" checkbox > >>> 5. Reboot remote server > >>> 6. Test again > >>> I can't recall if you need to add Access Permissions in the "COM > >>> Security" tab. > >>> ----- > >>> Shay Levi > >>> $cript Fanatic > >>> http://scriptolog.blogspot.com > >>>> Shay, > >>>> > >>>> Thanks for the help, but I see the namespace "root\MicrosoftIISv2" > >>>> operate differently when attempting to access it on a remote IIS6 > >>>> computer (default W2K3 installs). > >>>> > >>>> The code examples you pointed out all work fine when targeting the > >>>> namespace locally, but I recieve access denied messages when useing > >>>> the same commands remotely. > >>>> > >>>> I have tried from multiple machines to multiple servers. The VB > >>>> Script I supplied still works in all cases, which leads me to > >>>> believe I am not setting the PowerShell WMI object authentication > >>>> to use pktPrivacy correctly. > >>>> > >>>> Any advice would be appreciated. > >>>> > >>>> Thanks > >>>> Bill > >>>> "Shay Levi" wrote: > >>>>> Pinging the remote machine before trying to recycle pools is a > >>>>> recommended practice. > >>>>> > >>>>> Also, I wrote: > >>>>> > >>>>> gwmi -class IIsApplicationPool -namespace "root\MicrosoftIISv2" > >>>>> -computer $computer | % {$_.name} > >>>>> > >>>>> for those who are not familiar with gwmi and %, I should say that > >>>>> they are > >>>>> aliases for: > >>>>> gwmi = get-wmiobject > >>>>> % = foreach-object > >>>>> I should have written it like: > >>>>> get-wmiobject -class IIsApplicationPool -namespace > >>>>> "root\MicrosoftIISv2" -computer $computer | foreach-object > >>>>> {$_.name} > >>>>> ----- > >>>>> Shay Levi > >>>>> $cript Fanatic > >>>>> http://scriptolog.blogspot.com > >>>>>> If you know the application pool name (the function returns > >>>>>> true/false respectively: > >>>>>> > >>>>>> function Recycle-AppPool{ > >>>>>> param([string]$server,[string]$appPool) > >>>>>> ([WMI]"\\$server\root\MicrosoftIISv2:IIsApplicationPool.Name='W3S > >>>>>> V > >>>>>> C/ > >>>>>> A > >>>>>> ppPools/$appPool'").recycle(); > >>>>>> if($? -ne 0}{$false} else {$true} > >>>>>> } > >>>>>> To get a list of application pool names: > >>>>>> $computer = "your Server name/ip" > >>>>>> gwmi -class IIsApplicationPool -namespace "root\MicrosoftIISv2" > >>>>>> -computer > >>>>>> $computer | % {$_.name} > >>>>>> ----- > >>>>>> Shay Levi > >>>>>> $cript Fanatic > >>>>>> http://scriptolog.blogspot.com > >>>>>>> I'm having some trouble finding the best method for recycling > >>>>>>> remote IIS6 application pools using PowerShell. > >>>>>>> > >>>>>>> In the past this has always been very easy using VB script: > >>>>>>> > >>>>>>> Function PoolRecycle(strServer) > >>>>>>> > >>>>>>> On Error Resume Next > >>>>>>> Err.Clear > >>>>>>> Dim objWMIService > >>>>>>> Dim colItems > >>>>>>> Dim objItem > >>>>>>> 'recycle application pool > >>>>>>> WScript.Echo "" > >>>>>>> Err.Clear > >>>>>>> Set objWMIService = GetObject _ > >>>>>>> ("winmgmts:{authenticationLevel=pktPrivacy}\\" _ > >>>>>>> & strServer & "\root\microsoftiisv2") > >>>>>>> 'connect to WMI > >>>>>>> Set colItems = objWMIService.ExecQuery("Select * From > >>>>>>> IIsApplicationPool") > >>>>>>> 'Step through the objects to be recycled > >>>>>>> For each objItem in colItems > >>>>>>> objItem.Recycle > >>>>>>> If err = 0 Then > >>>>>>> WScript.Echo(strServer & " - " & ObjItem.Name & " Recycled") > >>>>>>> PoolRecycle = "success" > >>>>>>> Else > >>>>>>> WScript.Echo("Unable to recycle the application pool on " & > >>>>>>> strServer) > >>>>>>> PoolRecycle = "failed" > >>>>>>> End If > >>>>>>> Next > >>>>>>> End Function > >>>>>>> I have attempted to duplicate the same thing in PowerShell, but > >>>>>>> I > >>>>>>> believe I am still running into an issue with the pktPrivacy > >>>>>>> authentication setting. The following code works when executing > >>>>>>> localy, but not on a remote host: > >>>>>>> Function PoolRecycle($strServerName) > >>>>>>> { > >>>>>>> $objWMI = [WmiSearcher] "Select * From IIsApplicationPool" > >>>>>>> $objWMI.Scope.Path = "\\" + $strServerName + > >>>>>>> "\root\microsoftiisv2" > >>>>>>> $objWMI.Scope.Options.Authentication = 6 > >>>>>>> $pools = $objWMI.Get() > >>>>>>> foreach ($pool in $pools) > >>>>>>> { > >>>>>>> $pool.recycle() > >>>>>>> if (!$?) > >>>>>>> { > >>>>>>> Write-Host $pool.name " - ERROR" > >>>>>>> } > >>>>>>> else > >>>>>>> { > >>>>>>> Write-Host $pool.name " - Recycled" > >>>>>>> } > >>>>>>> } > >>>>>>> } > >>>>>>> Any help or better ways of accomplishing this in PowerShell > >>>>>>> would > >>>>>>> be > >>>>>>> very much appreciated! > >>>>>>> Thanks > >>>>>>> Bill > > |
My System Specs![]() |
| | #10 (permalink) |
| | Re: remote application pool recycle using WMI \ PowerShell I'll keep looking for it :-) ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > Hi Shay, > > Yeah, I can list the pools, but only after specifing the > authentication setting. > > It's almost like it does not carry to the other objects. > > I appreciate the help. > > Thanks > Bill > "Shay Levi" wrote: > Quote: >> Bill >> >> Just to clarify, I'm not able to recycle remote app pools, just list >> their >> names (Access denied). >> Even adding full security on IIsApplicationPool (WMI Properties) >> didn't resolve >> it. >> I'm still on it... >> ----- >> Shay Levi >> $cript Fanatic >> http://scriptolog.blogspot.com Quote: >>> Are you able to list the Application poll names? >>> >>> $server="server" >>> $objWMI = [WmiSearcher] "Select * From IIsApplicationPool" >>> $objWMI.Scope.Path = "\\$server\root\microsoftiisv2" >>> $objWMI.Scope.Options.Authentication = >>> [System.Management.AuthenticationLevel]::PacketPrivacy >>> $pools = $objWMI.Get() >>> $pools | foreach { $_.name } >>> ----- >>> Shay Levi >>> $cript Fanatic >>> http://scriptolog.blogspot.com >>>> Hi Shay, >>>> >>>> I have tested this and it still does not resolve the issue. >>>> >>>> I guess I must be missing something. The fact that the VB Script >>>> works and the PowerShell does not, leads me to believe that I have >>>> an issue with my script and not the security on the target server. >>>> >>>> I may have to use PowerShell to call the actual .Net class instead >>>> of using the built in commands. >>>> >>>> Funny, I would have never believed that something as simple as >>>> recycling a remote application pool would be so hard ![]() >>>> >>>> Thanks again for the help. >>>> Bill >>>> "Shay Levi" wrote: >>>>> Bill >>>>> >>>>> I can't test it right now. Try this on the remote server(s ![]() >>>>> >>>>> 1. Start > Run > dcomcnfg > ENTER >>>>> 2. In the left pane (Compnent Services.msc) expand "Component >>>>> Services" > >>>>> Computers >>>>> 3. Right click "My Computer" >>>>> 4. In the "Default Properties" tab tick the "Enable COM Internet >>>>> Services >>>>> on this computer" checkbox >>>>> 5. Reboot remote server >>>>> 6. Test again >>>>> I can't recall if you need to add Access Permissions in the "COM >>>>> Security" tab. >>>>> ----- >>>>> Shay Levi >>>>> $cript Fanatic >>>>> http://scriptolog.blogspot.com >>>>>> Shay, >>>>>> >>>>>> Thanks for the help, but I see the namespace >>>>>> "root\MicrosoftIISv2" operate differently when attempting to >>>>>> access it on a remote IIS6 computer (default W2K3 installs). >>>>>> >>>>>> The code examples you pointed out all work fine when targeting >>>>>> the namespace locally, but I recieve access denied messages when >>>>>> useing the same commands remotely. >>>>>> >>>>>> I have tried from multiple machines to multiple servers. The VB >>>>>> Script I supplied still works in all cases, which leads me to >>>>>> believe I am not setting the PowerShell WMI object authentication >>>>>> to use pktPrivacy correctly. >>>>>> >>>>>> Any advice would be appreciated. >>>>>> >>>>>> Thanks >>>>>> Bill >>>>>> "Shay Levi" wrote: >>>>>>> Pinging the remote machine before trying to recycle pools is a >>>>>>> recommended practice. >>>>>>> >>>>>>> Also, I wrote: >>>>>>> >>>>>>> gwmi -class IIsApplicationPool -namespace "root\MicrosoftIISv2" >>>>>>> -computer $computer | % {$_.name} >>>>>>> >>>>>>> for those who are not familiar with gwmi and %, I should say >>>>>>> that >>>>>>> they are >>>>>>> aliases for: >>>>>>> gwmi = get-wmiobject >>>>>>> % = foreach-object >>>>>>> I should have written it like: >>>>>>> get-wmiobject -class IIsApplicationPool -namespace >>>>>>> "root\MicrosoftIISv2" -computer $computer | foreach-object >>>>>>> {$_.name} >>>>>>> ----- >>>>>>> Shay Levi >>>>>>> $cript Fanatic >>>>>>> http://scriptolog.blogspot.com >>>>>>>> If you know the application pool name (the function returns >>>>>>>> true/false respectively: >>>>>>>> >>>>>>>> function Recycle-AppPool{ >>>>>>>> param([string]$server,[string]$appPool) >>>>>>>> ([WMI]"\\$server\root\MicrosoftIISv2:IIsApplicationPool.Name='W >>>>>>>> 3S >>>>>>>> V >>>>>>>> C/ >>>>>>>> A >>>>>>>> ppPools/$appPool'").recycle(); >>>>>>>> if($? -ne 0}{$false} else {$true} >>>>>>>> } >>>>>>>> To get a list of application pool names: >>>>>>>> $computer = "your Server name/ip" >>>>>>>> gwmi -class IIsApplicationPool -namespace "root\MicrosoftIISv2" >>>>>>>> -computer >>>>>>>> $computer | % {$_.name} >>>>>>>> ----- >>>>>>>> Shay Levi >>>>>>>> $cript Fanatic >>>>>>>> http://scriptolog.blogspot.com >>>>>>>>> I'm having some trouble finding the best method for recycling >>>>>>>>> remote IIS6 application pools using PowerShell. >>>>>>>>> >>>>>>>>> In the past this has always been very easy using VB script: >>>>>>>>> >>>>>>>>> Function PoolRecycle(strServer) >>>>>>>>> >>>>>>>>> On Error Resume Next >>>>>>>>> Err.Clear >>>>>>>>> Dim objWMIService >>>>>>>>> Dim colItems >>>>>>>>> Dim objItem >>>>>>>>> 'recycle application pool >>>>>>>>> WScript.Echo "" >>>>>>>>> Err.Clear >>>>>>>>> Set objWMIService = GetObject _ >>>>>>>>> ("winmgmts:{authenticationLevel=pktPrivacy}\\" _ >>>>>>>>> & strServer & "\root\microsoftiisv2") >>>>>>>>> 'connect to WMI >>>>>>>>> Set colItems = objWMIService.ExecQuery("Select * From >>>>>>>>> IIsApplicationPool") >>>>>>>>> 'Step through the objects to be recycled >>>>>>>>> For each objItem in colItems >>>>>>>>> objItem.Recycle >>>>>>>>> If err = 0 Then >>>>>>>>> WScript.Echo(strServer & " - " & ObjItem.Name & " Recycled") >>>>>>>>> PoolRecycle = "success" >>>>>>>>> Else >>>>>>>>> WScript.Echo("Unable to recycle the application pool on " & >>>>>>>>> strServer) >>>>>>>>> PoolRecycle = "failed" >>>>>>>>> End If >>>>>>>>> Next >>>>>>>>> End Function >>>>>>>>> I have attempted to duplicate the same thing in PowerShell, >>>>>>>>> but >>>>>>>>> I >>>>>>>>> believe I am still running into an issue with the pktPrivacy >>>>>>>>> authentication setting. The following code works when >>>>>>>>> executing >>>>>>>>> localy, but not on a remote host: >>>>>>>>> Function PoolRecycle($strServerName) >>>>>>>>> { >>>>>>>>> $objWMI = [WmiSearcher] "Select * From IIsApplicationPool" >>>>>>>>> $objWMI.Scope.Path = "\\" + $strServerName + >>>>>>>>> "\root\microsoftiisv2" >>>>>>>>> $objWMI.Scope.Options.Authentication = 6 >>>>>>>>> $pools = $objWMI.Get() >>>>>>>>> foreach ($pool in $pools) >>>>>>>>> { >>>>>>>>> $pool.recycle() >>>>>>>>> if (!$?) >>>>>>>>> { >>>>>>>>> Write-Host $pool.name " - ERROR" >>>>>>>>> } >>>>>>>>> else >>>>>>>>> { >>>>>>>>> Write-Host $pool.name " - Recycled" >>>>>>>>> } >>>>>>>>> } >>>>>>>>> } >>>>>>>>> Any help or better ways of accomplishing this in PowerShell >>>>>>>>> would >>>>>>>>> be >>>>>>>>> very much appreciated! >>>>>>>>> Thanks >>>>>>>>> Bill |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Remote Application | Vista networking & sharing | |||
| Re: Remote Development of VB.NET Application | .NET General | |||
| RE: How do you run a One-Click application from PowerShell | PowerShell | |||
| How to install an application using PowerShell | PowerShell | |||
| Uninstall an application using Powershell | PowerShell | |||