As usual, the ideas for the posts start as a question from a colleague or a customer.
In this case, the customer had to distribute differently the folders in his FileServers’ volumes.
He had added an additional drive, copied all the relevant folders, and now needed to change the shares (non cluster resources) settings.
If there were only two or three, there is no problem doing it “manually”, but when you have more than 150 of them… it’s PowerShell time!
All the shares information and settings are stored in the registry, under the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Shares key (as described briefly in KB125996).
Each value represents a share, and the mutli-string value data contains the settings for it.
So by looping on each value, searching for the relevant folder in the value-data text (e.g. “Path=C:\myOldSharePath”) and replacing it with the new value, we could easily change them all in a script.
This led to the PowerShell function below:
Where we would use it:
– With the -WhatIf parameter for testing purposes:
– With the -Verbose parameter for details during the changes:
And don’t forget to restart the Server service (aka lanmanserver) after all the changes, for the new settings to take effect: