I humbly beg the wise monks for advice on converting a simple VBS script to perl. In particular, I'm unable to translate the second line here:

set objWMILocator = CreateObject("WbemScripting.SWbemLocator") objWMILocator.Security_.AuthenticationLevel = 6

The full working VBS script is

Option Explicit On Error Resume Next Dim strServ, strUsrN, strPasswd strServ = "10.x.x.x" strUsrN = "Administrator" strPasswd = "******" Const WMIPATH = "root\Citrix\WanScaler" Dim objWMILocator set objWMILocator = CreateObject("WbemScripting.SWbemLocator") If Err.Number then Wscript.Echo( "CreateObject: error 0x" & CStr(Hex(Err.Number)) ) WScript.Quit(1) end if objWMILocator.Security_.AuthenticationLevel = 6 Dim objService Set objService = objWMILocator.ConnectServer(strServ, WMIPATH, strUsrN +, strPasswd) If Err.number Then Wscript.Echo( "Connect Error 0x" & CStr(Err.Number)) WScript.Quit(1) End If Dim colSettings, strQuery strQuery = "Select * from Citrix_WS_SystemConfig" Set colSettings = objService.ExecQuery(strQuery) Dim objClassProperty, objInstance, colProperties, strOutPut For Each objInstance in colSettings Set colProperties = objInstance.Properties_ For Each objClassProperty In colProperties strOutput = objClassProperty.Name & " = " & objClassProperty.V +alue WScript.Echo " " & strOutput Next WScript.echo " " Next WScript.Quit(0)

my beginner attempt in perl

use strict; use Win32::OLE; use Data::Dumper; my $strServ = "10.x.x.x"; my $wmipath = "root\\Citrix\\WanScaler"; my $strUsrN = "Administrator"; my $strPasswd = "******"; my $objWMILocator; unless( Win32::OLE::CreateObject( "WbemScripting.SWbemLocator", $objWM +ILocator )) { print("Cannot create objWMILocator ($!)\n"); exit; } # TBD - FIX THIS # objWMILocator.Security_.AuthenticationLevel = 6 my $objWMIService; $objWMIService = $objWMILocator->ConnectServer($strServ,$wmipath,$strU +srN,$strPasswd) or die "Can't access WMI on remote machine $strServ\n"; my $colItems = $objWMIService->ExecQuery( "Select * From Citrix_WS_Sys +temConfig" ) or die "ExecQuery failed"; foreach my $objItem ( in $colItems ) { #code yet to be written } print "\nfinished\n";

In reply to Win32::OLE VB to perl translation problem by anadem

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.