HOW TO: Use the Disk Summary Script Tool (Diskusage.pl) in Windows 2000 (318766)



The information in this article applies to:

  • Microsoft Windows 2000 Server
  • Microsoft Windows 2000 Advanced Server
  • Microsoft Windows 2000 Professional

This article was previously published under Q318766

SUMMARY

This step-by-step article describes how to use the Disk Summary Script tool (Diskusage.pl) to display information about folders and files on both local and remote Windows 2000-based computers.

The Disk Summary Script tool is available in Windows 2000 Resource Kit Supplement 1. You can use this script tool to display the following information about folders or files that reside on NTFS file system volumes of local or remote computers:
  • Size of files
  • Compression state of files or folders
  • Type of object (whether the object is a file or folder)
  • Number of files in a folder
  • Owner of the file or the folder
  • Location of the file or the folder
back to the top

System Requirements for Diskusage.pl

Diskusage.pl runs on a source computer and acts on a target computer (which can be either the same computer or a different computer than the source computer). The following sections describe the system requirements to use this script tool to display information about files or folders on local or remote computers.

back to the top

Source Computer

  • The computer is running either Windows 2000 Professional or Windows 2000 Server.
  • ActiveState ActivePerl Build 521 is installed. This program is available in Windows 2000 Resource Kit.

    You must also correctly configure the computer to run the Perl scripts that are included in Windows 2000 Resource Kit Supplement 1. The Resource Kit Windows Management Instrumentation (WMI) provider module (Wmi.pm) must be in the Perl Installation Folder\Site\Lib\W2rk folder. The Resource Kit Setup program typically creates the W2rk folder, and then copies the Wmi.pm file to this folder.

    If the W2rk folder is not automatically created during Setup, you can manually create this folder, and then configure the environment in which you want to run Diskusage.pl. For more information about how to manually configure this folder, see the "Troubleshooting" section later in this article.
  • You are logged on using a user account that is a member of the Administrators group of the target computer.
back to the top

Target Computer

  • The computer is running either Windows 2000 Professional or Windows 2000 Server.
  • The computer contains volumes that are formatted by using NTFS.
back to the top

Overview of Diskusage.pl

Diskusage.pl uses the following syntax:

diskusage.pl Folder| File [ Folder| File...] [ -s Computer [ -u Domain\User -p Password]][ -recurse][ -format table| list | csv] [ -v][ -unittype B| KB | MB][ -filter "FieldOperatorValue" [ -filter "FieldOperatorValue"...]]

The following list describes the parameters that you can use with Diskusage.pl:
  • folder | file [ folder | file...]: Use this parameter to specify the folders or files whose information you want to display by using the following format: drive:\folder\filename.

    When you specify files, Diskusage.pl displays information about those files. When you specify a folder, Diskusage.pl displays information about the files in that folder.

    You can use the wildcard character (*) in any position in the path. If you want to specify two or more folders or files, separate each item with a space. If the folder or file name contains a space, enclose the folder or file name and path with quotation marks ("").

    If the file or the folder is on a volume that is not mapped to the local computer, use the relative path (the path as seen from the remote computer).
  • -s computer: Use this parameter to specify the name or Internet Protocol (IP) address of a remote computer. If you omit this parameter, the local computer is specified.
    • -u domain\user: Use this parameter to specify the user account with which you want to run Diskusage.pl. If you omit this parameter, Diskusage.pl uses the permissions of the currently logged-on user. If you use this parameter, you must also use the -p parameter to provide the user's password.
    • -p password: Use this parameter to specify the password of the user account that is specified by the -u parameter. The -p parameter is required when you use the -u parameter.
    Both the -p parameter and the -u parameter are available only if you use the -s parameter.

    NOTE: If the remote volume is mapped to a drive on the local computer, you can specify the mapped drive letter in the file path, for example, Z:\Winnt\Explorer.exe. You do not need to use the -s parameter to indicate another computer.

  • -recurse: Use this parameter to add child objects of the specified folder to the output. If you omit this parameter, only files in the specified folders are included in the output.
  • -format table|list| csv: Use this parameter to specify the output format. If you omit this parameter, Diskusage.pl uses the table format by default.
  • -v: Use this parameter to add the "Owner" entry to the output.
  • -unittype B|KB| MB: Use this parameter to specify the unit of disk space that is used to display the file size. If you omit this parameter, Diskusage.pl uses kilobytes (KB) by default.
  • -filter "FieldOperatorValue" [-filter "FieldOperatorValue"...]: Use this parameter to specify the criteria for folders and files that are included in the output. If you omit this parameter, all of the items that are specified in the Folder | File parameter are included in the output.

    To establish more than one criteria, use a separate instance of -filter "FieldOperatorValue" for each criteria that you want to specify and separate each instance with a space. Diskusage.pl displays only those items that meet all of the criteria.

    The following table lists the operators and values that are available for each field that is used with the -filter parameter and an example of each "FieldOperatorValue":
FieldOperatorValueExample
SizeAll logical operatorsNumberUnit"size>=3MB"
Compressed=Yes | No"compressed=yes"
Type= !File | Directory"type=file"
TotalfilesAll logical operatorsWhole number that represents the number of files in the folder. This value is not recursive."totalfiles>8"
Owner= !User or user group"owner=Administrators"
Filepath= !string value (no wildcards)"filepath!c:\temp"


back to the top

Examples

  • To display information about the Report1.doc file in the E:\Company Info\Reports folder of the local computer, type the following line at the command prompt, and then press ENTER:

    diskusage.pl "e:\company info\reports\report1.doc" -v

  • To display information about all files and subfolders in the C:\Winnt folder of the local computer, display the output in list format, and redirect the output to a file named "Winnt_info.txt" on drive E, type the following line at the command prompt, and then press ENTER:

    diskusage.pl c:\winnt\*.* -format list > e:\winnt_info.txt -v

  • To run Diskusage.pl by using the Administrator account to display information about the C:\Program Files and E:\Documents folders of a remote computer named "Server5," type the following line at the command prompt, and then press ENTER:

    diskusage.pl "c:\program files" e:\documents -s server5 -u server5\administrator -p password

  • To search for all uncompressed folders on volume M and on all child objects of volume M, type the following line at the command prompt, and then press ENTER:

    NOTE: In this example, drive M on the local computer is mapped to the drive C of a remote computer.

    diskusage.pl m: -recurse -filter "compressed=no" -filter "type=directory"

back to the top

Troubleshooting

If you run Diskusage.pl, you receive the following error message:
ERROR: Wmi.pm is required to run the script.
Copy Wmi.pm from the Resource Kit directory to /Perl/site/lib/W2RK.
This behavior can occur if you did not configure the computer to run the Perl scripts that are included in Windows 2000 Resource Kit Supplement 1. To use Diskusage.pl, the W2rk folder must exist in the Perl Installation Folder\site\lib folder and it must contain the Wmi.pm file.

To resolve this behavior, manually configure the environment in which you want to run Perl scripts:
  1. Create a folder named "W2rk" in the Perl Installation Folder\Site\Lib folder.

    NOTE: The default Perl Installation Folder is drive:\Perl, where drive is the disk drive on which Windows is installed.
  2. Copy the Wmi.pm file from the folder in which Windows 2000 Resource Kit is installed (by default, this folder is Program Files\Resource Kit) to the W2rk folder that you created in step 1.
back to the top

REFERENCES

For more information about Windows 2000 Resource Kit and Windows 2000 Resource Kit Supplement 1, visit the following Microsoft Web site: back to the top

Modification Type:MajorLast Reviewed:9/27/2006
Keywords:kbhowto kbHOWTOmaster KB318766