<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Powershell Script to Poll for IIS AppPool consuming large amount of memory in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/673512#M112784</link>
    <description>&lt;P&gt;# Import IIS module&lt;BR /&gt;Import-Module WebAdministration&lt;/P&gt;&lt;P&gt;# Get the list of Application Pools&lt;BR /&gt;$appPools = Get-ChildItem IIS:\AppPools&lt;/P&gt;&lt;P&gt;# Display the App Pool names and their statuses in key-value pairs&lt;BR /&gt;foreach ($appPool in $appPools) {&lt;BR /&gt;$status = Get-WebAppPoolState -Name $appPool.name&lt;BR /&gt;Write-Output "appPoolName=$($appPool.name), appPoolStatus=$($status.Value)"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can expand with more details inf you like.&lt;BR /&gt;You can run by either calling with powershell in your stanza or via cmd and call it with powershell that way.&lt;/P&gt;</description>
    <pubDate>Mon, 08 Jan 2024 09:46:03 GMT</pubDate>
    <dc:creator>astralsailor</dc:creator>
    <dc:date>2024-01-08T09:46:03Z</dc:date>
    <item>
      <title>Powershell Script to Poll for IIS AppPool consuming large amount of memory- is there a better way?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/559154#M92493</link>
      <description>&lt;P&gt;Our application developers were looking to poll the service states of their IIS Application Pools.&amp;nbsp; This would be just like the Windows Service States (Start/Stopped/Disabled).&lt;/P&gt;
