![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Get-WmiObject and starting/stopping remote services I am trying to connect remotely to a server, using credentials that are different than my current credentials, and then start / stop a particular services. For that I am using the Get-WmiObject but am not finding a Start or Stop method. $a = Get-WmiObject Win32_service -computer Test01 -Credential Test01\administrator | Where-Object { $_.Name -match "^Cms*" } $a | Get-Member What am I missing here? Is this the best to accomplish remotely start stop services, using different credentials or is there a better way ? TIA -Sourabh |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Get-WmiObject and starting/stopping remote services For now , you can do something like PS C:\> $a = gwmi win32_service -filter "name='spooler'" PS C:\> $a.invokemethod("stopservice",$null) 3 In our next release, you will be able to do $a.stopservice() You can read more about it at http://blogs.msdn.com/powershell/arc...26/647038.aspx -- Wei Wu [MSFT] Windows PowerShell Team Microsoft Corporation This posting is provided "AS IS" with no warranties, and confers no rights. "Sourabh" <kksmkksm@yahoo.com> wrote in message news:O495$kWpGHA.3288@TK2MSFTNGP03.phx.gbl... >I am trying to connect remotely to a server, using credentials that are >different than my current credentials, and then start / stop a particular >services. For that I am using the Get-WmiObject but am not finding a Start >or Stop method. > > $a = Get-WmiObject Win32_service -computer Test01 -Credential > Test01\administrator | Where-Object { $_.Name -match "^Cms*" } > $a | Get-Member > > What am I missing here? Is this the best to accomplish remotely start stop > services, using different credentials or is there a better way ? > > TIA > -Sourabh > > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Get-WmiObject and starting/stopping remote services For now, you can also try this: $svc = Get-WmiObject -Class Win32_Service -ComputerName . | ?{$_.Name -eq "UPHClean"} $svc.InvokeMethod("StopService", $null) The key issue here that they are addressing is that WMI methods aren't exposed by standard .NET wrappers in a clean fashion. Notice that instead of having a named method, in RC1 we have to call a generic InvokeMethod method that takes two arguments. The first argument is the method name, and the second argument is actually an ARRAY of the parameters that the WMI method takes. Since StopService takes no parameters, $null works ok. Info on the Win32_Service class can be found here online: http://msdn.microsoft.com/library/en...32_service.asp A more general way to find methods for all WMI classes in root/cimv2 on a specific machine is to use the following command: Get-WmiObject -List -ComputerName . | %{$_.PSBase} | Select-Object -ExpandProperty Methods "Sourabh" <kksmkksm@yahoo.com> wrote in message news:O495$kWpGHA.3288@TK2MSFTNGP03.phx.gbl... >I am trying to connect remotely to a server, using credentials that are >different than my current credentials, and then start / stop a particular >services. For that I am using the Get-WmiObject but am not finding a Start >or Stop method. > > $a = Get-WmiObject Win32_service -computer Test01 -Credential > Test01\administrator | Where-Object { $_.Name -match "^Cms*" } > $a | Get-Member > > What am I missing here? Is this the best to accomplish remotely start stop > services, using different credentials or is there a better way ? > > TIA > -Sourabh > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Self starting and stopping torrent software | Software | |||
| Starting & stopping services | VB Script | |||
| How to make a batch file on starting and stopping services from command prompt ? | General Discussion | |||
| stopping and starting service | PowerShell | |||
| stopping a program from starting up | Vista General | |||