Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove multiple website from IIS 7.5

I have a web server for shared webhosting purpose based on windows server 2008 R2 and IIS 7.5. There are currently 450 websites in it IIS server. I want to remove all of the website from the server because this server has been gone out of production. Is there any script in powershel to automate the deletion of 450 websites or I have to remove them one by one manually.

like image 237
Pourya.M Avatar asked Jan 06 '14 14:01

Pourya.M


People also ask

How do I delete a website from IIS?

Click Start > Control Panel > Administrative Tools > Internet Information Services. In the Connections pane, expand the machine's name, then expand Sites, then Default Web Site (or your web site, if renamed). Right-click acuxbis and select Remove from the popup menu.

Can I delete the default website in IIS?

Yes, you can safely delete the Default Web Site in IIS Manager, even though delete the files under the wwwroot .


3 Answers

The Web Server (IIS) Administration Cmdlets in Windows PowerShell will help you here.

The following will remove all websites:

Import-Module WebAdministration
Get-Website | Remove-Website

This won't remove any files so that should be done separately.

like image 82
David Martin Avatar answered Sep 19 '22 15:09

David Martin


Big Thanks to David Martin, but here is what I needed to do in order for it to install and work.

# Get WebAdminstration module
Add-PSSnapin WebAdministration -ErrorAction SilentlyContinue 
# Import module in order to run it
Import-Module WebAdministration
# Remove All Websites from IIS
Remove-Website -Name *

I hope this helps others.

Works with IIS 8.5 (Windows Server 2012 R2)

like image 21
Tom Stickel Avatar answered Sep 18 '22 15:09

Tom Stickel


When installed on IIS 7.0 or later Web Deploy adds a context menu item to IIS manager called Deploy.

There are multiple actions available here one of which is the Delete action. There are two options depending on what node you have selected in IIS manager:

Web site :   Deploy >> Delete Web Site and Content
Application: Deploy >> Delete Application and Content

For more details...please check below link

http://blogs.iis.net/richma/archive/2010/07/03/deleting-iis-web-sites-applications-and-their-content-with-web-deploy.aspx

like image 22
Tatarao Vana Avatar answered Sep 20 '22 15:09

Tatarao Vana