Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions reference/6/Microsoft.PowerShell.Core/About/about_Jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ work in the session without interruption while the job runs.

## HOW TO START A JOB ON THE LOCAL COMPUTER

To start a background job on the local computer, use the Start-Job
To start a background job on the local computer, use the `Start-Job`
cmdlet.

To write a Start-Job command, enclose the command that the job runs in
braces ( { } ). Use the ScriptBlock parameter to specify the command.
To write a `Start-Job` command, enclose the command that the job runs in curly
braces ( `{ }` ). Use the **ScriptBlock** parameter to specify the command.

The following command starts a background job that runs a `Get-Process`
command on the local computer.
Expand All @@ -67,8 +67,9 @@ object and saves the resulting job object in the \$job variable.
$job = Start-Job -ScriptBlock {Get-Process}
```

You can also use `&` to start jobs.
The following command is functionally equivalent to the command above.
Beginning in PowerShell 6.0, you can use an amersand (`&`) at the end of a
pipeline to start a background job. The following command is functionally
equivalent to the command above.

```powershell
$job = Get-Process &
Expand All @@ -80,7 +81,7 @@ see [background operator](about_Operators.md#background-operator-).

You can also use the `Get-Job` cmdlet to get objects that represent the jobs
started in the current session. `Get-Job` returns the same job object that
Start-Job returns.
`Start-Job` returns.

## GETTING JOB OBJECTS

Expand Down
157 changes: 84 additions & 73 deletions reference/6/Microsoft.PowerShell.Management/Get-Service.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
keywords: powershell,cmdlet
locale: en-us
Module Name: Microsoft.PowerShell.Management
ms.date: 06/09/2017
ms.date: 10/30/2019
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/get-service?view=powershell-6&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Get-Service
---

# Get-Service

## SYNOPSIS
Expand Down Expand Up @@ -38,64 +39,71 @@ Get-Service [-DependentServices] [-RequiredServices] [-Include <String[]>] [-Exc

## DESCRIPTION

The **Get-Service** cmdlet gets objects that represent the services on a computer,
including running and stopped services.
The `Get-Service` cmdlet gets objects that represent the services on a computer, including running
and stopped services. By default, when `Get-Service` is run without parameters, all the local
computer's services are returned.

You can direct this cmdlet to get only particular services by specifying the service name or
the display name of the services, or you can pipe service objects to this cmdlet.
You can direct this cmdlet to get only particular services by specifying the service name or the
display name of the services, or you can pipe service objects to this cmdlet.

## EXAMPLES

### Example 1: Get all services on the computer

This example gets all of the services on the computer. It behaves as though you typed
`Get-Service *`. The default display shows the status, service name, and display name of each
service.

```powershell
Get-Service
```

This command gets all of the services on the computer.
It behaves as though you typed `Get-Service *`.
The default display shows the status, service name, and display name of each service.

### Example 2: Get services that begin with a search string

This example retrieves services with service names that begin with WMI (Windows Management
Instrumentation).

```powershell
Get-Service "wmi*"
```

This command retrieves services with service names that begin with WMI (the acronym for Windows Management Instrumentation).

### Example 3: Display services that include a search string

This example displays services with a display name that includes the word network. Searching the
display name finds network-related services even when the service name doesn't include Net, such as
xmlprov, the Network Provisioning Service.

```powershell
Get-Service -Displayname "*network*"
```

This command displays services with a display name that includes the word network.
Searching the display name finds network-related services even when the service name does not include "Net", such as xmlprov, the Network Provisioning Service.

### Example 4: Get services that begin with a search string and an exclusion

This example only gets the services with service names that begin with **win**, except for the WinRM
service.

```powershell
Get-Service -Name "win*" -Exclude "WinRM"
```

These commands get only the services with service names that begin with win, except for the WinRM service.

### Example 5: Display services that are currently active

This example displays only the services with a status of Running.

```powershell
Get-Service | Where-Object {$_.Status -eq "Running"}
```

This command displays only the services that are currently active.
It uses the **Get-Service** cmdlet to get all of the services on the computer.
The pipeline operator (|) passes the results to the Where-Object cmdlet, which selects only the services with a Status property that equals Running.
`Get-Service` gets all the services on the computer and sends the objects down the pipeline. The
`Where-Object` cmdlet, selects only the services with a **Status** property that equals Running.

Status is only one property of service objects.
To see all of the properties, type `Get-Service | Get-Member`.
Status is only one property of service objects. To see all of the properties, type
`Get-Service | Get-Member`.

### Example 6: List the services on the computer that have dependent services

This example gets services that have dependent services.

```powershell
Get-Service |
Where-Object {$_.DependentServices} |
Expand All @@ -115,14 +123,24 @@ NoOfDependentServices : 1
...
```

The first command uses the **Get-Service** cmdlet to get the services on the computer.
A pipeline operator (|) sends the services to the **Where-Object** cmdlet, which selects the services whose **DependentServices** property is not null.
The `Get-Service` cmdlet gets all the services on the computer and sends the objects down the
pipeline. The `Where-Object` cmdlet selects the services whose **DependentServices** property isn't
null.

Another pipeline operator sends the results to the Format-List cmdlet.
The command uses its *Property* parameter to display the name of the service, the name of the dependent services, and a calculated property that displays the number of dependent services that each service has.
The results are sent down the pipeline to the `Format-List` cmdlet. The **Property** parameter
displays the name of the service, the name of the dependent services, and a calculated property that
displays the number of dependent services for each service.

### Example 7: Sort services by property value

This example shows that when you sort services in ascending order by the value of their **Status**
property, stopped services appear before running services. The reason is because the value of
**Status** is an enumeration, in which Stopped has a value of 1, and Running has a value of 4. For
more information, see
[ServiceControllerStatus](/dotnet/api/system.serviceprocess.servicecontrollerstatus).

To list running services first, use the **Descending** parameter of the `Sort-Object` cmdlet.

```powershell
Get-Service "s*" | Sort-Object status
```
Expand All @@ -145,55 +163,46 @@ Running SENS System Event Notification
Running seclogon Secondary Logon
```

This command shows that when you sort services in ascending order by the value of their **Status** property, stopped services appear before running services.
This happens because the value of Status is an enumeration, in which Stopped has a value of 1, and Running has a value of 4.

To list running services first, use the *Descending* parameter of the Sort-Object cmdlet.

### Example 8: Get the dependent services of a service

This example gets the services that the WinRM service requires. The value of the service's
**ServicesDependedOn** property is returned.

```powershell
Get-Service "WinRM" -RequiredServices
```

This command gets the services that the WinRM service requires.

The command returns the value of the **ServicesDependedOn** property of the service.

### Example 9: Get a service through the pipeline operator

This example gets the WinRM service on the local computer. The service name string, enclosed in
quotation marks, is sent down the pipeline to `Get-Service`.

```powershell
"WinRM" | Get-Service
```

This command gets the WinRM service on the local computer.
This example shows that you can pipe a service name string (enclosed in quotation marks) to **Get-Service**.

## PARAMETERS

### -DependentServices

Indicates that this cmdlet gets only the services that depend upon the specified service.

By default, this cmdlet gets all services.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: DS

Required: False
Position: Named
Default value: None
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```

### -DisplayName

Specifies, as a string array, the display names of services to be retrieved.
Wildcards are permitted.
By default, this cmdlet gets all services on the computer.
Specifies, as a string array, the display names of services to be retrieved. Wildcards are
permitted.

```yaml
Type: String[]
Expand All @@ -210,9 +219,8 @@ Accept wildcard characters: True
### -Exclude

Specifies, as a string array, a service or services that this cmdlet excludes from the operation.
The value of this parameter qualifies the *Name* parameter.
Enter a name element or pattern, such as "s*".
Wildcards are permitted.
The value of this parameter qualifies the **Name** parameter. Enter a name element or pattern, such
as `s*`. Wildcards are permitted.

```yaml
Type: String[]
Expand All @@ -228,10 +236,9 @@ Accept wildcard characters: True

### -Include

Specifies, as a string array, a service or services that this cmdlet includes in the operation.
The value of this parameter qualifies the *Name* parameter.
Enter a name element or pattern, such as "s*".
Wildcards are permitted.
Specifies, as a string array, a service or services that this cmdlet includes in the operation. The
value of this parameter qualifies the **Name** parameter. Enter a name element or pattern, such as
`s*`. Wildcards are permitted.

```yaml
Type: String[]
Expand All @@ -247,9 +254,9 @@ Accept wildcard characters: True

### -InputObject

Specifies **ServiceController** objects representing the services to be retrieved.
Enter a variable that contains the objects, or type a command or expression that gets the objects.
You can also pipe a service object to this cmdlet.
Specifies **ServiceController** objects representing the services to be retrieved. Enter a variable
that contains the objects, or type a command or expression that gets the objects. You can pipe a
service object to this cmdlet.

```yaml
Type: ServiceController[]
Expand All @@ -265,9 +272,7 @@ Accept wildcard characters: False

### -Name

Specifies the service names of services to be retrieved.
Wildcards are permitted.
By default, this cmdlet gets all of the services on the computer.
Specifies the service names of services to be retrieved. Wildcards are permitted.

```yaml
Type: String[]
Expand All @@ -283,10 +288,8 @@ Accept wildcard characters: True

### -RequiredServices

Indicates that this cmdlet gets only the services that this service requires.

This parameter gets the value of the **ServicesDependedOn** property of the service.
By default, this cmdlet gets all services.
Indicates that this cmdlet gets only the services that this service requires. This parameter gets
the value of the **ServicesDependedOn** property of the service.

```yaml
Type: SwitchParameter
Expand All @@ -295,14 +298,17 @@ Aliases: SDO, ServicesDependedOn

Required: False
Position: Named
Default value: None
Default value: False
Accept pipeline input: False
Accept wildcard characters: True
```

### CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
-WarningAction, and -WarningVariable. For more information, see
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

Expand All @@ -318,18 +324,25 @@ This cmdlet returns objects that represent the services on the computer.

## NOTES

You can also refer to **Get-Service** by its built-in alias, "gsv". For more information, see about_Aliases.
Beginning in PowerShell 6.0, the following properties are added to the **ServiceController**
objects: **UserName**, **Description**, **DelayedAutoStart**, **BinaryPathName**, and
**StartupType** .

This cmdlet can display services only when the current user has permission to see them.
If this cmdlet does not display services, you might not have permission to see them.
You can also refer to `Get-Service` by its built-in alias, `gsv`. For more information, see
[about_Aliases](../Microsoft.PowerShell.Core/About/about_Aliases.md).

To find the service name and display name of each service on your system, type `Get-Service`.
The service names appear in the Name column, and the display names appear in the DisplayName column.
This cmdlet can display services only when the current user has permission to see them. If this
cmdlet does not display services, you might not have permission to see them.

When you sort in ascending order by status value, "Stopped" services appear before "Running" services.
The Status property of a service is an enumerated value in which the names of the statuses represent integer values.
The sort is based on the integer value, not the name.
"Running" appears before "Stopped" because "Stopped" has a value of "1", and "Running" has a value of "4".
To find the service name and display name of each service on your system, type `Get-Service`. The
service names appear in the Name column, and the display names appear in the **DisplayName** column.

When you sort in ascending order by the **Status** property's value, Stopped services appear before
Running services. The service's **Status** property is an enumerated value and the status names
represent integer values. The sort order is based on the integer value, not the name. Stopped
appears before because Running because Stopped has a value of 1, and Running has a value of 4. For
more information, see
[ServiceControllerStatus](/dotnet/api/system.serviceprocess.servicecontrollerstatus).

## RELATED LINKS

Expand All @@ -348,5 +361,3 @@ The sort is based on the integer value, not the name.
[Suspend-Service](Suspend-Service.md)

[Remove-Service](Remove-Service.md)


2 changes: 2 additions & 0 deletions reference/6/Microsoft.PowerShell.Management/Set-Service.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ object and the password is stored as a [SecureString](/dotnet/api/system.securit
> For more information about **SecureString** data protection, see
> [How secure is SecureString?](/dotnet/api/system.security.securestring#how-secure-is-securestring).

This parameter was introduced in PowerShell 6.0.

```yaml
Type: PSCredential
Parameter Sets: (All)
Expand Down
Loading