4

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

4

1 回答 1

1

这是我找到的解决方案

从这里的链接MSDN DirectoryEntry.CopyTo我发现我可以复制虚拟目录然后手动设置属性

从那里我想出了以下powershell代码,它可以让我克隆一个虚拟目录,然后重新指向它

$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()
于 2012-06-15T09:44:05.513 回答