Solved

Run local script against remote computer using Psexec.

Posted on 2013-12-18
3
422 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
  • 2
3 Comments
 
LVL 28

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
cant ping a windows 10 computer 12 56
Aero theme is getting disabled. 3 38
Bulk Reorder File Names 4 56
Remnants of old Homegroup persist 8 14
New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

911 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now