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

After exporting all file share data from the old system, it's time to recreate those shares on the new system.

Powershell to the rescue!

The following script requires you to set up a cluster group, containing a disk (named "Disk :")and a network name resource (named like the group). Invoke it calling it with the .csv created in Part 1 as the first, the resource group's name as the second and the driveletter of the new volume as the third parameter.

$shares = import-csv $args[0]
$server = $args[1]
$drive  = "Disk " + $args[2] + ":"

$ocluster = new-object -comobject MSCLuster.Cluster

foreach ($share in $shares) {
	$group = $ocluster.resourcegroups.createitem($server)
	$resource = $group.Resources.CreateItem($,"File Share",0)
	$dependencies = $resource.dependencies
	$properties = $resource.privateproperties
	cluster . res $ /priv security="everyone,set,c:security"
	cluster . res $ /priv security="everyone,grant,r:security"	

As you can see, I used the Cluster Automation COM interface to configure the new cluster resources. There seems to be a bug, as properties.savechanges() throws an exception while still doing what it is supposed to do.

Also, I was unable to look up the correct way of setting the file share permissions via COM, so I used cluster.exe instead.