Solved

Run local script against remote computer using Psexec.

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

Accepted Solution

by:
serialband earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Excellent
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Hi Friends, These registry tweaks will help you optimizing your Windows 7 system for any VDI. This will improve the machine performanance and can be used on normal systems also. These are few registry tweaks which will add value by enhancing the …
One of the features I've come to appreciate about Windows 7 and Windows Server 2008 R2 is the ability to pin applications to the task bar. As useful a feature as I've found this, it does have some quirks.  For example, have you ever tried pinning an…
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.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

772 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

9 Experts available now in Live!

Get 1:1 Help Now