File share migration – Phase 1 – Discovery

Many organizations are struggling to meet the end of support deadline for Windows 2003 servers coming up on July 14, 2015. It’s staggering the number of Windows 2003 file servers still in production out there. This post is the first in a series that deals with file shares migration from Windows 2003 servers to 2012 R2.

As usual, I’m using Powershell to perform this task. This script contains Get-FileShares function and can be downloaded from the Microsoft Script Center Repository.

This function provides file share information from one or more Windows file servers. This is intended to run from a domain joined Windows 8.1 workstation against one or more file servers in the same domain. However, the source file servers can be Windows 2003 and up as long as Powershell 2.0 or up is installed, and Powershell remoting is configured. For more information on Powershell for Windows 2003 see this post. The function returns information including server name, share name, description, count of currently connected users, and amount of free space on the drive where the share is located. The function also obtains and saves the registry entries for file shares on the source server(s), and provides link(s) to file(s) location. Function output is displayed to screen and saved to log file.

Here’s an example output of running this script against one Windows 2003 file server:

After running the script to load its functions, I used the command:

$Shares = Get-FileShares -ComputerName NYFILSRV01P-SK3 -Passthru


The console output is also saved to a log file under .\logs subfolder similar to this one:


The output can also be viewed in PS ISE:

$Shares | Out-Gridview # shows information in tabular format in PS ISE


This can also be exported to CSV for viewing in Excel:

$Shares | Export-Csv .\NYFILSRV01P-SK3.csv -NoType


Note that CSV is not suited to handle complex data types. XML is more suitable for that. However, if you wish to list share permissions in CSV, we can use a small script like:

‘”ServerName”,”ShareName”,”Path”,”ShareUser”,”SharePerms”,”ShareAccess”‘ |
Out-File .\NYFILSRV01P-SK3b.csv -Encoding ascii
$Shares | % {
$ServerName = $_.ServerName
$ShareName = $_.ShareName
$Path = $_.Path
$SharePerms = $_.SharePerms
$ShareAccess = $_.ShareAccess
$i = 0
$_.ShareUser | % { “””$ServerName””,””$ShareName””,””$Path””,””$_””,””$(if ($SharePerms.Count -ge ($i+1)) {$SharePerms[$i]})””,””$(if ($ShareAccess.Count -ge ($i+1)) {$ShareAccess[$i]})””” | Out-File .\NYFILSRV01P-SK3b.csv -Append -Encoding ascii $i++ }

Migrate-Files-07and the output will look like:




5 responses

  1. Pingback: File share migration – Phase 2 – Robocopy | Sam's Corner

  2. Pingback: File share migration – Phase 3 – importing file share information | Sam's Corner

  3. Sophia

    I see too many commands here, lets make it simple. I am currently GS Richcopy 360 to do this task and it works like a charm. User friendly GUI, 100% multi threaded file transfer to get the maximum transfer speed. Give it a try, hope it helps!

    June 11, 2017 at 11:19 am

  4. Peter Barclay

    I’m missing something – running the script in a PS session (local), as admin, does not ‘load’ the function, therefore the next command where you create the variable “$Shares =” produces no output.

    I’m running it on Server 2012R2, Server 2016, with executionpolicy as “unrestricted”.

    Something I just cannot place. I know I’ve run these excellent scripts before but it escapes me.

    October 2, 2017 at 5:56 pm

  5. You can “dotsource” the script by running . .\Get-FileShares.ps1

    Then run get-fileshares

    October 25, 2017 at 7:06 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.