You say it's migration time and you're rolling out Windows 2000? Then you've got a lot of work to do: Design the DNS and Active Directory (AD) structures, migrate user accounts, upgrade some servers, and scrap and replace some others. If some of those new servers are file servers, you face an old problem: copying a bunch of files and folders from a share on one machine to a share on another machine while minimizing the amount of work you need to do to recreate the file, directory, and share permissions on those file shares. Permcopy and share.vbs are two tools that can help you get started.
Permcopy.exe duplicates the share permissions that it finds on one share on another share. The syntax is
permcopy \\sourceserver sourceshare \\targetserver targetshare
This command duplicates the \\sourceserver\sourceshare share-level permissions on \\targetserver\targetshare.
Permcopy has four arguments: the names of the source server, source share, target server, and target share. The command's syntax is a bit nonintuitive. Rather than using Uniform Naming Convention (UNC) names for the shares, you separate each argument by at least one space from the rest of the command string. For example, to duplicate the permissions on the Mystuff share, which is on a server named Homebase, to the Yourstuff share on a server named Foreign, I wouldn't enter
permcopy \\homebase\mystuff \\foreign\yourstuff
Instead, I'd type
permcopy \\homebase mystuff \\foreign yourstuff
You need to know a few things about Permcopy. First, despite what the Microsoft Windows 2000 Resource Kit documentation says, Permcopy doesn't make the file permissions on the target directory match the file permissions on the source directory; the utility duplicates only the share permissions. Second, Permcopy doesn't copy the files from one share to the other, nor does it create shares in the target directory.
You might think, "All right, then; how will I create that new share?" You could use the GUI to create the share, of course, but let's assume that you want to perform the task on the command line and keep it as scriptable as possible. Share.vbs can list, create, and delete shares on a remote system. (Share.vbs can't set share permissions on a share; you use Permcopy to set the permissions.)
Simplified, the share.vbs syntax is
cscript share.vbs /c /n <sharename> /s <servername> /p <path> /t disk
For example, to create a share named Yourstuff on a server named Foreign, where Yourstuff lives in the directory C:\shares\yourstuff, you'd type
cscript share.vbs /c /n yourstuff /s foreign /p c:\shares\yourstuff /t disk
As with other resource kit scripts, you can add the /u option to specify a user name and the /w option to add a password. The /v option lets you add a comment to the share. To extend this example, suppose I had an administrative account called Czar on the Foreign server and a password of ivan. To add the user account information and a comment to the command in the above example, I could type
cscript share.vbs /c /n yourstuff /s foreign /p c:\shares\yourstuff /t disk /v "My first share.vbs-created share" /u czar /w ivan
Are you wondering how to remotely create directory C:\shares\yourstuff in the first place? I'll explain that in an upcoming column.