-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdd-WindowsFeature-Web-Server.ps1
More file actions
26 lines (22 loc) · 1.89 KB
/
Copy pathAdd-WindowsFeature-Web-Server.ps1
File metadata and controls
26 lines (22 loc) · 1.89 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
##Install IIS
Add-WindowsFeature Web-Server
##Loading powershell modules
Import-Module -Name WebAdministration
##Begin basic site configuration
Remove-IISSite -Name "Default Web Site" -Confirm:$false
New-IISSite -Name "LabSite" -BindingInformation "*:80:" -PhysicalPath "$env:systemdrive\inetpub\wwwroot"
Set-Content -Path "$env:systemdrive\inetpub\wwwroot\Default.htm" -Value "Hello World from host $($env:computername) !"
##Configure Logging
$logdir = '%SystemDrive%\inetpub\logs\LogFiles'
Set-ItemProperty `
-Path 'IIS:\Sites\LabSite' `
-Name Logfile.enabled `
-Value $true
Invoke-Expression "& '$env:WINDIR\system32\inetsrv\appcmd.exe' unlock config -section:system.applicationHost/log"
Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.applicationHost/sites/site[@name='LabSite']/logFile/customFields" -name "." -value @{logFieldName='Content-Length';sourceName='Content-Length';sourceType='RequestHeader'}
Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.applicationHost/sites/site[@name='LabSite']/logFile/customFields" -name "." -value @{logFieldName='Host';sourceName='Host';sourceType='RequestHeader'}
Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.applicationHost/sites/site[@name='LabSite']/logFile/customFields" -name "." -value @{logFieldName='User-Agent';sourceName='UserAgent';sourceType='RequestHeader'}
Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.applicationHost/sites/site[@name='LabSite']/logFile/customFields" -name "." -value @{logFieldName='X-Forwarded-For';sourceName='X-Forwarded-For';sourceType='RequestHeader'}
Set-WebConfigurationProperty "/system.applicationHost/sites/siteDefaults" -name logfile.directory -value $logdir
##Lock IIS COnfig down.
Invoke-Expression "& '$env:WINDIR\system32\inetsrv\appcmd.exe' lock config -section:system.applicationHost/log"