Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I just import a IIS config with 50 sites.

I will delete all of these sites several times to make new tests.

Currently I just delete them one by one...

I have not found how to select all sites to remove them in one hit.

share|improve this question
1  
Is a scripted solution acceptable? If yes, which scripting language would you prefer to use? –  jscott Oct 26 '11 at 10:22

3 Answers 3

up vote 3 down vote accepted

You should be able to do:

cd %systemroot%\system32\inetsrv\

and then

appcmd list site /xml | appcmd delete site /in

To delete all of the sites, although I'm not sure. If it works it would be faster.

Learn more about piping appcmd here: http://blogs.iis.net/ksingla/archive/2007/06/17/things-you-can-do-by-piping-appcmd-commands.aspx

share|improve this answer
1  
Wow, this is really cool! –  michaelx386 Oct 26 '11 at 12:32
    
It works superbly, thanks! Do you know how to add a filter to delete everything except certain sites? –  GG. Oct 26 '11 at 13:01
    
Filter on their names. I look on your link. –  GG. Oct 26 '11 at 13:13
    
I found appcmd list site /name:"$=mySite*" to list sites starting with "mySite". Any idea to list sites not starting with"mySite" ? –  GG. Oct 26 '11 at 14:11

You can use the IIS appcmd command to remove a site automatically like this:

%systemroot%\system32\inetsrv\appcmd delete site "Website1"

You can repeat the command in a script to delete specific website names whenever you run the script. Create a file called DeleteSites.bat and paste the following code inside:

@echo off
cd %systemroot%\system32\inetsrv\

appcmd delete site "Website1"
appcmd delete site "Website2"
appcmd delete site "Website3"
appcmd delete site "Website4"
appcmd delete site "Website5"

Save the file, and then double-click it. That should delete the websites listed every time you run the script.

Here's a useful article on iis.net about using the appcmd to automate a lot of IIS tasks.

share|improve this answer
    
It's pretty easy, thanks. Is there a way to retrieve the list of sites? –  GG. Oct 26 '11 at 10:49
    
I think I'll delete this response. Chris's answer is much better. –  michaelx386 Oct 26 '11 at 12:43
    
No need to delete your answer, it works too. :) –  GG. Oct 26 '11 at 12:59

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.