-
Notifications
You must be signed in to change notification settings - Fork 1
/
Configure-Iis.ps1
56 lines (45 loc) · 1.86 KB
/
Configure-Iis.ps1
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
54
55
56
<#
.SYNOPSIS
Remove IIS default App Pools and Web Sites.
Configures the default Log file location for future Web Sites.
Configures additional log fields.
.DESCRIPTION
Remove IIS default App Pools and Web Sites.
Configures the default Log file location for future Web Sites.
Configures additional log fields.
Intended to ensure a clean configuration prior to creating or joining machines to a SharePoint Farm.
Assumes the SharePoint Pre-requisites installer has been used, or eviqualent pre reqs installed.
25/06/2015
.NOTES
File Name : Configure-Iis.ps1
Author : Spencer Harbar ([email protected])
Requires : PowerShell Version 2.0
.LINK
.PARAMETER File
#>
#region PARAMS
param (
[String]$IisLogsLocation,
[String]$WebSite = "Default Web Site",
[String[]]$AppPools = (".NET v2.0", ".NET v2.0 Classic", ".NET v4.5", ".NET v4.5 Classic", "Classic .NET AppPool", "DefaultAppPool"),
[String]$IisLogFields = "Date,Time,ClientIP,UserName,ServerIP,Method,UriStem,UriQuery,HttpStatus,Win32Status,BytesSent,BytesRecv,TimeTaken,ServerPort,UserAgent,Host,HttpSubStatus"
)
#endregion PARAMS
Import-Module WebAdministration
# Remove web site
if (Get-Website -Name $WebSite) { Remove-WebSite -Name $WebSite }
# remove application pools
foreach ($AppPool in $AppPools) {
if (Test-Path IIS:\AppPools\$AppPool) {
Remove-WebAppPool -name $AppPool
}
}
# Set the default log location
if ($IisLogsLocation -ne $null) {
Set-WebConfigurationProperty "/system.applicationHost/sites/siteDefaults" -name logfile.directory -value $IisLogsLocation
}
# Set the fields to log
Set-WebConfigurationProperty -Filter System.Applicationhost/Sites/SiteDefaults/logfile -Name LogExtFileFlags -Value $IisLogFields
Write-Output "$(Get-Date -Format T) : IIS Configuration Updated on $env:ComputerName"
#EOF