&lt;P&gt;He wrote a powershell script to check if the Windows Host has IIS installed and if so, checks the service state of all Application Pools.&amp;nbsp; This was tested in a test environment without any issues.&amp;nbsp; However, it is now consuming up to 7GB of memory.&lt;/P&gt;
&lt;P&gt;My question is, for custom powershell scripts.&amp;nbsp; I'm not completely versed on Powershell, so can't say for sure if this code is the most optimal method for achieving the results.&amp;nbsp; Is there a better way?&amp;nbsp; For such a small task, why would it consume so much memory?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;#### SysInternals Process Info #####
Command Line: powershell.exe -command "&amp;amp; {get-content "C:\Windows\TEMP\\inputffdc149fdcf785fb.tmp" | "C:\Program Files\SplunkUniversalFowarder\bin\splunk-powershell.ps1" "C:\Program Files\SplunkUniversalForwarder" ffdc1449fdcf785fb}"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The powershell.log file only has two lines when it runs:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;07-09-2021 11:11:58.8862744-5 INFO start splunk-powershell.ps1
07-09-2021 11:12:00.5243172-5 INFO launched disposer&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The temp file contains info about the app-pool.ps1 stanza&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SplunkServerUri:https://127.0.0.1:8089
SplunkSessionKey:&amp;lt;redacted&amp;gt;
stanzas
stanza:App-Pool-State
event_group:-1,1
index:appdevadmin_servers
script:. "$SplunkHome\etc\apps\loves_ta_windows_appdev\bin\powershell\app-pool.ps1"
source:powershell://App-Pool-State
sourcetype:Windows:AppPool&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Inputs.conf&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;###### Inputs.conf ######
[powershell://App-Pool-State]
script = . "$SplunkHome\etc\apps\loves_ta_windows_appdev\bin\powershell\app-pool.ps1"
schedule = */5 * * * *
disabled = 0
sourcetype = Windows:AppPool
index = appdevadmin_servers&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Powershell Script&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;###### app-pool.ps1 #####
If (Get-WmiObject -Class Win32_ServerFeature -ComputerName $env:computername | Where-Object {$_.name -like "Web Server (IIS)"}){
    Import-Module WebAdministration
    $ApplicationPools = Get-ChildItem IIS:\AppPools;
    Foreach ($ApplicationPool in $ApplicationPools){
      $ApplicationPoolName = $ApplicationPool.Name;
      $ApplicationPoolState = $ApplicationPool.State;
      If ($ApplicationPool.processModel.identityType -eq 'SpecificUser'){
        $UserIdentity = $ApplicationPool.processModel.UserName;
      }
      else {
        $UserIdentity = $ApplicationPool.processModel.identityType;
      }
      Write-Output "
      ApplicationPoolName=`"$ApplicationPoolName`"
      ApplicationPoolState=`"$ApplicationPoolState`"
      UserIdentity=`"$UserIdentity`"
      ";
    }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 14:35:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/559154#M92493</guid>
      <dc:creator>JHannan</dc:creator>
      <dc:date>2022-02-10T14:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script to Poll for IIS AppPool consuming large amount of memory</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/580385#M102392</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/151941"&gt;@JHannan&lt;/a&gt;&amp;nbsp;I have similar requirement, did you ever get this resolved? If so, could you please share with me the working PS script and the inputs.conf file that you are using. I have a requirement to get the IIS AppPool Status from Splunk which will send an alert if the status changes to "stopped".&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 04:38:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/580385#M102392</guid>
      <dc:creator>alexlexxy</dc:creator>
      <dc:date>2022-01-10T04:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script to Poll for IIS AppPool consuming large amount of memory</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/580386#M102393</link>
      <description>&lt;P&gt;can you ask the powershell&amp;nbsp; guy to use the&amp;nbsp;&lt;SPAN&gt;Get-IISAppPool cmdlet instead of get-wmiobject and see if he can get the same results.I cannot check this dont have an env to test on. But this should sort the script up.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 05:01:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/580386#M102393</guid>
      <dc:creator>SinghK</dc:creator>
      <dc:date>2022-01-10T05:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script to Poll for IIS AppPool consuming large amount of memory</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/580405#M102394</link>
      <description>&lt;P&gt;He did run the cmdlet Get-IISAppPool and got the desired result from power shell prompt. But my issue is how to implement this in splunk to be able to see the same status and use them to set alerts. The AppPool data that is in splunk does not include the status nor event codes associated with the status. So my assessment is that a new input script is required, but can’t figure it out&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 06:25:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/580405#M102394</guid>
      <dc:creator>alexlexxy</dc:creator>
      <dc:date>2022-01-10T06:25:25Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script to Poll for IIS AppPool consuming large amount of memory</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/580409#M102395</link>
      <description>&lt;P&gt;You can write them to file and the monitor it.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 07:51:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/580409#M102395</guid>
      <dc:creator>SinghK</dc:creator>
      <dc:date>2022-01-10T07:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script to Poll for IIS AppPool consuming large amount of memory</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/580410#M102396</link>
      <description>&lt;P&gt;If you can share the output of that cmdlet maybe I can write something with sample data so it gets parsed properly in splunk&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 07:53:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/580410#M102396</guid>
      <dc:creator>SinghK</dc:creator>
      <dc:date>2022-01-10T07:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script to Poll for IIS AppPool consuming large amount of memory</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/580440#M102400</link>
      <description>&lt;P&gt;what i have seenin examples is the cmdlet does not provide eventcodes etc. neither will get-wmiobject. you will have to correlate that yourself.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 12:01:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/580440#M102400</guid>
      <dc:creator>SinghK</dc:creator>
      <dc:date>2022-01-10T12:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script to Poll for IIS AppPool consuming large amount of memory</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/580470#M102410</link>
      <description>&lt;P&gt;the script works, however it has a memory leak on the servers. That was the issue which opened this as over time memory is slowly eaten.&lt;/P&gt;&lt;P&gt;THe script returns the following to splunk&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;1/10/22&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;9:05:01.000 AM&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;ApplicationPoolName=&lt;/SPAN&gt;"&lt;SPAN class=""&gt;Sites&lt;/SPAN&gt;" &lt;SPAN class=""&gt;ApplicationPoolState=&lt;/SPAN&gt;"&lt;SPAN class=""&gt;Started&lt;/SPAN&gt;" &lt;SPAN class=""&gt;UserIdentity=&lt;/SPAN&gt;"&lt;SPAN class=""&gt;domain\SvcUser&lt;/SPAN&gt;"&lt;/DIV&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 10 Jan 2022 15:13:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/580470#M102410</guid>
      <dc:creator>JasonMcMahan</dc:creator>
      <dc:date>2022-01-10T15:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script to Poll for IIS AppPool consuming large amount of memory</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/580491#M102416</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231588"&gt;@JasonMcMahan&lt;/a&gt;&amp;nbsp;you created a new HEC input and used the token?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 17:09:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/580491#M102416</guid>
      <dc:creator>alexlexxy</dc:creator>
      <dc:date>2022-01-10T17:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script to Poll for IIS AppPool consuming large amount of memory</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/580519#M102420</link>
      <description>&lt;P&gt;I got it working! Thanks to everyone that contributed.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 19:53:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/580519#M102420</guid>
      <dc:creator>alexlexxy</dc:creator>
      <dc:date>2022-01-10T19:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script to Poll for IIS AppPool consuming large amount of memory</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/580521#M102421</link>
      <description>&lt;P&gt;What script, cmdlet and output did you end up using?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 20:33:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/580521#M102421</guid>
      <dc:creator>JasonMcMahan</dc:creator>
      <dc:date>2022-01-10T20:33:29Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script to Poll for IIS AppPool consuming large amount of memory</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/584527#M102880</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I believe I know the problem based on some testing we did at my company.&amp;nbsp; I believe the root issue is when executing powershell with the powershell stanza it is invoking splunk-powershell.exe and that executable is not managing powershells memory at all.&amp;nbsp; In order to have the memory clear after your script completes you need to put this command at the end of your script:&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;[System.gc]::Collect()&lt;/LI-CODE&gt;&lt;P&gt;This will force a garbage collection of powershell.exe's memory. If you do not do this then each iteration of your script will continually add to powershell's memory footprint since the memory is never cleared.&amp;nbsp; This article was very enlightening in regards to memory management with powershell: &lt;A href="https://www.cloudsparkle.be/2021-05-06-PowerShellMemory/" target="_blank"&gt;https://www.cloudsparkle.be/2021-05-06-PowerShellMemory/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Personally I believe this should be handled by the splunk-powershell.exe process and I believe it should be treated as a defect by splunk.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 13:37:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/584527#M102880</guid>
      <dc:creator>dmarling</dc:creator>
      <dc:date>2022-02-10T13:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script to Poll for IIS AppPool consuming large amount of memory</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/585009#M102938</link>
      <description>&lt;P&gt;Thank you Dmarling,&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are adding the line to our script and will be testing, monitoring the memory this week. For us normally it takes approximately 9 days to get memory to the 80-90% range. We really appreciate your help and reply.&lt;/P&gt;&lt;P&gt;Thank you again&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 17:17:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/585009#M102938</guid>
      <dc:creator>JasonMcMahan</dc:creator>
      <dc:date>2022-02-14T17:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script to Poll for IIS AppPool consuming large amount of memory</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/587238#M103162</link>
      <description>&lt;P&gt;Good morning,&amp;nbsp;&lt;/P&gt;&lt;P&gt;We did see some decrease in memory however initially i was not sure if the GC need to be inside or outside the foreach loop.&lt;/P&gt;&lt;P&gt;Originally i had&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;If (Get-WmiObject -Class Win32_ServerFeature -ComputerName $env:computername | Where-Object {$_.name -like "Web Server (IIS)"}){
    Import-Module WebAdministration
    $ApplicationPools = Get-ChildItem IIS:\AppPools;
    Foreach ($ApplicationPool in $ApplicationPools){
      $ApplicationPoolName = $ApplicationPool.Name;
      $ApplicationPoolState = $ApplicationPool.State;
      If ($ApplicationPool.processModel.identityType -eq 'SpecificUser'){
        $UserIdentity = $ApplicationPool.processModel.UserName;
      }
      else {
        $UserIdentity = $ApplicationPool.processModel.identityType;
      }
      Write-Output "
      ApplicationPoolName=`"$ApplicationPoolName`"
      ApplicationPoolState=`"$ApplicationPoolState`"
      UserIdentity=`"$UserIdentity`"
      ";
    }
    Remove-Module WebAdministration
}
[System.gc]::Collect()&lt;/LI-CODE&gt;&lt;P&gt;but memory slowly creeped upward so altered the script to&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;If (Get-WmiObject -Class Win32_ServerFeature -ComputerName $env:computername | Where-Object {$_.name -like "Web Server (IIS)"}){
    Import-Module WebAdministration
    $ApplicationPools = Get-ChildItem IIS:\AppPools;
    Foreach ($ApplicationPool in $ApplicationPools){
      $ApplicationPoolName = $ApplicationPool.Name;
      $ApplicationPoolState = $ApplicationPool.State;
      If ($ApplicationPool.processModel.identityType -eq 'SpecificUser'){
        $UserIdentity = $ApplicationPool.processModel.UserName;
      }
      else {
        $UserIdentity = $ApplicationPool.processModel.identityType;
      }
      Write-Output "
      ApplicationPoolName=`"$ApplicationPoolName`"
      ApplicationPoolState=`"$ApplicationPoolState`"
      UserIdentity=`"$UserIdentity`"
      ";
      [System.gc]::Collect()
    }
    Remove-Module WebAdministration
}&lt;/LI-CODE&gt;&lt;P&gt;watching this currently to evaluate. Also testing the following variants.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;If (Get-WmiObject -Class Win32_ServerFeature -ComputerName $env:computername | Where-Object {$_.name -like "Web Server (IIS)"}){

    $ApplicationPools = Get-WebConfiguration -Filter '/system.applicationHost/applicationPools/add'
    foreach ($ApplicationPool in $ApplicationPools){
        $ApplicationPoolName = $ApplicationPool.Name;
        $ApplicationPoolState = $ApplicationPool.State;
        If ($ApplicationPool.processModel.identityType -eq 'SpecificUser'){
            $UserIdentity = $ApplicationPool.processModel.UserName;
        }
        else {
            $UserIdentity = $ApplicationPool.processModel.identityType;
        }
        Write-Output "
            ApplicationPoolName: $ApplicationPoolName
            ApplicationPoolState: $ApplicationPoolState
            UserIdentity: $UserIdentity
        ";
        [System.gc]::Collect()
    }
    Remove-Module WebAdministration
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;So watching it a bit longer. Unfortunately this is a slow memory creep 9 days or so before it normally reaches its peek.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 14:15:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/587238#M103162</guid>
      <dc:creator>JasonMcMahan</dc:creator>
      <dc:date>2022-03-02T14:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script to Poll for IIS AppPool consuming large amount of memory</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/588114#M103243</link>
      <description>&lt;P&gt;I wanted to offer and update.&lt;/P&gt;&lt;P&gt;After making the change and performing a restart of the forwarder service memory still climbed pretty quickly to near what it was prior. I then restarted the client servers i running the script on and now 7 days not only as it held between 30-50% i even saw a spike to 76% at one point then it reclaimed 12 hrs later. That at least tells me most likely adding system.gc corrects the issue but requires a restart of the system. I will continue to watch mine for another week or so but consider the matter closed. Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 20:49:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/588114#M103243</guid>
      <dc:creator>JasonMcMahan</dc:creator>
      <dc:date>2022-03-08T20:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script to Poll for IIS AppPool consuming large amount of memory</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/673512#M112784</link>
      <description>&lt;P&gt;# Import IIS module&lt;BR /&gt;Import-Module WebAdministration&lt;/P&gt;&lt;P&gt;# Get the list of Application Pools&lt;BR /&gt;$appPools = Get-ChildItem IIS:\AppPools&lt;/P&gt;&lt;P&gt;# Display the App Pool names and their statuses in key-value pairs&lt;BR /&gt;foreach ($appPool in $appPools) {&lt;BR /&gt;$status = Get-WebAppPoolState -Name $appPool.name&lt;BR /&gt;Write-Output "appPoolName=$($appPool.name), appPoolStatus=$($status.Value)"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can expand with more details inf you like.&lt;BR /&gt;You can run by either calling with powershell in your stanza or via cmd and call it with powershell that way.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2024 09:46:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-to-Poll-for-IIS-AppPool-consuming-large-amount/m-p/673512#M112784</guid>
      <dc:creator>astralsailor</dc:creator>
      <dc:date>2024-01-08T09:46:03Z</dc:date>
    </item>
  </channel>
</rss>

