Posts tagged “Windows 2003 Migration

File share migration – Phase 4 – Dealing with files that failed to copy

3/17/2015 update:

I updated the Powershell script to report on files and folders copied and the duration it took, and export that information to CSV files.

Running the same command:

Get-FailedFiles (Get-ChildItem -Path .\logs | where { $_.Name.StartsWith('Robo') }).FullName

The script now produces output to the console like:


and saves two CSV files to the current folder. One contains the file/folder copy summary statistics displayed on the console, and the other contains the list of files that failed to copy and the error code

Following Phase 3 of file share migration, phase 4 will deal with the files that failed to copy. Most commonly this is because the files were open at the time Robocopy attempted to copy them and it could not get the necessary file lock. Step 1 of dealing with the files that failed to copy is to identify them. This Powershell script goes through one or more Robocopy log files and parses out the files that failed to copy. The script can be downloaded from the Microsoft script center repository.

Get-FailedFiles -RoboLog .\logs\Robo-Migrate-FileShares_NYFILSRV01P-2015-03-11_05-27-26AM.txt

The script returns a list of files that failed to copy and the corresponding error codes:

Migrate-Files-14This also can be run against a group of files as in:

$FailedFiles = Get-FailedFiles (Get-ChildItem -Path .\logs | where { $_.Name.StartsWith(‘Robo’) }).FullName

This command will parse all the files under .\logs subfolder that start with ‘Robo’ and return the files that failed to copy and their error codes. This can be presented:
$FailedFiles | FT -Auto # in tabular format

Migrate-Files-15$FailedFiles | Out-Gridview # in Powershell ISE Gridview


$FailedFiles | Export-Csv .\FailedFiles.CSV -NoType # or exported to CSV



Script to get website(s) information from IIS 6 on Windows 2003 servers

With Windows Server 2003 end of life coming up in July 14, 2015, many organizations are busy trying to migrate from Server 2003 to Server 2012 R2. This Powershell script/tool will get web site information for one or more web sites from a Windows 2003 Server running IIS 6.

This script is intended to be run from a Windows 8.1 or Server 2012 R2 machine. It has been tested on Server 2012 R2 (Powershell 4).  However, the scriptblocks that interact with Server 2003 have been tested on Powershell 2. The script will powershell-remote into the Windows 2003 server to retrieve the website(s) information. For more information on Powershell remoting to Server 2003 from Windows 8.1/Server 2012 R2 see this post.

To use this script, download it from the Microsoft Script Center Repository, unblock the file, and run it like:

.\Get-WebSite.ps1 -WebSite -ComputerName MyW2k3Server -AdminName administrator

The script saves the encrypted admin password for future use. If the file does not exist, the user is prompted for the password:


The script output is a PS Object containing:

  • WebSiteName: for example or
  • Bindings: each binding will have hostname, IP, and Port properties
    • if the host header name is bound to * All Unassigned *, the returned IP will be blank
  • Path: local path on web server where the web site resides
    • if the web site is redirected in IIS, this field will contain redirection URL
  • FileCount: number of files in the web site
  • FolderSize: total file size of the web site
  • vFolders: each VirtualFolder will have Path, vFolder, FileCount, FolderSize
    • This will be blank for redirected websites
  • AutoStart: True or False value to indicate whether or not the website is set to auto-start
  • ID: internal ID number used by IIS
  • LogFolder: local path to IIS logs for this web site
  • Server: name of the web server where this web site resides
  • SSL: secure binding (if any). It has IP and Port properties


The output object of this script contains Bindings, SSL, and vFolders properties which are objects having their own properties. The output will not export properly to CSV but can be saved to and retrieved from XML using the Import-Clixml and Export-Clixml cmdlets.

-XML and -CSV are optional parameters of XML and CSV file names. When used, the script will save website raw information in theses filesGet-WebSite003


.\Get-WebSite.ps1 -WebSite, -ComputerName MyW2k3Server -AdminName administrator -Verbose

Get-WebSite004This example returns information about the websites ‘’ and ‘’ on the server ‘MyW2k3Server’. The -Verbose parameter displays progress information.


$MyWebSites = .\Get-WebSite.ps1, MyW2k3Server administrator -Verbose
$MyWebSites | Out-GridView

This example displays the websites’ information in Powershell_ISE Grid View

    select WebSiteName,ID,Server,FileCount,@{N='Size(MB)';
        E={[Math]::Round($_.FolderSize/1MB,0)}} |
            FT -Auto

This example displays the websites’ information on the console screen

$MyWebSites| % {
    $_ | select WebSiteName,ID,Server,FileCount,@{N='Size(MB)';
        E={[Math]::Round($_.FolderSize/1MB,0)}} | FT -Auto 
    $_.Bindings | FT -Auto 
    $_.vFolders | FT -Auto 

This example displays the websites’ information on the console screen, including Bindings and vFolders


$MyWebSites = .\Get-WebSite.ps1 (Get-Content .\mywebsites.txt) MyW2k3Server administrator -Verbose
$MyWebSites | Out-GridView

This example retieves information about each of the websites listed in the .\mywebsites.txt file and displays it to Powershell_ISE Grid View


If the -WebSite parameter is not provided the script will retrieve web sites’ information about all websites on the provided server.

.\Get-WebSite.ps1 -ComputerName MyW2k3Server -AdminName administrator -Verbose

This example will retrieve information on all web sites on server ‘MyW2k3Server’

Powershell remoting to Windows 2003 from Server 2012 R2 or Windows 8.1

With Windows Server 2003 end of life coming up in July 14, 2015, many organizations are busy trying to migrate from Server 2003 to Server 2012 R2. Some try to do in-place migration to Server 2008 R2 then another in-place migration to server 2012 R2. I don’t think this is good idea. It inherits all the issues from the old 2003 system, and I’m sure there are many. This post goes over Powershell remoting into Windows 2003 servers which is first step in many automation/migration processes.

Install Powershell 2 on Server 2003

Download and install PS2 for Server 2003 x86 or x64 version. This is part of Windows Management Framework (Windows PowerShell 2.0, WinRM 2.0, and BITS 4.0)

Create shortcut to PS2 on Server 2003



Make sure WinRM and WinMgmt services are running

In the GUI Computer Management under Services and applications/services or using Powershell:

Get-Service -Name Win*


Make sure the following 2 services are running and startup is set to ‘automatic’

  • WinMgmt (Windows Management Instrumentation)
  • WinRM (Windows Remote Management)

Enable Powershell Remoting on Server 2003

In Powershell run

Enable-PSRemoting -Force -Verbose


That’s it on the Server 2003 side.

Test connectivity

On a Server 2012 R2 or Windows 8.1 workstation with RSAT installed, which is typically running Powershell 4, add the Server 2003 computer to the trusted hosts list if need be. This is often needed if the managing machine and the managed server are not in the same domain:

winrm s winrm/config/client "@{TrustedHosts=""My2003Server""}"

W2k3-004Finally, use a cmdlet like Enter-PSSession to test connectivity:

Enter-PSSession -ComputerName


You can now execute commands on the remote Windows 2003 computer from your Server 2012 R2 or Windows 8.1 management station.

For more information see Secrets of Powershell Remoting ebook by Dave Jones, Tobias Weltner, Dave Wyatt, and Aleksandar Nikolic