#47456 - 2003-10-29 08:55 PM
WMI - problems connecting to a server
|
Sverre
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
|
|
|
|
#47458 - 2003-10-29 09:06 PM
Re: WMI - problems connecting to a server
|
Sverre
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
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
|
|
Top
|
|
|
|
#47461 - 2003-10-29 10:34 PM
Re: WMI - problems connecting to a server
|
Sverre
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1471 anonymous users online.
|
|
|