Question

I'm using IIS6

using powershell I would like to export a specific virtual directory to a file, change the name and some paths and then reimport the data, creating a new virtual directory

It looks like IISComputer.Export would do the job but try as I might I can't get it to work

Was it helpful?

Solution

This is the solution I found

From the link here MSDN DirectoryEntry.CopyTo I worked out that I would be able to copy the virtual directory then set the properties manually

From there I came up with the following powershell code which lets my clone a virtual directory then re point it

$vd = [ADSI]"IIS://localhost/W3SVC/1/Root/CurrentVd"

$parent = [ADSI]"IIS://localhost/W3SVC/1/Root"

$vd.CopyTo($parent,"NewVd")

Set Application Pool
$vd.AppPoolId = "MyNewAppPool"

Set Virtual Directory
$Vd.Path = "C:\MyNewTargetPath"

$parent.CommitChanges()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top