Converting MS VBS scripts to Perl scripts


Example 1:  Converting "List Video Adapter Configuration"

VB Script code:
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_DisplayControllerConfiguration")

For Each objItem in colItems
Wscript.Echo "Bits Per Pixel: " & objItem.BitsPerPixel
Wscript.Echo "Color Planes: " & objItem.ColorPlanes
Wscript.Echo "Device Entries in a Color Table: " & objItem.DeviceEntriesInAColorTable
Wscript.Echo "Device Specific Pens: " & objItem.DeviceSpecificPens
Wscript.Echo "Horizontal Resolution: " & objItem.HorizontalResolution
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "Refresh Rate: " & objItem.RefreshRate
Wscript.Echo "Setting ID: " & objItem.SettingID
Wscript.Echo "Vertical Resolution: " & objItem.VerticalResolution
Wscript.Echo "Video Mode: " & objItem.VideoMode


Perl Code:

use Win32::OLE;

my $strComp='.';    # Change this dot to the computer name of your victim, or leave it as is to scan your own computer
my $objwmi=Win32::OLE->GetObject("winmgmts:\\\\". $strComp . "\\root\\cimv2");
my $colitems=$objwmi->ExecQuery("Select * from Win32_DisplayControllerConfiguration");
my $item;

foreach $item (in $colitems)
print "Bits Per Pixel: ".$item->BitsPerPixel ."\n";
print "Color Planes: ".$item->ColorPlanes ."\n";
print "Device Entries in a Color Table: ".$item->DeviceEntriesInAColorTable ."\n";
print "Device Specific Pens: ".$item->DeviceSpecificPens ."\n";
print "Horizontal Resolution: ".$item->HorizontalResolution ."\n";
print "Name: ".$item->Name ."\n";
print "Refresh Rate: ".$item->RefreshRate ."\n";
print "Setting ID ".$item->SettingID ."\n";
print "Vertical Resolution: ".$item->VerticalResolution ."\n";
print "Video Mode: ".$item->VideoMode ."\n\n";