• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 428
  • Last Modified:

Run local script against remote computer using Psexec.

Run local script against remote computer using Psexec.

I have the following script on my windows 7 computer:
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
 Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkLoginProfile")

For Each objItem in colItems
  if (objItem.UserType = "Normal Account") then
   Wscript.Echo objItem.Name
  end if
 Next




I want to use Psexec command so that I can run it against the remote computer.
is it possible? if so please paste the command.

Thanks
0
jskfan
Asked:
jskfan
  • 2
1 Solution
 
serialbandCommented:
You should be able to connect to a remote server with your call to GetObject

change

GetObject("winmgmts:\\.\root\cimv2")

to

GetObject("winmgmts:\\remote_computer\root\cimv2: Win32_LogicalDisk='C:'")
0
 
jskfanAuthor Commented:
worked ..thanks

Set objWMIService = GetObject("winmgmts:\\Remotecomputername\root\cimv2")
 Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkLoginProfile")

For Each objItem in colItems
  if (objItem.UserType = "Normal Account") then
   Wscript.Echo objItem.Name
  end if
 Next
0
 
jskfanAuthor Commented:
Excellent
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now