PowerShell script to migrate FTP virtual directories from Metabase.xml of IIS 6 to PowerShell commands for IIS 7.5

You have a thousands of FTP virtual directories in IIS 6. Now you would like to migrate these to IIS 7.5. There is a tool called Web Deploy which would help you migrate WebSites but unfortunately that doesn't migrate FTP Site and its virtual directories.

So we worked upon a PowerShell script which can help you help you migrate FTP websites and virtual directories with very basic settings. You can modify this script to do more while migrating like username and others..


In order to run the script you need Metabase.xml file from Windows 2003 box. You can find this file in %SystemRoot%\system32\inetsrv folder. Please open Metabase.xml file in notepad and remove <configuration> tab from the top and bottom of document. Once done, run below script :

 # Remove the following lines from the XML source file before running this 
# <configuration xmlns="urn:microsoft-catalog:XML_Metabase_V64_0"> 
# </configuration> 

# Developed under Powershell V2 on 2008 R2 
# invoke "importsystemmodules" to get the webAdministration libraries loaded 

 select-xml -path d:\temp\MetaBase.xml -xpath "//IIsFtpVirtualDir" | % { 
    $location= split-path $_.node.getattribute("Location") -leaf 
    $path = $_.node.getattribute("Path") 

        # Use this to test, this will give you stack of commands to execute which you can validate, add or modify and create another script file.
     "New-WebVirtualDirectory -site 'Default FTP Site' -name '$location' -physicalpath `"$path`" -Force"  # | out-file -append c:\temp\junk.txt.xml 

    # Use this to really create on IIS if you are sure (backup first)
    # "New-WebVirtualDirectory -site 'Default FTP Site' -name $location -physicalpath `"$path`"" 

This script can create commands which you can validate and run after, Or you can directly run. You need to uncomment the lines accordingly in above script. DISCLAIMER: THE MATERIALS ARE PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY OF ANY KIND.


  ~Devendra Asane