Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista Tutorial - How to start a remote service under a different user name

Reply
 
Old 01-22-2008   #1 (permalink)
Flea#
Guest


 
 

How to start a remote service under a different user name

Hello,

I need to be able to start a service a remote server under a different logon
name using PowerShell. If you right click on a service and choose properties
you can click on the 'Log On' tab and by default it uses a system account but
gives you the option to run it as a different account. Is there a way to do
this using PowerShell and probably WMI?

I was looking at the ServiceController.Start Method (String[]) which allows
you to pass parameters but I could not find examples of what parameters you
could pass. Does anyone know if this is possible?

Thanks,
Flea

--
http://fleasharp.blogspot.com/

My System SpecsSystem Spec
Old 01-22-2008   #2 (permalink)
Marco Shaw [MVP]
Guest


 
 

Re: How to start a remote service under a different user name

Flea# wrote:
Quote:

> Hello,
>
> I need to be able to start a service a remote server under a different logon
> name using PowerShell. If you right click on a service and choose properties
> you can click on the 'Log On' tab and by default it uses a system account but
> gives you the option to run it as a different account. Is there a way to do
> this using PowerShell and probably WMI?
>
> I was looking at the ServiceController.Start Method (String[]) which allows
> you to pass parameters but I could not find examples of what parameters you
> could pass. Does anyone know if this is possible?
>
> Thanks,
> Flea
>
I haven't checked other options, but there doesn't seem to be any option
to pass along.

I wasn't able to confirm either that the Start method accepted any kind
of argument.

http://msdn2.microsoft.com/en-us/lib...r_members.aspx

No solution, but it might be possible.

At the very least, maybe the 'log on' name can be changed directly, then
the service started?

Marco

--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp

PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
My System SpecsSystem Spec
Old 01-23-2008   #3 (permalink)
Shay Levi
Guest


 
 

Re: How to start a remote service under a different user name


Try the Change method, you can get more info on it here:
http://msdn2.microsoft.com/en-us/library/aa384901.aspx


## Specify $null if you are not changing the password.
## Specify an empty string if the service has no password.
## When changing a service from a local system to a network, or from a network
to a
## local system, StartPassword must be an empty string ("") and not $null.

$user="domain\username"
$psw = "password"

$svc = Get-WmiObject win32_service -ComputerName computer -filter "name='alerter'"
$svc.change($null,$null,$null,$null,$null,$null,$user,$psw,$null,$null,$null)
# restart the service
$svc.StopService()
$svc.StartService()




-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Quote:

> Flea# wrote:
>
Quote:

>> Hello,
>>
>> I need to be able to start a service a remote server under a
>> different logon name using PowerShell. If you right click on a
>> service and choose properties you can click on the 'Log On' tab and
>> by default it uses a system account but gives you the option to run
>> it as a different account. Is there a way to do this using PowerShell
>> and probably WMI?
>>
>> I was looking at the ServiceController.Start Method (String[]) which
>> allows you to pass parameters but I could not find examples of what
>> parameters you could pass. Does anyone know if this is possible?
>>
>> Thanks,
>> Flea
> I haven't checked other options, but there doesn't seem to be any
> option to pass along.
>
> I wasn't able to confirm either that the Start method accepted any
> kind of argument.
>
> http://msdn2.microsoft.com/en-us/lib...rocess.service
> controller_members.aspx
>
> No solution, but it might be possible.
>
> At the very least, maybe the 'log on' name can be changed directly,
> then the service started?
>
> Marco
>
> PowerGadgets MVP
> http://www.powergadgets.com/mvp
> Blog:
> http://marcoshaw.blogspot.com

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
[HELP] Can't Start Routing And Remote Access Service Vista networking & sharing
Routing and remote access service can't start Vista networking & sharing
Can't start Routing and Remote Access service Vista networking & sharing
How to start a remote service under a different user account PowerShell
Is it possible for a service to start a user app running with admin privilege? Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46