-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSP-Clean-Service-AppPools.ps1
More file actions
53 lines (43 loc) · 1.23 KB
/
SP-Clean-Service-AppPools.ps1
File metadata and controls
53 lines (43 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<#
.DESCRIPTION
Compares available Service Application IIS Pools to active used.
Optionally can delete InActive pools to reduce IIS memory usage and streamline farm configuration.
.PARAMETER delete
Will delete InActive pools from the farm.
.EXAMPLE
.\SP-Clean-Service-AppPools.ps1
.\SP-Clean-Service-AppPools.ps1 -delete
.NOTES
File Name: SP-Clean-Service-AppPools.ps1
Author : Jeff Jones - spjeff@spjeff.com
Version : 1.0
Modified : 2018-10-02
#>
[CmdletBinding()]
param (
[switch]$delete
)
# Log
Start-Transcript
# Modules
Add-PSSnapIn Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue | Out-Null
# Clean up IIS service application pools
$avail = (Get-SPServiceApplicationPool).id.guid
$used = (Get-SPServiceApplication).applicationpool.id.guid
# Loop available and check for usage.
Write-Host "Scanning Service Application pools..." -Fore Yellow
foreach ($a in $avail) {
Write-Host "Checking pool [$a]" -Fore Yellow
$match = $used |? {$_ -eq $a}
if ($match) {
Write-Host " - Active" -Fore Green
} else {
Write-Host " - InActive" -Fore Red
if ($delete) {
Remove-SPServiceApplicationPool $a -Confirm:$false
Write-Host " - DELETED pool [$a]" -Fore White -Back Red
}
}
}
# Log
Stop-Transcript