Udostępnij za pośrednictwem


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 

#importsystemmodules 
 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

 

createFTP.ren2ps1.txt

Comments

  • Anonymous
    October 21, 2013
    In that I'm not a PowerShell guru, can you please expand on the script that you've provided?Thank you in advance.
  • Anonymous
    October 30, 2013
    Hi Devendra,                 How do I migrate FTP virtual directories Under FTP Virual directories to IIS7.5?(FTP Site/Vir Dir/Vir Dir)Thanks
  • Anonymous
    December 18, 2013
    What happened to the script?  I have tried using the script but the virtual directories do not get created.
  • Anonymous
    December 19, 2013
    The comment has been removed
  • Anonymous
    January 19, 2015
    Davendra,Thanks for this but I cannot find the script here, Is there suppose to be a script in createFTP.ren2ps1.txt  ?
  • Anonymous
    February 29, 2016
    The comment has been removed