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?
LVL 12
rgn2121Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dave4dlCommented:
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.
0
rgn2121Author Commented:
I appreciate the reponse, but I need to be able to do this without an additional external tool.
0
dave4dlCommented:
powershell lets you run scripts on another machine so user PS to run the following command: sc queryex type= service state= all | find "_NAME"
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

dave4dlCommented:
actually I just saw that powershell has a built-in command for this.  See http://technet.microsoft.com/en-us/library/dd347591.aspx
0
dave4dlCommented:
lastly, here is a little more info about remote execution with powershell (in general): http://technet.microsoft.com/en-us/library/dd819505.aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dave4dlCommented:
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
0
rgn2121Author Commented:
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...
0
CodeCruiserCommented:
It needs to be an account on the remote computer to which you are connecting.
0
rgn2121Author Commented:
K...I have that.  So I don't have to have the same account on the client pc that I am connecting from correct?
0
CodeCruiserCommented:
yes.
0
rgn2121Author Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.