Page 1 of 1 1
Topic Options
#47456 - 2003-10-29 08:55 PM WMI - problems connecting to a server
Sverre Offline
Getting the hang of it

Registered: 2002-09-29
Posts: 52
I have made a small script that checks jobs in all the print ques on the primary domain controller (PDC).

The problem is that it can't be used from any other server (I have a dedicated server for controlling the network).

I can run the script from any other server/machine to check on any of the other servers/machines. But it can not check the PDC(it can check the BDC) unless run from the PDC.

Also, the script when run from the PDC can NOT check any other server/machine.

What am I doing wrong?

Top
#47457 - 2003-10-29 08:57 PM Re: WMI - problems connecting to a server
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
It would help if you would post your script. It might be authentication issues.
_________________________
There are two types of vessels, submarines and targets.

Top
#47458 - 2003-10-29 09:06 PM Re: WMI - problems connecting to a server
Sverre Offline
Getting the hang of it

Registered: 2002-09-29
Posts: 52
It's just a test. And I don't need to authenticate on any of the other servers/machines. I am logged in as domain admin on the server I'm trying to run it from (actualy I've logged in as domain admin from ALL the servers/machines I've tried running it from).

code:
$workstation = "10.47.2.1"
$x = 0
$name = "Something"
while len($name) > 0
$name = WMIQuery("Name","Win32_PerfRawData_Spooler_PrintQueue",$workstation)[$x]
? $name
if $name = "_Total"
$jobs = WMIQuery("TotalJobsPrinted","Win32_PerfRawData_Spooler_PrintQueue",$workstation)[$x]
goto ok
endif
$x = $x + 1
loop

:ok
? $jobs

exit



;SYNTAX WMIQuery($what,$from,optional $computer,optional $where, optional $x)
; http://download.microsoft.com/download/platformsdk/wmicore/1.5/W9XNT4/EN-US/wmicore.EXE

FUNCTION WMIQuery($sWhat, $sFrom, Optional $sComputer, Optional $sWhere, Optional $x)
Dim $sQuery, $objEnum, $sValue, $sItem, $lUbound
Dim $aTMP[0]
$sQuery = "Select " + $sWhat + " From "+ $sFrom
If Not $sComputer
$sComputer=@WKSTA
EndIf
If $sWhere AND $x
$sQuery = $sQuery + " Where " + $sWhere + " = '"+$x+"'"
EndIf
$SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//"+$sComputer)
If @ERROR
Exit VAL("&"+Right(DecToHex(@ERROR),4))
Return
EndIf
$objEnum = $SystemSet.ExecQuery($sQuery)
If @ERROR
Exit VAL("&"+Right(DecToHex(@ERROR),4))
Return
EndIf
For Each $objInstance in $objEnum
If $objInstance
$=Execute("$$sValue = $$objInstance.$sWhat")
Select
Case VarType($sValue) & 8192
For Each $sItem in $sValue
$lUbound = Ubound($aTMP)
If $aTMP[$lUbound] >' '
$lUbound = $lUbound +1
Redim Preserve $aTMP[$lUbound]
EndIf
$aTMP[$lUbound] = Trim($sItem)
Next
Case 1
$lUbound = Ubound($aTMP)
If $aTMP[$lUbound] >' '
$lUbound = $lUbound +1
Redim Preserve $aTMP[$lUbound]
EndIf
$aTMP[$lUbound] = Trim($sValue)
EndSelect
EndIf
Next
$WMIQuery = $aTMP
Exit VAL("&"+Right(DecToHex(@ERROR),4))
ENDFUNCTION



Top
#47459 - 2003-10-29 10:03 PM Re: WMI - problems connecting to a server
Sverre Offline
Getting the hang of it

Registered: 2002-09-29
Posts: 52
It looks like was a DCOM problem.
Solution:

Run dcomcnfg.exe
Select Default properties
Tick Enable distributed COM on this computer
Click OK and reboot

[Frown]

Top
#47460 - 2003-10-29 10:11 PM Re: WMI - problems connecting to a server
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
What OS are you actually running this under? I suspect Win NT 4.0?
_________________________
There are two types of vessels, submarines and targets.

Top
#47461 - 2003-10-29 10:34 PM Re: WMI - problems connecting to a server
Sverre Offline
Getting the hang of it

Registered: 2002-09-29
Posts: 52
2000 server. This is the only server I've had this problem on.
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1471 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.057 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org