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.
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.
Yes, you can safely delete the Default Web Site in IIS Manager, even though delete the files under the wwwroot .
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.
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)
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With