![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Help with script on service Hey all, I have been playing with powershell for a few weeks now but I need to write a script that is way beyond my knowledge so far. I need to change the service "Remote Procedure Call" to log in with local system account. Is there an easy way to do this in powershell? I have a list workstations.txt I can call to run WMI against but I do not know the command to change the value. Thanks for any help |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Help with script on service To be completely honest with you... what you are asking for AFAICT should be strait forward... I was actually ready just to post the code, but alas... I cannot find a method to do what your want with .NET or WMI... Actually that is not entirely accurate... I found a way to set the value with WMI, but it does not commit to the actual service just the object. I am sure there is a way to do it, but I would just use sc.exe and save your self the time. example or something similar: $cmd = "sc.exe \\$server config $service obj= `"user`" password= `"password`"" invoke-expression $cmd Here is an article to help. http://support.microsoft.com/kb/166819 p.s. If anyone else has got this work using native Powershell.. I would love to know how. "Damon" <Damon@discussions.microsoft.com> wrote in message news:66770754-90A2-47A8-B068-D5863CA0CE23@microsoft.com... > Hey all, > I have been playing with powershell for a few weeks now but I need to > write > a script that is way beyond my knowledge so far. > > I need to change the service "Remote Procedure Call" to log in with local > system account. > > Is there an easy way to do this in powershell? > I have a list workstations.txt I can call to run WMI against but I do not > know the command to change the value. > Thanks for any help > |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Help with script on service OMG... I searched my own site and came up with. http://mow001.blogspot.com/2005/12/p...meters-to.html This should do it for you. "Brandon Shell" <tshell.mask@gmail.com> wrote in message news:%23NDKmvwlHHA.1624@TK2MSFTNGP02.phx.gbl... > To be completely honest with you... what you are asking for AFAICT should > be strait forward... I was actually ready just to post the code, but > alas... I cannot find a method to do what your want with .NET or WMI... > Actually that is not entirely accurate... I found a way to set the value > with WMI, but it does not commit to the actual service just the object. I > am sure there is a way to do it, but I would just use sc.exe and save your > self the time. > > example or something similar: > $cmd = "sc.exe \\$server config $service obj= `"user`" password= > `"password`"" > invoke-expression $cmd > > Here is an article to help. > http://support.microsoft.com/kb/166819 > > p.s. If anyone else has got this work using native Powershell.. I would > love to know how. > > "Damon" <Damon@discussions.microsoft.com> wrote in message > news:66770754-90A2-47A8-B068-D5863CA0CE23@microsoft.com... >> Hey all, >> I have been playing with powershell for a few weeks now but I need to >> write >> a script that is way beyond my knowledge so far. >> >> I need to change the service "Remote Procedure Call" to log in with local >> system account. >> >> Is there an easy way to do this in powershell? >> I have a list workstations.txt I can call to run WMI against but I do not >> know the command to change the value. >> Thanks for any help >> > |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: Help with script on service Here is a function that should help (Password can be null for built-in accounts like LocalSystem and NetworkService) function Change-ServicePassword{ Param([string]$server,[string]$service,[string]$user,[string]$password) # Setup for WMI $class = "Win32_Service" $method = "change" $computer = $server $filter = "Name=`'$service`'" # Getting Service Via WMI $MyService = get-WmiObject $class -computer $computer -filter $filter # Setting Parameters for Change Method $inparams = $MyService.psbase.GetMethodParameters($method) $inparams["StartName"] = $user $inparams["StartPassword"] = $password # Calling Change Method and Return $results $result = $MyService.psbase.InvokeMethod($method,$inparams,$null) $result.ReturnValue } "Brandon Shell" <tshell.mask@gmail.com> wrote in message news:%23NDKmvwlHHA.1624@TK2MSFTNGP02.phx.gbl... > To be completely honest with you... what you are asking for AFAICT should > be strait forward... I was actually ready just to post the code, but > alas... I cannot find a method to do what your want with .NET or WMI... > Actually that is not entirely accurate... I found a way to set the value > with WMI, but it does not commit to the actual service just the object. I > am sure there is a way to do it, but I would just use sc.exe and save your > self the time. > > example or something similar: > $cmd = "sc.exe \\$server config $service obj= `"user`" password= > `"password`"" > invoke-expression $cmd > > Here is an article to help. > http://support.microsoft.com/kb/166819 > > p.s. If anyone else has got this work using native Powershell.. I would > love to know how. > > "Damon" <Damon@discussions.microsoft.com> wrote in message > news:66770754-90A2-47A8-B068-D5863CA0CE23@microsoft.com... >> Hey all, >> I have been playing with powershell for a few weeks now but I need to >> write >> a script that is way beyond my knowledge so far. >> >> I need to change the service "Remote Procedure Call" to log in with local >> system account. >> >> Is there an easy way to do this in powershell? >> I have a list workstations.txt I can call to run WMI against but I do not >> know the command to change the value. >> Thanks for any help >> > |
My System Specs![]() |
| | #5 (permalink) |
| Guest | Re: Help with script on service Query the Win32_Service class from WMI and use its Change() method. -- Don Jones Windows PowerShell MVP Founder: www.ScriptingAnswers.com Co-Author: "Windows PowerShell: TFM" "Damon" <Damon@discussions.microsoft.com> wrote in message news:66770754-90A2-47A8-B068-D5863CA0CE23@microsoft.com... > Hey all, > I have been playing with powershell for a few weeks now but I need to > write > a script that is way beyond my knowledge so far. > > I need to change the service "Remote Procedure Call" to log in with local > system account. > > Is there an easy way to do this in powershell? > I have a list workstations.txt I can call to run WMI against but I do not > know the command to change the value. > Thanks for any help > |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Can a Windows Service run a visual basic script? | David | .NET General | 2 | 03-26-2008 07:04 AM |
| Script that emails out a service failure notification | Ian_1 | PowerShell | 8 | 10-24-2007 10:08 PM |
| script as a service | lonervamp | PowerShell | 6 | 10-16-2007 07:47 AM |
| Script Host Client launched from Windows Service | DavidRF | Vista security | 4 | 06-27-2007 04:01 PM |
| Powershell Script as Windows Service | tobias.kuhn@gmail.com | PowerShell | 5 | 02-08-2007 12:00 PM |