Sometimes it's inconvenient to use the Windows GUI to map a drive—this is a problem particularly in logon scripts. How do you use a batch file to tell the mouse pointer to move over to My Network Places? There's a better way. The net use command enables you to map any drive to any server on your network, and in some cases, outside networks, too. The syntax is:
net use drive servershare
net use H: mercuryuserslmjohnson
net use * mercuryuserslmjohnson
net use H: foreignmachinesharename /user:foreigndomainusername
net use mercuryuserslmjohnson /d
net use * /d
net use H: 18.104.22.168c$
net use H: 22.214.171.124c$ /user:hasselltechhassell
And you can specify that this mapping is for the current session only and should not be restored upon logon. This is a feature that I call map persistency—keeping the same mappings across login sessions, a big timesaver for your users. To do so:
net use H: 126.96.36.199c$ /persistent:no
fsutil quota modify [VolumeOrDrive] [warninglevel] [hardquota] [username]
replacing the text in brackets with the appropriate information as specified in the following list:
VolumeOrDrive The drive letter or volume name of the disk on which you want to modify a quota. Volume names are tricky to specify because you must do so using the globally unique identifier (GUID), which can be a long string of seemingly random numbers.
warninglevel The amount of space at which warnings will be recorded in the system event log.
hardquota The amount of space at which users will reach their maximum allowed disk space.
username The user to which this quota specification applies. Using fsutil.exe, you can create scripts to automatically set quota entries upon new-user creation to work around the limitation of assigning quotas to groups, as described earlier in this chapter. fsutil.exe can help you access functionality more quickly and efficiently than you can by using the GUI interface. The following examples, designed to run from a command line, illustrate the quota functionality available through fsutil.exe. To disable quota support on drive C:
fsutil quota disable C:
fsutil quota enforce E:
fsutil quota modify C: 250000000 lmjohnson
To list the current quotas set on drive D:
fsutil quota query D:
fsutil quota track F:
fsutil quota violations
Managing Offline Folders
net share nameofshare /CACHE:[manual | documents | programs | none]
/CACHE:manual enables manual client caching of programs and documents from this share. /CACHE: documents enables automatic caching of documents from this share. /CACHE:programs enables automatic caching of documents and programs (distinguished by their file extension) from this share. /CACHE:none disables caching from this share.
The GUI for managing shadow copies is somewhat complete; however, it lacks the ability to specify on which disk or volume shadow copies are stored. Also, an administrator cannot delete specific shadow copy files using the GUI. This might be needed if a user creates an incorrect version of a file, then leaves and another worker comes back the next day. An administrator might need to delete the previous version as soon as possible so that the new user doesn't inadvertently work from the incorrect version. The vssadmin.exe command-line utility was created to offer administrators the ability to control these factors. I'll now walk through several examples.
vssadmin Add ShadowStorage /For=C: /On=D: /MaxSize=150MB
This command specifies that storage for shadow copies (known as an association) of drive C: will be stored on drive D:. If a value is not specified, there is no limit to the amount of space shadow copies can use. Shadow copies require at least 100 MB of space, and you can specify the maximum amount in KB, MB, GB, TB, PB, and EB, although it's assumed if you don't use a suffix, the value is in bytes.
vssadmin Create Shadow /For=E: /AutoRetry=2
This command creates a new shadow copy of drive E:. The /AutoRetry switch dictates that if another process is attempting to make shadow copies at the same time vssadmin is attempting to make them, the utility will keep trying for two minutes.
vssadmin Delete Shadows /For=C: /Oldest
This command deletes the oldest shadow copy on drive C:. You can use the /all switch to instead delete all shadow copies that can be deleted. You also can specify a specific shadow copy to delete by using /Shadow=ID, where ID is the hexadecimal number you obtain through the List Shadows command, covered later in this section.
vssadmin Delete ShadowStorage /For=C: /On=D:
vssadmin Resize ShadowStorage /For=C: /On=D: /MaxSize=150MB
This command modifies the maximum size for a shadow copy storage association between drives C: and D:. Again, the maximum size has to be 100 MB or more. If you decrease the maximum size, older shadow copies can be deleted to make room for more recent shadow copies. Other useful commands:
vssadmin List Providers This command lists registered volume shadow copy providers.
vssadmin List Shadows This command lists existing volume shadow copies and their ID numbers, for use with the Delete Shadows command.
vssadmin List ShadowStorage This command shows the disks eligible to support shadow copy functionality.