Solved

Run local script against remote computer using Psexec.

Posted on 2013-12-18
3
424 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

697 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