Link to home
Start Free TrialLog in
Avatar of rgn2121
rgn2121Flag for United States of America

asked on

Using impersonation to check services on a remote machine.

Scenario:
User on machine A needs to see if services are running on machine B.  User on machine A is your average windows user, no admin rights or anything special.  There is an account that is used on machine B that IS an admin account and this account is what is used to install/unistall services, do updates, etc.

The admin account on machine B does not exist on machine A.  Can I use impersonation to create an app that will allow the user of machine A to impersonate the admin user on machine B and check the services?  Both machines are in the same domain.  The users account is a domain account, but the admin account on machine B is only on that machine...if that matters.

So far I haven't gotten this to work.  Not sure if it will according to this...
http://msdn.microsoft.com/en-us/library/windows/desktop/aa378184(v=vs.85).aspx

If it can't be done this way, can it be done using WMI?
Avatar of dave4dl
dave4dl

I recommend using psservice (from the sysinternals suite). http://technet.microsoft.com/en-us/sysinternals/bb897542

In the command line parameters you can specify the username and password to use for your query.
Avatar of rgn2121

ASKER

I appreciate the reponse, but I need to be able to do this without an additional external tool.
powershell lets you run scripts on another machine so user PS to run the following command: sc queryex type= service state= all | find "_NAME"
actually I just saw that powershell has a built-in command for this.  See http://technet.microsoft.com/en-us/library/dd347591.aspx
lastly, here is a little more info about remote execution with powershell (in general): http://technet.microsoft.com/en-us/library/dd819505.aspx
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
so user PS to run the following command
Wow, I mistyped that
what I meant to say was
so use PS to run the following command
Avatar of rgn2121

ASKER

CodeCrusier...Will it matter if that account exists on the client workstation?  Or will it just work because it is an admin on the host machine...?  I would like to not have to create an account on every workstation.  Just that I can supply the credentials in a config file and it will use those to logon remotely and do the work...
It needs to be an account on the remote computer to which you are connecting.
Avatar of rgn2121

ASKER

K...I have that.  So I don't have to have the same account on the client pc that I am connecting from correct?
Avatar of rgn2121

ASKER

Thanks