Authenticate and enumerate the disks on a system (Perl)
This code can be found in
Chapter 1 of Windows Server Cookbook
Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.
Find out how to download all of the Perl code from this site.
# Adapted from VBScript code contained in the book:
# "Windows Server Cookbook" by Robbie Allen
# ISBN: 0-596-00633-0
use Win32::OLE qw(in);
$Win32::OLE::Warn = 3;
$objLocator = Win32::OLE->new('WbemScripting.SWbemLocator');
$objWMI = $objLocator->ConnectServer('srv01', 'root\\cimv2', 'srv01\\administrator', 'net');
$objDisks = $objWMI->InstancesOf('Win32_LogicalDisk');
foreach my $objDisk (in $objDisks) {
print 'DeviceID: ' . $objDisk->DeviceID, "\n";
print 'FileSystem: ' . $objDisk->FileSystem, "\n";
print 'FreeSpace: ' . $objDisk->FreeSpace, "\n";
print 'Size: ' . $objDisk->Size, "\n";
print "\n";
}
|
This code has been viewed 901 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|