Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove multiple virtual directories?

Tags:

iis

web

I need to remove a big amount of virtual directories, some of them don't have associated physical directories.
Ideas?

like image 369
user626528 Avatar asked Mar 15 '12 08:03

user626528


People also ask

How do I find virtual folders?

In the Actions pane, click View Virtual Directories, and then click Add Virtual Directory... In the Add Virtual Directory dialog box, at a minimum enter information in the Alias: and Physical path: text boxes, and then click OK.

What are virtual directories used for?

A virtual directory serves as an intermediary that gathers and aggregates identity data from a variety of different sources such as LDAP directories, databases, applications, and web services.


2 Answers

You could also write an msbuild script to do this and use the msbuild extension pack which is available here. I have used this successfully to do exactly what you are saying for 100s of vdirs in iis 6 AND in iis 7.5.

Its pretty simple and took me longer to write the .proj file than it did to figure out how to do it.

have fun :)

the resultant msbuild target would look like as follows

  <Target Name="IIS7VirtualDirectories:Delete">
    <MSBuild.ExtensionPack.Web.Iis7Application
      TaskAction="Delete"
      Website="%(Application.WebsiteName)"
      Applications="@(Application)"
      MachineName="$(MachineName)"
      ContinueOnError="false"/>

     <MSBuild.ExtensionPack.Web.Iis7Website 
      TaskAction="DeleteVirtualDirectory" 
      Name="%(VirtualDirectory.WebsiteName)" 
      VirtualDirectories="@(VirtualDirectory)"
      ContinueOnError="false"
      MachineName="$(MachineName)"/>    
    </Target>

Where Application and VirtualDirectory are defined in an external proj file :)

like image 25
krystan honour Avatar answered Nov 15 '22 12:11

krystan honour


As you need to remove a large amount, I'm guessing you'll want to use some form of script.

IIS 6.0, using IISvdir.vbs( article @ MSDN):

At the command prompt, use the cd command to change to the directory where the Iisvdir.vbs script is installed. The default location for this file is systemroot/system32/iisvdir.vbs.

At the command prompt, type:

cscript iisvdir.vbs /delete "Sample Web Site" VirtualDirectoryName.

Substitute your Web site name and virtual directory name as appropriate. If there are spaces in the Web site name, use quotation marks around the Web site name, as shown in the preceding example.

IIS 7 using AppCmd.exe (article @ TechNet):

To remove a virtual directory, use the following syntax:

appcmd delete vdir /vdir.name: string

The variable vdir.namestring is the virtual path of the virtual directory.

For example, to remove a virtual directory named photos from the root application of a site named contoso, type the following at the command prompt, and then press ENTER:

appcmd delete vdir /vdir.name: contoso / photos

To remove a virtual directory named photos from an application named marketing in a site named contoso, type the following at the command prompt, and then press ENTER:

appcmd delete vdir /vdir.name: contoso / marketing / photos

HTH

like image 84
ianbailey Avatar answered Nov 15 '22 12:11

ianbailey