I’m always sick and tired of having to remove the IIS Default Web Site and DefaultAppPool after I’ve installed the Web Roles in Windows Server 2012 R2. So, I created a short script that will remove them.
# Check for Admin Access (UAC)
$User = [Security.Principal.WindowsIdentity]::GetCurrent()
$Role = ( New-Object Security.Principal.WindowsPrincipal $user ).IsInRole( [Security.Principal.WindowsBuiltinRole]::Administrator )
if ( -not $Role )
{
Write-Warning "To perform some operations you must run an elevated Windows PowerShell console."
}
else
{
Get-WebSite -Name "Default Web Site" | Remove-WebSite -Confirm:$false -Verbose
Remove-WebAppPool -Name "DefaultAppPool" -Confirm:$false -Verbose
}
DISCLAIMER: These materials are provided “AS IS” without any express or implied warranty of any kind.
Is there any script for removing just the default home page (not whole default website)?
I’m sure it’s possible, but it’s not what I needed to do for my scenario.