Using PowerShell to transfer file shares from a Windows 2000 to a Windows 2003 Microsoft cluster, Part 1

Happy 2007. A (late) new year's resolution has led me to start this post. I'm currently assigned a task that involves retiring a file server cluster running MSCS on Windows 2000 to one running 2003, complete new hardware. That makes for a fairly straightforward and slightly boring job. We also move from Storage Central to File Server Resource manager. We also move from a L2 network to L3. To spice things up, why not learn Windows Powershell in the process?

What I used to do with a couple .cmd scripts in a tried and true way of course does not translate well into "the new way". One of the first tasks here would be to

Enumerate all shares for one virtual server on the old cluster

Piece of cake with PowerShell. Behold:

gwmi win32_share -computer oldvirtualserver | where {$_.name -notlike '*$' -and $_.path -like 'driveletterofoldvolume:*'}

That queries WMI on the legacy system and gets you all non-hidden shares (the only hidden shares of interest on our systems are home directories, which will be auto shared later by MSCS, so I can omit them here). To import them on the new system you might want to put them into a file, a la:

gwmi win32_share -computer oldvirtualserver | where {$_.name -notlike '*$' -and $_.path -like 'driveletterofoldvolume:*'} | select name, path, description | export-csv shares.csv

That's essentially the same data, only put into a .csv file for later importing.