how can I export the contents of a virtual directory change some paths and then reimport

StackOverflow https://stackoverflow.com/questions/10932634

  •  13-06-2021
  •  | 
  •  

質問

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

役に立ちましたか?

解決

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()
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top