I am trying to display whether the AppPool for IIS is started or not. By default it will display all AppPool State.
But if a parameter -EA (--exceptionAppPool) is passed while running the script it will not consider the status of those AppPool.
I am somehow stuck with the else{} statement when -EA is passed. Not sure how to remove the list of array passed in -EA from being considered in Get-WebAppPoolState method
param([String[]]$EA) if (-Not ($ParamAvailable = $PSBoundParameters.ContainsKey('EA'))){ $ApplicationPoolsState = Get-WebAppPoolState | % { return @{($_.itemxpath -split ("'"))[1]="$($_.value)" } } | % getEnumerator | % { if ($_.value -ne "Started"){ $statuses.critical += $_.key } else{ $statuses.ok += $_.key } } } else{ #----I want to exclude the Keys which is present in -EA array ? #----The example of -EA is .NET v4.5,.NET v4.5 Classic,DefaultAppPool $ApplicationPoolsState = Get-WebAppPoolState | % { return @{($_.itemxpath -split ("'"))[1]="$($_.value)" } } for ($i=0; $i -lt $EA.length; $i++){ $ApplicationPoolsState = $ApplicationPoolsState.Remove($EA[$i]) } $ApplicationPoolsState = $ApplicationPoolsState | % getEnumerator | % { if ($_.value -ne "Started"){ $statuses.critical += $_.key } else{ $statuses.ok += $_.key } } script will run like .\check_appPool.ps1 -EA .NET v4.5,.NET v4.5 Classic,DefaultAppPool
Got error
Exception calling "Remove" with "1" argument(s): "Collection was of a fixed size."
How do I exclude those from being checked in the else statement