Solved

Run local script against remote computer using Psexec.

Posted on 2013-12-18
3
425 Views
Last Modified: 2013-12-18
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
Comment
Question by:jskfan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
serialband earned 500 total points
ID: 39728185
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
 

Author Comment

by:jskfan
ID: 39728240
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
 

Author Closing Comment

by:jskfan
ID: 39728242
Excellent
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By default the complete memory dump option is disabled in windows . If we want to enable the complete memory dump for a diagnostic purpose, we have a solution for it. here we are using the registry method to enable this.
On some Windows 7 (SP1) computers, Windows Update becomes super slow even the computer is reasonably fast.  There's one solution that seemed to have worked well for me (after trying a few other suggested solutions).
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question