NavigationUser login |
Using PowerShell to transfer file shares from a Windows 2000 to a Windows 2003 Microsoft cluster, Part 2After 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 $shares = import-csv $args[0] $server = $args[1] $drive = "Disk " + $args[2] + ":" $ocluster = new-object -comobject MSCLuster.Cluster $ocluster.open("") foreach ($share in $shares) { $group = $ocluster.resourcegroups.createitem($server) $resource = $group.Resources.CreateItem($share.name,"File Share",0) $dependencies = $resource.dependencies $properties = $resource.privateproperties $properties.item("ShareName")=$share.name $properties.item("Path")=$share.path $properties.item("Remark")=$share.description $properties.savechanges() cluster . res $share.name /priv security="everyone,set,c:security" cluster . res $share.name /priv security="everyone,grant,r:security" $dependencies.additem($group.resources.item($server)) $dependencies.additem($group.resources.Item($drive)) } 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. By mirko at 04.01.2007 - 12:34 | mirko's blog | login to post comments
|