# Kod formatuje wolumin.
# Klasa Win32_Volume jest nowoci w systemie Windows Server 2003.

use Win32::OLE qw(in);
$Win32::OLE::Warn = 3;

# ------ KONFIGURACJA SKRYPTU ------
$strComputer = '<Serwer>';
$strDrive = '<Napd>';
# np. D:

$strFS = 'NTFS';
$boolQuick = 0;
$intClusterSize = 4096;
$strLabel = 'Dane';
$boolCompress = 0;
# ------ KONIEC KONFIGURACJI ---------
$objWMI = Win32::OLE->GetObject('winmgmts:\\\\' . $strComputer . '\\root\\cimv2');
$colVol = $objWMI->ExecQuery('select * from Win32_Volume where Name = \'' . $strDrive . '\\\\\'');
if ($colVol->Count != 1) {
    print "Bd: wolumin nie zosta znaleziony.\n";
}
else {
    foreach my $objVol (in $colVol) {
        $intRC = $objVol->Format($strFS, $boolQuick, $intClusterSize, $strLabel, $boolCompress);
        if ($intRC != 0) {
            print 'Podczas formatowania woluminu wystpi bd: ' . $intRC, "\n";
        }
        else {
            print "Formatowanie woluminu zostao zakoczone powodzeniem.\n";
        }
    }
}
