Stopping and removing IIS

11 July 2015
Stopping IIS
If you temporarily don't use IIS, you can 'turn it off'.
Optionally, stop all web sites, ftp sites and application pools:
ls iis:\sites | stop-website -ErrorAction SilentlyContinue
ls iis:\sites | % {$_.ftpserver.stop()}
ls IIS:\AppPools | Stop-WebAppPool
Stop all related services. Please note that WMSVC and ftpsvc may not be installed on your machine.
Stop-Service WMSVC 
Stop-Service AppHostSvc
Stop-Service W3SVC
Stop-Service ftpsvc
Stop-Service WAS
Disable the services
Set-Service -Name AppHostSvc -StartupType disabled
Set-Service -Name w3svc -StartupType disabled
Set-Service -Name ftpsvc -StartupType disabled
Set-Service -Name WAS -StartupType disabled
Set-Service -Name WMSVC -StartupType disabled
You should see that nobody is listening to any web ports anymore:
netstat -an
To Enable IIS again:
Set-Service -Name AppHostSvc -StartupType Automatic
Set-Service -Name w3svc -StartupType Automatic
Set-Service -Name ftpsvc -StartupType Automatic
Set-Service -Name WAS -StartupType Automatic
Set-Service -Name WMSVC -StartupType Automatic

Start-Service WAS
Start-Service W3SVC
Start-Service ftpsvc
Start-Service AppHostSvc
Start-Service WMSVC

ls iis:\sites | start-website -ErrorAction SilentlyContinue
ls iis:\sites | % {$_.ftpserver.start()}
Removing IIS
Close IIS Manager if you have it running.
Uninstall any IIS Extensions, it's better to do that before uninstalling IIS.
$app = get-WmiObject -Class Win32_Product -namespace "root\cimv2" | Where-object{$_.Name -match "IIS URL Rewrite Module 2"}
$app.Uninstall()
We can remove most IIS components with the following command:
Uninstall-WindowsFeature -Name Web-Server -restart
Uninstall-WindowsFeature -Name Was
or on older Windows versions:
dism.exe -online -Disable-Feature -FeatureName:IIS-WebServer
dism.exe -online -Disable-Feature -FeatureName:WAS-WindowsActivationService
There are still some files in "C:\Windows\System32\inetsrv","C:\inetpub" and your content directories. Leave "inetsrv" alone, but you can delete the others.
Tags: IIS | IT Pro

Pages in this section

Categories

ASP.Net | Community | Development | IIS | IT Pro | Security | SQL (Server) | Tools | Web | Work on the road | Windows