Previous Topic: start-service Command--Start a Windows Service on a Remote or Local System (Funclet)Next Topic: start-java Command--Start Java Virtual Machine (Cmdlet)


stop-service Command--Stop a Windows Service on a Remote or Local System (Funclet)

The stop-service command stops a Windows service on the local or remote system.

The command has the following syntax:

stop-service -svcName sName [-host hostname] [-user username] [-pass password]

The command returns 1 on success and 0 on failure.

-svcName sName

Specifies the name of the service.

-host hostname

(Optional) The name of the remote server.

Default: ""

-user username

(Optional) Specifies the user name to use to log in to the remote node. Unquoted argument tokens are automatically stringified. Prevent automatic quoting for expressions by placing expression code in parentheses.

Default: ""

-pass password

(Optional) Specifies password to use to log in to the remote node. If no password is specified, the password entered during AutoShell login is used. Unquoted argument tokens are automatically stringified. Prevent automatic quoting for expressions by placing expression code in parentheses.

Default: ""

Examples

To stop the local Apache service:

? stop-service -svcName Apache2.2

To stop the Microsoft SQL Server service on a remote server REMOTESRV:

? stop-service -svcName MSSQLSERVER -host REMOTESRV -user admin -pass notsecret