#89689 - 2002-11-21 08:51 AM
Need help with translation
|
Vig
Starting to like KiXtart
Registered: 2001-11-14
Posts: 166
Loc: Saudi Arabia
|
I'm attempting to translate the following bit of code from this vbs script.
code:
Set OpSysSet=GetObject("winmgmts:{(Debug,RemoteShutdown)}//" _ & ComputerName & "/root/cimv2").ExecQuery( _ "Select * from Win32_OperatingSystem where Primary=true") For Each OpSys in OpSysSet OpSys.Win32Shutdown(x) Next
Unfortunantly I know as much about COM as I know about VBS.
Here are a couple of my attempts. Please let me know where I am going wrong.
code:
$ObjShutdown = GetObject("winmgmts:{(Debug,RemoteShutdown)}!\\computername\root\cimv2") .ExecQuery("Select * from Win32_OperatingSystem where Primary=true") For Each $OpSys in $ObjShutdown $execut = $OpSys.Win32Shutdown(4) Next
code:
$ObjShutdown = GetObject("winmgmts:{(Debug,RemoteShutdown)}!\\computername\root\cimv2") $OpSysSet = $ObjShutdown.ExecQuery("Select * from Win32_OperatingSystem where Primary=true") For Each $OpSys in $OpSysSet $execut = $OpSys.Win32Shutdown(4) Next
Thanks
|
|
Top
|
|
|
|
#89691 - 2002-11-21 09:31 AM
Re: Need help with translation
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
|
Top
|
|
|
|
#89694 - 2002-11-21 01:02 PM
Re: Need help with translation
|
Vig
Starting to like KiXtart
Registered: 2001-11-14
Posts: 166
Loc: Saudi Arabia
|
I believe I'm on the verge of understanding this and if someone could answer a couple questions I'd be greatfull.
First, what is the purpose of "Debug,Remoteshutdown" in the following line.
code:
winmgmts:{(Debug,RemoteShutdown)}
In some of the examples on this board I've seen different words such as "impersonationLevel=impersonate" and others were blank.
Second, why was it necessary to do a query for "Primary=true". I was looking at Win32Shutdown on MS MSDN but I see no reference to "this must happen" before you can do "this".
I'm trying to understand what the value of $OpSys is in "$execut = $OpSys.Win32Shutdown(4)".
Thanks for any help.
|
|
Top
|
|
|
|
#89697 - 2002-11-21 04:37 PM
Re: Need help with translation
|
Vig
Starting to like KiXtart
Registered: 2001-11-14
Posts: 166
Loc: Saudi Arabia
|
Thanks, I guess I need to RTFSDK.
|
|
Top
|
|
|
|
#89698 - 2002-11-21 08:10 PM
Re: Need help with translation
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11628
Loc: CA
|
RTNSDK
Normal manual is okay as well.
|
|
Top
|
|
|
|
#89699 - 2002-11-21 08:16 PM
Re: Need help with translation
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
I like that... rtfsdk...
|
|
Top
|
|
|
|
#89700 - 2002-11-21 08:23 PM
Re: Need help with translation
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11628
Loc: CA
|
Sure.. no problem. Its what, 300 pages or so long. I'll memorize it by the end of the day. LOL
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
1 registered
(Allen)
and 1198 anonymous users online.
|
|
|