Updates from: 01/26/2022 02:53:45
Service Microsoft Docs article Related commit history on GitHub Change details
Microsoft.PowerShell.Management Set Location (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Management/Set-Location.md
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 02/04/2020 Last updated : 01/25/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/set-location?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Set-Location
stack. For more information about location stacks, see the Notes.
```powershell PS C:\> Set-Location -Path "HKLM:\"
-```
-
-```output
PS HKLM:\> ```
This command sets the current location to the root of the `HKLM:` drive.
PS C:\> Set-Location -Path "Env:\" -PassThru ```
-```output
+```Output
Path ---- Env:\
is typed. No characters are interpreted as wildcard characters. If the path incl
characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.
-Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences.
- ```yaml Type: System.String Parameter Sets: LiteralPath
Accept wildcard characters: False
### -Path Specify the path of a new working location. If no path is provided, `Set-Location` defaults to the
-current user's home directory. When wildcards are used, the cmdlet chooses the first path that
-matches the wildcard pattern.
+current user's home directory. When wildcards are used, the cmdlet chooses the container (directory,
+registry key, certificate store) that matches the wildcard pattern. If the wildcard pattern matches
+more than one container, the cmdlet returns an error.
```yaml Type: System.String
Accept wildcard characters: True
### -StackName
-Specifies the existing location stack name that this cmdlet makes the current location stack. Enter
+Specifies an existing location stack name that this cmdlet makes the current location stack. Enter
a location stack name. To indicate the unnamed default location stack, type `$null` or an empty string (`""`).
-The `*-Location` cmdlets act on the current stack unless you use the **StackName** parameter to
-specify a different stack.
+Using this parameter does not change the current location. It only changes the stack used by the
+`*-Location` cmdlets. The `*-Location` cmdlets act on the current stack unless you use the
+**StackName** parameter to specify a different stack. For more information about location stacks,
+see the [Notes](#notes).
```yaml Type: System.String
Microsoft.PowerShell.Utility Compare Object (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Utility/Compare-Object.md
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 05/06/2021 Last updated : 01/25/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/compare-object?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Compare-Object
shows which input object the output belongs to.
## Notes When using the **PassThru** parameter, the output displayed in the console may not include the
-**SideIndicator** property. The default format view of the for the object type output by
-`Compare-Object` does not include the **SideIndicator** property. For more information see
-[Example 3](#ex3) in this article.
+**SideIndicator** property. The default format view for the object type output by `Compare-Object`
+does not include the **SideIndicator** property. For more information see [Example 3](#ex3) in this
+article.
## Related links
Microsoft.PowerShell.Management Set Location (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Management/Set-Location.md
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 02/04/2020 Last updated : 01/25/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/set-location?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Set-Location
independent from the location stack that is accessed using the **StackName** par
### Example 1: Set the current location
-```
+```powershell
PS C:\> Set-Location -Path "HKLM:\" PS HKLM:\> ```
This command sets the current location to the root of the `HKLM:` drive.
### Example 2: Set the current location and display that location
-```
+```powershell
PS C:\> Set-Location -Path "Env:\" -PassThru ```
To get the current location in the PSDrive use `Get-Location -PSDrive <DriveName
### Example 4: Set the current location to a named stack
-```
+```powershell
PS C:\> Push-Location -Path 'C:\Program Files\PowerShell\' -StackName "Paths" PS C:\Program Files\PowerShell\> Set-Location -StackName "Paths" PS C:\Program Files\PowerShell\> Get-Location -Stack
Accept wildcard characters: False
### -Path Specify the path of a new working location. If no path is provided, `Set-Location` defaults to the
-current user's home directory. When wildcards are used, the cmdlet chooses the first path that
-matches the wildcard pattern.
+current user's home directory. When wildcards are used, the cmdlet chooses the container (directory,
+registry key, certificate store) that matches the wildcard pattern. If the wildcard pattern matches
+more than one container, the cmdlet returns an error.
PowerShell keeps a history of the last 20 locations you have set. If the **Path** parameter value is the `-` character, then the new working location will be the previous working location in history (if it exists). Similarly, if the value is the `+` character, then the new working location will be the next working location in history (if it exists). This is similar to using `Pop-Location` and `Push-Location` except that the history is a list, not a stack, and is implicitly tracked,
-not manually controlled. Currently, there is no way to view the history list.
+not manually controlled. There is no way to view the history list.
```yaml Type: System.String
Accept wildcard characters: True
### -StackName
-Specifies the existing location stack name that this cmdlet makes the current location stack. Enter
+Specifies an existing location stack name that this cmdlet makes the current location stack. Enter
a location stack name. To indicate the unnamed default location stack, type `$null` or an empty string (`""`).
-The `*-Location` cmdlets act on the current stack unless you use the **StackName** parameter to
-specify a different stack. For more information about location stacks, see the [Notes](#notes).
+Using this parameter does not change the current location. It only changes the stack used by the
+`*-Location` cmdlets. The `*-Location` cmdlets act on the current stack unless you use the
+**StackName** parameter to specify a different stack. For more information about location stacks,
+see the [Notes](#notes).
```yaml Type: System.String
Microsoft.PowerShell.Utility Compare Object (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Utility/Compare-Object.md
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 05/06/2021 Last updated : 01/25/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/compare-object?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Compare-Object
a collection of objects. `Compare-Object` examines adjacent objects when it does
in the same position in a collection. The default value is `[Int32]::MaxValue`, which means that `Compare-Object` examines the entire object collection.
-When working with large collections, the default value might not be efficient but is very accurate.
+When working with large collections, the default value might not be efficient but is accurate.
Specifying a smaller value for **SyncWindow** can increase performance but could have lower accuracy.
shows which input object the output belongs to.
## Notes When using the **PassThru** parameter, the output displayed in the console may not include the
-**SideIndicator** property. The default format view of the for the object type output by
-`Compare-Object` does not include the **SideIndicator** property. For more information see
-[Example 3](#ex3) in this article.
+**SideIndicator** property. The default format view for the object type output by `Compare-Object`
+does not include the **SideIndicator** property. For more information see [Example 3](#ex3) in this
+article.
## Related links
Microsoft.PowerShell.Management Set Location (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Management/Set-Location.md
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 02/04/2020 Last updated : 01/25/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/set-location?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Set-Location
independent from the location stack that is accessed using the **StackName** par
### Example 1: Set the current location
-```
+```powershell
PS C:\> Set-Location -Path "HKLM:\" PS HKLM:\> ```
This command sets the current location to the root of the `HKLM:` drive.
### Example 2: Set the current location and display that location
-```
+```powershell
PS C:\> Set-Location -Path "Env:\" -PassThru ```
To get the current location in the PSDrive use `Get-Location -PSDrive <DriveName
### Example 4: Set the current location to a named stack
-```
+```powershell
PS C:\> Push-Location -Path 'C:\Program Files\PowerShell\' -StackName "Paths" PS C:\Program Files\PowerShell\> Set-Location -StackName "Paths" PS C:\Program Files\PowerShell\> Get-Location -Stack
Accept wildcard characters: False
### -Path Specify the path of a new working location. If no path is provided, `Set-Location` defaults to the
-current user's home directory. When wildcards are used, the cmdlet chooses the first path that
-matches the wildcard pattern.
+current user's home directory. When wildcards are used, the cmdlet chooses the container (directory,
+registry key, certificate store) that matches the wildcard pattern. If the wildcard pattern matches
+more than one container, the cmdlet returns an error.
PowerShell keeps a history of the last 20 locations you have set. If the **Path** parameter value is the `-` character, then the new working location will be the previous working location in history (if it exists). Similarly, if the value is the `+` character, then the new working location will be the next working location in history (if it exists). This is similar to using `Pop-Location` and `Push-Location` except that the history is a list, not a stack, and is implicitly tracked,
-not manually controlled. Currently, there is no way to view the history list.
+not manually controlled. There is no way to view the history list.
```yaml Type: System.String
Accept wildcard characters: True
### -StackName
-Specifies the existing location stack name that this cmdlet makes the current location stack. Enter
+Specifies an existing location stack name that this cmdlet makes the current location stack. Enter
a location stack name. To indicate the unnamed default location stack, type `$null` or an empty string (`""`).
-The `*-Location` cmdlets act on the current stack unless you use the **StackName** parameter to
-specify a different stack. For more information about location stacks, see the [Notes](#notes).
+Using this parameter does not change the current location. It only changes the stack used by the
+`*-Location` cmdlets. The `*-Location` cmdlets act on the current stack unless you use the
+**StackName** parameter to specify a different stack. For more information about location stacks,
+see the [Notes](#notes).
```yaml Type: System.String
the current stack, use the **StackName** parameter of the `Set-Location` cmdlet
[Pop-Location](Pop-Location.md) [Push-Location](Push-Location.md)-
Microsoft.PowerShell.Utility Compare Object (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Utility/Compare-Object.md
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 05/06/2021 Last updated : 01/25/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/compare-object?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Compare-Object
a collection of objects. `Compare-Object` examines adjacent objects when it does
in the same position in a collection. The default value is `[Int32]::MaxValue`, which means that `Compare-Object` examines the entire object collection.
-When working with large collections, the default value might not be efficient but is very accurate.
+When working with large collections, the default value might not be efficient but is accurate.
Specifying a smaller value for **SyncWindow** can increase performance but could have lower accuracy.
shows which input object the output belongs to.
## Notes When using the **PassThru** parameter, the output displayed in the console may not include the
-**SideIndicator** property. The default format view of the for the object type output by
-`Compare-Object` does not include the **SideIndicator** property. For more information see
-[Example 3](#ex3) in this article.
+**SideIndicator** property. The default format view for the object type output by `Compare-Object`
+does not include the **SideIndicator** property. For more information see [Example 3](#ex3) in this
+article.
## Related links
Microsoft.PowerShell.Management Set Location (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Management/Set-Location.md
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 02/04/2020 Last updated : 01/25/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/set-location?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Set-Location
independent from the location stack that is accessed using the **StackName** par
### Example 1: Set the current location
-```
+```powershell
PS C:\> Set-Location -Path "HKLM:\" PS HKLM:\> ```
This command sets the current location to the root of the `HKLM:` drive.
### Example 2: Set the current location and display that location
-```
+```powershell
PS C:\> Set-Location -Path "Env:\" -PassThru ```
To get the current location in the PSDrive use `Get-Location -PSDrive <DriveName
### Example 4: Set the current location to a named stack
-```
+```powershell
PS C:\> Push-Location -Path 'C:\Program Files\PowerShell\' -StackName "Paths" PS C:\Program Files\PowerShell\> Set-Location -StackName "Paths" PS C:\Program Files\PowerShell\> Get-Location -Stack
Accept wildcard characters: False
### -Path Specify the path of a new working location. If no path is provided, `Set-Location` defaults to the
-current user's home directory. When wildcards are used, the cmdlet chooses the first path that
-matches the wildcard pattern.
+current user's home directory. When wildcards are used, the cmdlet chooses the container (directory,
+registry key, certificate store) that matches the wildcard pattern. If the wildcard pattern matches
+more than one container, the cmdlet returns an error.
PowerShell keeps a history of the last 20 locations you have set. If the **Path** parameter value is the `-` character, then the new working location will be the previous working location in history (if it exists). Similarly, if the value is the `+` character, then the new working location will be the next working location in history (if it exists). This is similar to using `Pop-Location` and `Push-Location` except that the history is a list, not a stack, and is implicitly tracked,
-not manually controlled. Currently, there is no way to view the history list.
+not manually controlled. There is no way to view the history list.
```yaml Type: System.String
Accept wildcard characters: True
### -StackName
-Specifies the existing location stack name that this cmdlet makes the current location stack. Enter
+Specifies an existing location stack name that this cmdlet makes the current location stack. Enter
a location stack name. To indicate the unnamed default location stack, type `$null` or an empty string (`""`).
-The `*-Location` cmdlets act on the current stack unless you use the **StackName** parameter to
-specify a different stack. For more information about location stacks, see the [Notes](#notes).
+Using this parameter does not change the current location. It only changes the stack used by the
+`*-Location` cmdlets. The `*-Location` cmdlets act on the current stack unless you use the
+**StackName** parameter to specify a different stack. For more information about location stacks,
+see the [Notes](#notes).
```yaml Type: System.String
the current stack, use the **StackName** parameter of the `Set-Location` cmdlet
[Pop-Location](Pop-Location.md) [Push-Location](Push-Location.md)-
Microsoft.PowerShell.Utility Compare Object (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Utility/Compare-Object.md
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 05/06/2021 Last updated : 01/25/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/compare-object?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Compare-Object
a collection of objects. `Compare-Object` examines adjacent objects when it does
in the same position in a collection. The default value is `[Int32]::MaxValue`, which means that `Compare-Object` examines the entire object collection.
-When working with large collections, the default value might not be efficient but is very accurate.
+When working with large collections, the default value might not be efficient but is accurate.
Specifying a smaller value for **SyncWindow** can increase performance but could have lower accuracy.
shows which input object the output belongs to.
## Notes When using the **PassThru** parameter, the output displayed in the console may not include the
-**SideIndicator** property. The default format view of the for the object type output by
-`Compare-Object` does not include the **SideIndicator** property. For more information see
-[Example 3](#ex3) in this article.
+**SideIndicator** property. The default format view for the object type output by `Compare-Object`
+does not include the **SideIndicator** property. For more information see [Example 3](#ex3) in this
+article.
## Related links
Microsoft.PowerShell.Management Set Location (7.3) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.3/Microsoft.PowerShell.Management/Set-Location.md
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 02/04/2020 Last updated : 01/25/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/set-location?view=powershell-7.3&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Set-Location
independent from the location stack that is accessed using the **StackName** par
### Example 1: Set the current location
-```
+```powershell
PS C:\> Set-Location -Path "HKLM:\" PS HKLM:\> ```
This command sets the current location to the root of the `HKLM:` drive.
### Example 2: Set the current location and display that location
-```
+```powershell
PS C:\> Set-Location -Path "Env:\" -PassThru ```
To get the current location in the PSDrive use `Get-Location -PSDrive <DriveName
### Example 4: Set the current location to a named stack
-```
+```powershell
PS C:\> Push-Location -Path 'C:\Program Files\PowerShell\' -StackName "Paths" PS C:\Program Files\PowerShell\> Set-Location -StackName "Paths" PS C:\Program Files\PowerShell\> Get-Location -Stack
Accept wildcard characters: False
### -Path Specify the path of a new working location. If no path is provided, `Set-Location` defaults to the
-current user's home directory. When wildcards are used, the cmdlet chooses the first path that
-matches the wildcard pattern.
+current user's home directory. When wildcards are used, the cmdlet chooses the container (directory,
+registry key, certificate store) that matches the wildcard pattern. If the wildcard pattern matches
+more than one container, the cmdlet returns an error.
PowerShell keeps a history of the last 20 locations you have set. If the **Path** parameter value is the `-` character, then the new working location will be the previous working location in history (if it exists). Similarly, if the value is the `+` character, then the new working location will be the next working location in history (if it exists). This is similar to using `Pop-Location` and `Push-Location` except that the history is a list, not a stack, and is implicitly tracked,
-not manually controlled. Currently, there is no way to view the history list.
+not manually controlled. There is no way to view the history list.
```yaml Type: System.String
Accept wildcard characters: True
### -StackName
-Specifies the existing location stack name that this cmdlet makes the current location stack. Enter
+Specifies an existing location stack name that this cmdlet makes the current location stack. Enter
a location stack name. To indicate the unnamed default location stack, type `$null` or an empty string (`""`).
-The `*-Location` cmdlets act on the current stack unless you use the **StackName** parameter to
-specify a different stack. For more information about location stacks, see the [Notes](#notes).
+Using this parameter does not change the current location. It only changes the stack used by the
+`*-Location` cmdlets. The `*-Location` cmdlets act on the current stack unless you use the
+**StackName** parameter to specify a different stack. For more information about location stacks,
+see the [Notes](#notes).
```yaml Type: System.String
the current stack, use the **StackName** parameter of the `Set-Location` cmdlet
[Pop-Location](Pop-Location.md) [Push-Location](Push-Location.md)-
Microsoft.PowerShell.Utility Compare Object (7.3) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.3/Microsoft.PowerShell.Utility/Compare-Object.md
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 05/06/2021 Last updated : 01/25/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/compare-object?view=powershell-7.3&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Compare-Object
a collection of objects. `Compare-Object` examines adjacent objects when it does
in the same position in a collection. The default value is `[Int32]::MaxValue`, which means that `Compare-Object` examines the entire object collection.
-When working with large collections, the default value might not be efficient but is very accurate.
+When working with large collections, the default value might not be efficient but is accurate.
Specifying a smaller value for **SyncWindow** can increase performance but could have lower accuracy.
shows which input object the output belongs to.
## Notes When using the **PassThru** parameter, the output displayed in the console may not include the
-**SideIndicator** property. The default format view of the for the object type output by
-`Compare-Object` does not include the **SideIndicator** property. For more information see
-[Example 3](#ex3) in this article.
+**SideIndicator** property. The default format view for the object type output by `Compare-Object`
+does not include the **SideIndicator** property. For more information see [Example 3](#ex3) in this
+article.
## Related links
developer Approved Verbs For Windows Powershell Commands https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/docs-conceptual/developer/cmdlet/approved-verbs-for-windows-powershell-commands.md
--- description: Approved Verbs for PowerShell Commands Previously updated : 03/01/2021 Last updated : 01/25/2022 Title: Approved Verbs for PowerShell Commands ---
the cmdlets that are designed by others.
`Eliminate`. - Use only the form of each verb that is listed in this topic. For example, use `Get`, but do not use `Getting` or `Gets`.-- Do not use the following reserved verbs or aliases. The PowerShell language or a rare few of its
- cmdlet uses these verbs under exceptional circumstances.
+- Do not use the following reserved verbs or aliases. The PowerShell language and a rare few cmdlets
+ use these verbs under exceptional circumstances.
- ForEach (foreach)
- - [Format](/dotnet/api/System.Management.Automation.VerbsCommon.Format) (f): Arranges objects in a
- specified form or layout
- - [Group](/dotnet/api/System.Management.Automation.VerbsData.Group) (gp): Arranges or associates
- one or more resources
- - [Ping](/dotnet/api/System.Management.Automation.VerbsDiagnostic.Ping) (pi)
+ - Ping (pi)
- Sort (sr) - Tee (te) - Where (wh)
The following similar verbs represent different actions.
### New vs. Set
-Use the `New` verb to create a new resource. Use the `Set` verb to modify an existing
-resource, optionally creating it if it does not exist, such as the `Set-Variable` cmdlet.
+Use the `New` verb to create a new resource. Use the `Set` verb to modify an existing resource,
+optionally creating it if it does not exist, such as the `Set-Variable` cmdlet.
### Find vs. Search
-Use the `Find` verb to look for an object. Use the `Search` verb to create a reference to a
-resource in a container.
+Use the `Find` verb to look for an object. Use the `Search` verb to create a reference to a resource
+in a container.
### Get vs. Read Use the `Get` verb to obtain information about a resource (such as a file) or to obtain an object
-with which you can access the resource in future. Use the `Read` verb to open a resource and
-extract information contained within.
+with which you can access the resource in future. Use the `Read` verb to open a resource and extract
+information contained within.
### Invoke vs. Start
-Use the `Invoke` verb to perform synchronous operations, such as
-running a command and waiting for it to end. Use the `Start` verb to begin asynchronous
-operations, such as starting an autonomous process.
+Use the `Invoke` verb to perform synchronous operations, such as running a command and waiting for
+it to end. Use the `Start` verb to begin asynchronous operations, such as starting an autonomous
+process.
### Ping vs. Test
PowerShell uses the
enumeration class to define generic actions that can apply to almost any cmdlet. The following table lists most of the defined verbs.
-|Verb (alias)|Action|Synonyms to avoid|
-|--------------------|------------|--------------|
-|[Add](/dotnet/api/System.Management.Automation.VerbsCommon.Add) (a)|Adds a resource to a container, or attaches an item to another item. For example, the `Add-Content` cmdlet adds content to a file. This verb is paired with `Remove`.|Append, Attach, Concatenate, Insert|
-|[Clear](/dotnet/api/System.Management.Automation.VerbsCommon.Clear) (cl)|Removes all the resources from a container but does not delete the container. For example, the `Clear-Content` cmdlet removes the contents of a file but does not delete the file.|Flush, Erase, Release, Unmark, Unset, Nullify|
-|[Close](/dotnet/api/System.Management.Automation.VerbsCommon.Close) (cs)|Changes the state of a resource to make it inaccessible, unavailable, or unusable. This verb is paired with `Open.`||
-|[Copy](/dotnet/api/System.Management.Automation.VerbsCommon.Copy) (cp)|Copies a resource to another name or to another container. For example, the `Copy-Item` cmdlet copies an item (such as a file) from one location in the data store to another location.|Duplicate, Clone, Replicate, Sync|
-|[Enter](/dotnet/api/System.Management.Automation.VerbsCommon.Enter) (et)|Specifies an action that allows the user to move into a resource. For example, the `Enter-PSSession` cmdlet places the user in an interactive session. This verb is paired with `Exit`.|Push, Into|
-|[Exit](/dotnet/api/System.Management.Automation.VerbsCommon.Exit) (ex)|Sets the current environment or context to the most recently used context. For example, the `Exit-PSSession` cmdlet places the user in the session that was used to start the interactive session. This verb is paired with `Enter`.|Pop, Out|
-|[Find](/dotnet/api/System.Management.Automation.VerbsCommon.Find) (fd)|Looks for an object in a container that is unknown, implied, optional, or specified.|Search|
-|[Get](/dotnet/api/System.Management.Automation.VerbsCommon.Get) (g)|Specifies an action that retrieves a resource. This verb is paired with `Set`.|Read, Open, Cat, Type, Dir, Obtain, Dump, Acquire, Examine, Find, Search|
-|[Hide](/dotnet/api/System.Management.Automation.VerbsCommon.Hide) (h)|Makes a resource undetectable. For example, a cmdlet whose name includes the Hide verb might conceal a service from a user. This verb is paired with `Show`.|Block|
-|[Join](/dotnet/api/System.Management.Automation.VerbsCommon.Join) (j)|Combines resources into one resource. For example, the `Join-Path` cmdlet combines a path with one of its child paths to create a single path. This verb is paired with `Split`.|Combine, Unite, Connect, Associate|
-|[Lock](/dotnet/api/System.Management.Automation.VerbsCommon.Lock) (lk)|Secures a resource. This verb is paired with `Unlock`.|Restrict, Secure|
-|[Move](/dotnet/api/System.Management.Automation.VerbsCommon.Move) (m)|Moves a resource from one location to another. For example, the `Move-Item` cmdlet moves an item from one location in the data store to another location.|Transfer, Name, Migrate|
-|[New](/dotnet/api/System.Management.Automation.VerbsCommon.New) (n)|Creates a resource. (The `Set` verb can also be used when creating a resource that includes data, such as the `Set-Variable` cmdlet.)|Create, Generate, Build, Make, Allocate|
-|[Open](/dotnet/api/System.Management.Automation.VerbsCommon.Open) (op)|Changes the state of a resource to make it accessible, available, or usable. This verb is paired with `Close`.||
-|[Optimize](/dotnet/api/System.Management.Automation.VerbsCommon.Optimize) (om)|Increases the effectiveness of a resource.||
-|[Pop](/dotnet/api/System.Management.Automation.VerbsCommon.Pop) (pop)|Removes an item from the top of a stack. For example, the `Pop-Location` cmdlet changes the current location to the location that was most recently pushed onto the stack.||
-|[Push](/dotnet/api/System.Management.Automation.VerbsCommon.Push) (pu)|Adds an item to the top of a stack. For example, the `Push-Location` cmdlet pushes the current location onto the stack.||
-|[Redo](/dotnet/api/System.Management.Automation.VerbsCommon.Redo) (re)|Resets a resource to the state that was undone.||
-|[Remove](/dotnet/api/System.Management.Automation.VerbsCommon.Remove) (r)|Deletes a resource from a container. For example, the `Remove-Variable` cmdlet deletes a variable and its value. This verb is paired with `Add`.|Clear, Cut, Dispose, Discard, Erase|
-|[Rename](/dotnet/api/System.Management.Automation.VerbsCommon.Rename) (rn)|Changes the name of a resource. For example, the `Rename-Item` cmdlet, which is used to access stored data, changes the name of an item in the data store.|Change|
-|[Reset](/dotnet/api/System.Management.Automation.VerbsCommon.Reset) (rs)|Sets a resource back to its original state.||
-|[Resize](/dotnet/api/System.Management.Automation.VerbsCommon.Resize)(rz)|Changes the size of a resource.||
-|[Search](/dotnet/api/System.Management.Automation.VerbsCommon.Search) (sr)|Creates a reference to a resource in a container.|Find, Locate|
-|[Select](/dotnet/api/System.Management.Automation.VerbsCommon.Select) (sc)|Locates a resource in a container. For example, the `Select-String` cmdlet finds text in strings and files.|Find, Locate|
-|[Set](/dotnet/api/System.Management.Automation.VerbsCommon.Set) (s)|Replaces data on an existing resource or creates a resource that contains some data. For example, the `Set-Date` cmdlet changes the system time on the local computer. (The `New` verb can also be used to create a resource.) This verb is paired with `Get`.|Write, Reset, Assign, Configure|
-|[Show](/dotnet/api/System.Management.Automation.VerbsCommon.Show) (sh)|Makes a resource visible to the user. This verb is paired with `Hide`.|Display, Produce|
-|[Skip](/dotnet/api/System.Management.Automation.VerbsCommon.Skip) (sk)|Bypasses one or more resources or points in a sequence.|Bypass, Jump|
-|[Split](/dotnet/api/System.Management.Automation.VerbsCommon.Split) (sl)|Separates parts of a resource. For example, the `Split-Path` cmdlet returns different parts of a path. This verb is paired with `Join`.|Separate|
-|[Step](/dotnet/api/System.Management.Automation.VerbsCommon.Step) (st)|Moves to the next point or resource in a sequence.||
-|[Switch](/dotnet/api/System.Management.Automation.VerbsCommon.Switch) (sw)|Specifies an action that alternates between two resources, such as to change between two locations, responsibilities, or states.||
-|[Undo](/dotnet/api/System.Management.Automation.VerbsCommon.Undo) (un)|Sets a resource to its previous state.||
-|[Unlock](/dotnet/api/System.Management.Automation.VerbsCommon.Unlock) (uk)|Releases a resource that was locked. This verb is paired with `Lock`.|Release, Unrestrict, Unsecure|
-|[Watch](/dotnet/api/System.Management.Automation.VerbsCommon.Watch) (wc)|Continually inspects or monitors a resource for changes.||
+| Verb (alias) | Action | Synonyms to avoid |
+| ------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
+| [Add](/dotnet/api/System.Management.Automation.VerbsCommon.Add) (a) | Adds a resource to a container, or attaches an item to another item. For example, the `Add-Content` cmdlet adds content to a file. This verb is paired with `Remove`. | Append, Attach, Concatenate, Insert |
+| [Clear](/dotnet/api/System.Management.Automation.VerbsCommon.Clear) (cl) | Removes all the resources from a container but does not delete the container. For example, the `Clear-Content` cmdlet removes the contents of a file but does not delete the file. | Flush, Erase, Release, Unmark, Unset, Nullify |
+| [Close](/dotnet/api/System.Management.Automation.VerbsCommon.Close) (cs) | Changes the state of a resource to make it inaccessible, unavailable, or unusable. This verb is paired with `Open.` | |
+| [Copy](/dotnet/api/System.Management.Automation.VerbsCommon.Copy) (cp) | Copies a resource to another name or to another container. For example, the `Copy-Item` cmdlet copies an item (such as a file) from one location in the data store to another location. | Duplicate, Clone, Replicate, Sync |
+| [Enter](/dotnet/api/System.Management.Automation.VerbsCommon.Enter) (et) | Specifies an action that allows the user to move into a resource. For example, the `Enter-PSSession` cmdlet places the user in an interactive session. This verb is paired with `Exit`. | Push, Into |
+| [Exit](/dotnet/api/System.Management.Automation.VerbsCommon.Exit) (ex) | Sets the current environment or context to the most recently used context. For example, the `Exit-PSSession` cmdlet places the user in the session that was used to start the interactive session. This verb is paired with `Enter`. | Pop, Out |
+| [Find](/dotnet/api/System.Management.Automation.VerbsCommon.Find) (fd) | Looks for an object in a container that is unknown, implied, optional, or specified. | Search |
+| [Format](/dotnet/api/System.Management.Automation.VerbsCommon.Format) (f) | Arranges objects in a specified form or layout | |
+| [Get](/dotnet/api/System.Management.Automation.VerbsCommon.Get) (g) | Specifies an action that retrieves a resource. This verb is paired with `Set`. | Read, Open, Cat, Type, Dir, Obtain, Dump, Acquire, Examine, Find, Search |
+| [Hide](/dotnet/api/System.Management.Automation.VerbsCommon.Hide) (h) | Makes a resource undetectable. For example, a cmdlet whose name includes the Hide verb might conceal a service from a user. This verb is paired with `Show`. | Block |
+| [Join](/dotnet/api/System.Management.Automation.VerbsCommon.Join) (j) | Combines resources into one resource. For example, the `Join-Path` cmdlet combines a path with one of its child paths to create a single path. This verb is paired with `Split`. | Combine, Unite, Connect, Associate |
+| [Lock](/dotnet/api/System.Management.Automation.VerbsCommon.Lock) (lk) | Secures a resource. This verb is paired with `Unlock`. | Restrict, Secure |
+| [Move](/dotnet/api/System.Management.Automation.VerbsCommon.Move) (m) | Moves a resource from one location to another. For example, the `Move-Item` cmdlet moves an item from one location in the data store to another location. | Transfer, Name, Migrate |
+| [New](/dotnet/api/System.Management.Automation.VerbsCommon.New) (n) | Creates a resource. (The `Set` verb can also be used when creating a resource that includes data, such as the `Set-Variable` cmdlet.) | Create, Generate, Build, Make, Allocate |
+| [Open](/dotnet/api/System.Management.Automation.VerbsCommon.Open) (op) | Changes the state of a resource to make it accessible, available, or usable. This verb is paired with `Close`. | |
+| [Optimize](/dotnet/api/System.Management.Automation.VerbsCommon.Optimize) (om) | Increases the effectiveness of a resource. | |
+| [Pop](/dotnet/api/System.Management.Automation.VerbsCommon.Pop) (pop) | Removes an item from the top of a stack. For example, the `Pop-Location` cmdlet changes the current location to the location that was most recently pushed onto the stack. | |
+| [Push](/dotnet/api/System.Management.Automation.VerbsCommon.Push) (pu) | Adds an item to the top of a stack. For example, the `Push-Location` cmdlet pushes the current location onto the stack. | |
+| [Redo](/dotnet/api/System.Management.Automation.VerbsCommon.Redo) (re) | Resets a resource to the state that was undone. | |
+| [Remove](/dotnet/api/System.Management.Automation.VerbsCommon.Remove) (r) | Deletes a resource from a container. For example, the `Remove-Variable` cmdlet deletes a variable and its value. This verb is paired with `Add`. | Clear, Cut, Dispose, Discard, Erase |
+| [Rename](/dotnet/api/System.Management.Automation.VerbsCommon.Rename) (rn) | Changes the name of a resource. For example, the `Rename-Item` cmdlet, which is used to access stored data, changes the name of an item in the data store. | Change |
+| [Reset](/dotnet/api/System.Management.Automation.VerbsCommon.Reset) (rs) | Sets a resource back to its original state. | |
+| [Resize](/dotnet/api/System.Management.Automation.VerbsCommon.Resize)(rz) | Changes the size of a resource. | |
+| [Search](/dotnet/api/System.Management.Automation.VerbsCommon.Search) (sr) | Creates a reference to a resource in a container. | Find, Locate |
+| [Select](/dotnet/api/System.Management.Automation.VerbsCommon.Select) (sc) | Locates a resource in a container. For example, the `Select-String` cmdlet finds text in strings and files. | Find, Locate |
+| [Set](/dotnet/api/System.Management.Automation.VerbsCommon.Set) (s) | Replaces data on an existing resource or creates a resource that contains some data. For example, the `Set-Date` cmdlet changes the system time on the local computer. (The `New` verb can also be used to create a resource.) This verb is paired with `Get`. | Write, Reset, Assign, Configure |
+| [Show](/dotnet/api/System.Management.Automation.VerbsCommon.Show) (sh) | Makes a resource visible to the user. This verb is paired with `Hide`. | Display, Produce |
+| [Skip](/dotnet/api/System.Management.Automation.VerbsCommon.Skip) (sk) | Bypasses one or more resources or points in a sequence. | Bypass, Jump |
+| [Split](/dotnet/api/System.Management.Automation.VerbsCommon.Split) (sl) | Separates parts of a resource. For example, the `Split-Path` cmdlet returns different parts of a path. This verb is paired with `Join`. | Separate |
+| [Step](/dotnet/api/System.Management.Automation.VerbsCommon.Step) (st) | Moves to the next point or resource in a sequence. | |
+| [Switch](/dotnet/api/System.Management.Automation.VerbsCommon.Switch) (sw) | Specifies an action that alternates between two resources, such as to change between two locations, responsibilities, or states. | |
+| [Undo](/dotnet/api/System.Management.Automation.VerbsCommon.Undo) (un) | Sets a resource to its previous state. | |
+| [Unlock](/dotnet/api/System.Management.Automation.VerbsCommon.Unlock) (uk) | Releases a resource that was locked. This verb is paired with `Lock`. | Release, Unrestrict, Unsecure |
+| [Watch](/dotnet/api/System.Management.Automation.VerbsCommon.Watch) (wc) | Continually inspects or monitors a resource for changes. | |
## Communications Verbs
PowerShell uses the
class to define actions that apply to communications. The following table lists most of the defined verbs.
-|Verb (alias)|Action|Synonyms to avoid|
-|--------------------|------------|--------------|
-|[Connect](/dotnet/api/System.Management.Automation.VerbsCommunications.Connect) (cc)|Creates a link between a source and a destination. This verb is paired with `Disconnect`.|Join, Telnet|
-|[Disconnect](/dotnet/api/System.Management.Automation.VerbsCommunications.Disconnect) (dc)|Breaks the link between a source and a destination. This verb is paired with `Connect`.|Break, Logoff|
-|[Read](/dotnet/api/System.Management.Automation.VerbsCommunications.Read) (rd)|Acquires information from a source. This verb is paired with `Write`.|Acquire, Prompt, Get|
-|[Receive](/dotnet/api/System.Management.Automation.VerbsCommunications.Receive) (rc)|Accepts information sent from a source. This verb is paired with `Send`.|Read, Accept, Peek|
-|[Send](/dotnet/api/System.Management.Automation.VerbsCommunications.Send) (sd)|Delivers information to a destination. This verb is paired with `Receive`.|Put, Broadcast, Mail, Fax|
-|[Write](/dotnet/api/System.Management.Automation.VerbsCommunications.Write) (wr)|Adds information to a target. This verb is paired with `Read`.|Put, Print|
+| Verb (alias) | Action | Synonyms to avoid |
+| ------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------- | ------------------------- |
+| [Connect](/dotnet/api/System.Management.Automation.VerbsCommunications.Connect) (cc) | Creates a link between a source and a destination. This verb is paired with `Disconnect`. | Join, Telnet |
+| [Disconnect](/dotnet/api/System.Management.Automation.VerbsCommunications.Disconnect) (dc) | Breaks the link between a source and a destination. This verb is paired with `Connect`. | Break, Logoff |
+| [Read](/dotnet/api/System.Management.Automation.VerbsCommunications.Read) (rd) | Acquires information from a source. This verb is paired with `Write`. | Acquire, Prompt, Get |
+| [Receive](/dotnet/api/System.Management.Automation.VerbsCommunications.Receive) (rc) | Accepts information sent from a source. This verb is paired with `Send`. | Read, Accept, Peek |
+| [Send](/dotnet/api/System.Management.Automation.VerbsCommunications.Send) (sd) | Delivers information to a destination. This verb is paired with `Receive`. | Put, Broadcast, Mail, Fax |
+| [Write](/dotnet/api/System.Management.Automation.VerbsCommunications.Write) (wr) | Adds information to a target. This verb is paired with `Read`. | Put, Print |
## Data Verbs
PowerShell uses the
[System.Management.Automation.VerbsData](/dotnet/api/System.Management.Automation.VerbsData) class to define actions that apply to data handling. The following table lists most of the defined verbs.
-|Verb Name (alias)|Action|Synonyms to avoid|
-|-------------------------|------------|--------------|
-|[Backup](/dotnet/api/System.Management.Automation.VerbsData.Backup) (ba)|Stores data by replicating it.|Save, Burn, Replicate, Sync|
-|[Checkpoint](/dotnet/api/System.Management.Automation.VerbsData.Checkpoint) (ch)|Creates a snapshot of the current state of the data or of its configuration.|Diff|
-|[Compare](/dotnet/api/System.Management.Automation.VerbsData.Compare) (cr)|Evaluates the data from one resource against the data from another resource.|Diff|
-|[Compress](/dotnet/api/System.Management.Automation.VerbsData.Compress) (cm)|Compacts the data of a resource. Pairs with `Expand`.|Compact|
-|[Convert](/dotnet/api/System.Management.Automation.VerbsData.Convert) (cv)|Changes the data from one representation to another when the cmdlet supports bidirectional conversion or when the cmdlet supports conversion between multiple data types.|Change, Resize, Resample|
-|[ConvertFrom](/dotnet/api/System.Management.Automation.VerbsData.ConvertFrom) (cf)|Converts one primary type of input (the cmdlet noun indicates the input) to one or more supported output types.|Export, Output, Out|
-|[ConvertTo](/dotnet/api/System.Management.Automation.VerbsData.ConvertTo) (ct)|Converts from one or more types of input to a primary output type (the cmdlet noun indicates the output type).|Import, Input, In|
-|[Dismount](/dotnet/api/System.Management.Automation.VerbsData.Dismount) (dm)|Detaches a named entity from a location. This verb is paired with `Mount`.|Unmount, Unlink|
-|[Edit](/dotnet/api/System.Management.Automation.VerbsData.Edit) (ed)|Modifies existing data by adding or removing content.|Change, Update, Modify|
-|[Expand](/dotnet/api/System.Management.Automation.VerbsData.Expand) (en)|Restores the data of a resource that has been compressed to its original state. This verb is paired with `Compress`.|Explode, Uncompress|
-|[Export](/dotnet/api/System.Management.Automation.VerbsData.Export) (ep)|Encapsulates the primary input into a persistent data store, such as a file, or into an interchange format. This verb is paired with `Import`.|Extract, Backup|
-|[Import](/dotnet/api/System.Management.Automation.VerbsData.Import) (ip)|Creates a resource from data that is stored in a persistent data store (such as a file) or in an interchange format. For example, the `Import-CSV` cmdlet imports data from a comma-separated value (CSV) file to objects that can be used by other cmdlets. This verb is paired with `Export`.|BulkLoad, Load|
-|[Initialize](/dotnet/api/System.Management.Automation.VerbsData.Initialize) (in)|Prepares a resource for use, and sets it to a default state.|Erase, Init, Renew, Rebuild, Reinitialize, Setup|
-|[Limit](/dotnet/api/System.Management.Automation.VerbsData.Limit) (l)|Applies constraints to a resource.|Quota|
-|[Merge](/dotnet/api/System.Management.Automation.VerbsData.Merge) (mg)|Creates a single resource from multiple resources.|Combine, Join|
-|[Mount](/dotnet/api/System.Management.Automation.VerbsData.Mount) (mt)|Attaches a named entity to a location. This verb is paired with `Dismount`.|Connect|
-|[Out](/dotnet/api/System.Management.Automation.VerbsData.Out) (o)|Sends data out of the environment. For example, the `Out-Printer` cmdlet sends data to a printer.||
-|[Publish](/dotnet/api/System.Management.Automation.VerbsData.Publish) (pb)|Makes a resource available to others. This verb is paired with `Unpublish`.|Deploy, Release, Install|
-|[Restore](/dotnet/api/System.Management.Automation.VerbsData.Restore) (rr)|Sets a resource to a predefined state, such as a state set by `Checkpoint`. For example, the `Restore-Computer` cmdlet starts a system restore on the local computer.|Repair, Return, Undo, Fix|
-|[Save](/dotnet/api/System.Management.Automation.VerbsData.Save) (sv)|Preserves data to avoid loss.||
-|[Sync](/dotnet/api/System.Management.Automation.VerbsData.Sync) (sy)|Assures that two or more resources are in the same state.|Replicate, Coerce, Match|
-|[Unpublish](/dotnet/api/System.Management.Automation.VerbsData.Unpublish) (ub)|Makes a resource unavailable to others. This verb is paired with `Publish`.|Uninstall, Revert, Hide|
-|[Update](/dotnet/api/System.Management.Automation.VerbsData.Update) (ud)|Brings a resource up-to-date to maintain its state, accuracy, conformance, or compliance. For example, the `Update-FormatData` cmdlet updates and adds formatting files to the current PowerShell console.|Refresh, Renew, Recalculate, Re-index|
+| Verb Name (alias) | Action | Synonyms to avoid |
+| ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
+| [Backup](/dotnet/api/System.Management.Automation.VerbsData.Backup) (ba) | Stores data by replicating it. | Save, Burn, Replicate, Sync |
+| [Checkpoint](/dotnet/api/System.Management.Automation.VerbsData.Checkpoint) (ch) | Creates a snapshot of the current state of the data or of its configuration. | Diff |
+| [Compare](/dotnet/api/System.Management.Automation.VerbsData.Compare) (cr) | Evaluates the data from one resource against the data from another resource. | Diff |
+| [Compress](/dotnet/api/System.Management.Automation.VerbsData.Compress) (cm) | Compacts the data of a resource. Pairs with `Expand`. | Compact |
+| [Convert](/dotnet/api/System.Management.Automation.VerbsData.Convert) (cv) | Changes the data from one representation to another when the cmdlet supports bidirectional conversion or when the cmdlet supports conversion between multiple data types. | Change, Resize, Resample |
+| [ConvertFrom](/dotnet/api/System.Management.Automation.VerbsData.ConvertFrom) (cf) | Converts one primary type of input (the cmdlet noun indicates the input) to one or more supported output types. | Export, Output, Out |
+| [ConvertTo](/dotnet/api/System.Management.Automation.VerbsData.ConvertTo) (ct) | Converts from one or more types of input to a primary output type (the cmdlet noun indicates the output type). | Import, Input, In |
+| [Dismount](/dotnet/api/System.Management.Automation.VerbsData.Dismount) (dm) | Detaches a named entity from a location. This verb is paired with `Mount`. | Unmount, Unlink |
+| [Edit](/dotnet/api/System.Management.Automation.VerbsData.Edit) (ed) | Modifies existing data by adding or removing content. | Change, Update, Modify |
+| [Expand](/dotnet/api/System.Management.Automation.VerbsData.Expand) (en) | Restores the data of a resource that has been compressed to its original state. This verb is paired with `Compress`. | Explode, Uncompress |
+| [Export](/dotnet/api/System.Management.Automation.VerbsData.Export) (ep) | Encapsulates the primary input into a persistent data store, such as a file, or into an interchange format. This verb is paired with `Import`. | Extract, Backup |
+| [Group](/dotnet/api/System.Management.Automation.VerbsData.Group) (gp) | Arranges or associates one or more resources | |
+| [Import](/dotnet/api/System.Management.Automation.VerbsData.Import) (ip) | Creates a resource from data that is stored in a persistent data store (such as a file) or in an interchange format. For example, the `Import-CSV` cmdlet imports data from a comma-separated value (CSV) file to objects that can be used by other cmdlets. This verb is paired with `Export`. | BulkLoad, Load |
+| [Initialize](/dotnet/api/System.Management.Automation.VerbsData.Initialize) (in) | Prepares a resource for use, and sets it to a default state. | Erase, Init, Renew, Rebuild, Reinitialize, Setup |
+| [Limit](/dotnet/api/System.Management.Automation.VerbsData.Limit) (l) | Applies constraints to a resource. | Quota |
+| [Merge](/dotnet/api/System.Management.Automation.VerbsData.Merge) (mg) | Creates a single resource from multiple resources. | Combine, Join |
+| [Mount](/dotnet/api/System.Management.Automation.VerbsData.Mount) (mt) | Attaches a named entity to a location. This verb is paired with `Dismount`. | Connect |
+| [Out](/dotnet/api/System.Management.Automation.VerbsData.Out) (o) | Sends data out of the environment. For example, the `Out-Printer` cmdlet sends data to a printer. | |
+| [Publish](/dotnet/api/System.Management.Automation.VerbsData.Publish) (pb) | Makes a resource available to others. This verb is paired with `Unpublish`. | Deploy, Release, Install |
+| [Restore](/dotnet/api/System.Management.Automation.VerbsData.Restore) (rr) | Sets a resource to a predefined state, such as a state set by `Checkpoint`. For example, the `Restore-Computer` cmdlet starts a system restore on the local computer. | Repair, Return, Undo, Fix |
+| [Save](/dotnet/api/System.Management.Automation.VerbsData.Save) (sv) | Preserves data to avoid loss. | |
+| [Sync](/dotnet/api/System.Management.Automation.VerbsData.Sync) (sy) | Assures that two or more resources are in the same state. | Replicate, Coerce, Match |
+| [Unpublish](/dotnet/api/System.Management.Automation.VerbsData.Unpublish) (ub) | Makes a resource unavailable to others. This verb is paired with `Publish`. | Uninstall, Revert, Hide |
+| [Update](/dotnet/api/System.Management.Automation.VerbsData.Update) (ud) | Brings a resource up-to-date to maintain its state, accuracy, conformance, or compliance. For example, the `Update-FormatData` cmdlet updates and adds formatting files to the current PowerShell console. | Refresh, Renew, Recalculate, Re-index |
## Diagnostic Verbs
PowerShell uses the
class to define actions that apply to diagnostics. The following table lists most of the defined verbs.
-|Verb (alias)|Action|Synonyms to avoid|
-|--------------------|------------|--------------|
-|[Debug](/dotnet/api/System.Management.Automation.VerbsDiagnostic.Debug) (db)|Examines a resource to diagnose operational problems.|Diagnose|
-|[Measure](/dotnet/api/System.Management.Automation.VerbsDiagnostic.Measure) (ms)|Identifies resources that are consumed by a specified operation, or retrieves statistics about a resource.|Calculate, Determine, Analyze|
-|[Repair](/dotnet/api/System.Management.Automation.VerbsDiagnostic.Repair) (rp)|Restores a resource to a usable condition|Fix, Restore|
-|[Resolve](/dotnet/api/System.Management.Automation.VerbsDiagnostic.Resolve) (rv)|Maps a shorthand representation of a resource to a more complete representation.|Expand, Determine|
-|[Test](/dotnet/api/System.Management.Automation.VerbsDiagnostic.Test) (t)|Verifies the operation or consistency of a resource.|Diagnose, Analyze, Salvage, Verify|
-|[Trace](/dotnet/api/System.Management.Automation.VerbsDiagnostic.Trace) (tr)|Tracks the activities of a resource.|Track, Follow, Inspect, Dig|
+| Verb (alias) | Action | Synonyms to avoid |
+| -------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------- |
+| [Debug](/dotnet/api/System.Management.Automation.VerbsDiagnostic.Debug) (db) | Examines a resource to diagnose operational problems. | Diagnose |
+| [Measure](/dotnet/api/System.Management.Automation.VerbsDiagnostic.Measure) (ms) | Identifies resources that are consumed by a specified operation, or retrieves statistics about a resource. | Calculate, Determine, Analyze |
+| [Ping](/dotnet/api/System.Management.Automation.VerbsDiagnostic.Ping) (pi) | Deprecated - Use the Test verb instead. | |
+| [Repair](/dotnet/api/System.Management.Automation.VerbsDiagnostic.Repair) (rp) | Restores a resource to a usable condition | Fix, Restore |
+| [Resolve](/dotnet/api/System.Management.Automation.VerbsDiagnostic.Resolve) (rv) | Maps a shorthand representation of a resource to a more complete representation. | Expand, Determine |
+| [Test](/dotnet/api/System.Management.Automation.VerbsDiagnostic.Test) (t) | Verifies the operation or consistency of a resource. | Diagnose, Analyze, Salvage, Verify |
+| [Trace](/dotnet/api/System.Management.Automation.VerbsDiagnostic.Trace) (tr) | Tracks the activities of a resource. | Track, Follow, Inspect, Dig |
## Lifecycle Verbs
PowerShell uses the
class to define actions that apply to the lifecycle of a resource. The following table lists most of the defined verbs.
-|Verb (alias)|Action|Synonyms to avoid|
-|--------------------|------------|--------------|
-|[Approve](/dotnet/api/System.Management.Automation.VerbsLifecycle.Approve) (ap)|Confirms or agrees to the status of a resource or process.||
-|[Assert](/dotnet/api/System.Management.Automation.VerbsLifecycle.Assert) (as)|Affirms the state of a resource.|Certify|
-|[Build](/dotnet/api/System.Management.Automation.VerbsLifecycle.Build) (bd)|Creates an artifact (usually a binary or document) out of some set of input files (usually source code or declarative documents.) This verb was added in PowerShell 6.||
-|[Complete](/dotnet/api/system.management.automation.host.buffercelltype) (cp)|Concludes an operation.||
-|[Confirm](/dotnet/api/System.Management.Automation.VerbsLifecycle.Confirm) (cn)|Acknowledges, verifies, or validates the state of a resource or process.|Acknowledge, Agree, Certify, Validate, Verify|
-|[Deny](/dotnet/api/System.Management.Automation.VerbsLifecycle.Deny) (dn)|Refuses, objects, blocks, or opposes the state of a resource or process.|Block, Object, Refuse, Reject|
-|[Deploy](/dotnet/api/System.Management.Automation.VerbsLifecycle.Deploy) (dp)|Sends an application, website, or solution to a remote target[s] in such a way that a consumer of that solution can access it after deployment is complete. This verb was added in PowerShell 6.||
-|[Disable](/dotnet/api/System.Management.Automation.VerbsLifecycle.Disable) (d)|Configures a resource to an unavailable or inactive state. For example, the `Disable-PSBreakpoint` cmdlet makes a breakpoint inactive. This verb is paired with `Enable`.|Halt, Hide|
-|[Enable](/dotnet/api/System.Management.Automation.VerbsLifecycle.Enable) (e)|Configures a resource to an available or active state. For example, the `Enable-PSBreakpoint` cmdlet makes a breakpoint active. This verb is paired with `Disable`.|Start, Begin|
-|[Install](/dotnet/api/System.Management.Automation.VerbsLifecycle.Install) (is)|Places a resource in a location, and optionally initializes it. This verb is paired with `Uninstall`.|Setup|
-|[Invoke](/dotnet/api/System.Management.Automation.VerbsLifecycle.Invoke) (i)|Performs an action, such as running a command or a method.|Run, Start|
-|[Register](/dotnet/api/System.Management.Automation.VerbsLifecycle.Register) (rg)|Creates an entry for a resource in a repository such as a database. This verb is paired with `Unregister`.||
-|[Request](/dotnet/api/System.Management.Automation.VerbsLifecycle.Request) (rq)|Asks for a resource or asks for permissions.||
-|[Restart](/dotnet/api/System.Management.Automation.VerbsLifecycle.Restart) (rt)|Stops an operation and then starts it again. For example, the `Restart-Service` cmdlet stops and then starts a service.|Recycle|
-|[Resume](/dotnet/api/System.Management.Automation.VerbsLifecycle.Resume) (ru)|Starts an operation that has been suspended. For example, the `Resume-Service` cmdlet starts a service that has been suspended. This verb is paired with `Suspend`.||
-|[Start](/dotnet/api/System.Management.Automation.VerbsLifecycle.Start) (sa)|Initiates an operation. For example, the `Start-Service` cmdlet starts a service. This verb is paired with `Stop`.|Launch, Initiate, Boot|
-|[Stop](/dotnet/api/System.Management.Automation.VerbsLifecycle.Stop) (sp)|Discontinues an activity. This verb is paired with `Start`.|End, Kill, Terminate, Cancel|
-|[Submit](/dotnet/api/System.Management.Automation.VerbsLifecycle.Submit) (sb)|Presents a resource for approval.|Post|
-|[Suspend](/dotnet/api/System.Management.Automation.VerbsLifecycle.Suspend) (ss)|Pauses an activity. For example, the `Suspend-Service` cmdlet pauses a service. This verb is paired with `Resume`.|Pause|
-|[Uninstall](/dotnet/api/System.Management.Automation.VerbsLifecycle.Uninstall) (us)|Removes a resource from an indicated location. This verb is paired with `Install`.||
-|[Unregister](/dotnet/api/System.Management.Automation.VerbsLifecycle.Unregister) (ur)|Removes the entry for a resource from a repository. This verb is paired with `Register`.|Remove|
-|[Wait](/dotnet/api/System.Management.Automation.VerbsLifecycle.Wait) (w)|Pauses an operation until a specified event occurs. For example, the `Wait-Job` cmdlet pauses operations until one or more of the background jobs are complete.|Sleep, Pause|
+| Verb (alias) | Action | Synonyms to avoid |
+| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------- |
+| [Approve](/dotnet/api/System.Management.Automation.VerbsLifecycle.Approve) (ap) | Confirms or agrees to the status of a resource or process. | |
+| [Assert](/dotnet/api/System.Management.Automation.VerbsLifecycle.Assert) (as) | Affirms the state of a resource. | Certify |
+| [Build](/dotnet/api/System.Management.Automation.VerbsLifecycle.Build) (bd) | Creates an artifact (usually a binary or document) out of some set of input files (usually source code or declarative documents.) This verb was added in PowerShell 6. | |
+| [Complete](/dotnet/api/system.management.automation.host.buffercelltype) (cp) | Concludes an operation. | |
+| [Confirm](/dotnet/api/System.Management.Automation.VerbsLifecycle.Confirm) (cn) | Acknowledges, verifies, or validates the state of a resource or process. | Acknowledge, Agree, Certify, Validate, Verify |
+| [Deny](/dotnet/api/System.Management.Automation.VerbsLifecycle.Deny) (dn) | Refuses, objects, blocks, or opposes the state of a resource or process. | Block, Object, Refuse, Reject |
+| [Deploy](/dotnet/api/System.Management.Automation.VerbsLifecycle.Deploy) (dp) | Sends an application, website, or solution to a remote target[s] in such a way that a consumer of that solution can access it after deployment is complete. This verb was added in PowerShell 6. | |
+| [Disable](/dotnet/api/System.Management.Automation.VerbsLifecycle.Disable) (d) | Configures a resource to an unavailable or inactive state. For example, the `Disable-PSBreakpoint` cmdlet makes a breakpoint inactive. This verb is paired with `Enable`. | Halt, Hide |
+| [Enable](/dotnet/api/System.Management.Automation.VerbsLifecycle.Enable) (e) | Configures a resource to an available or active state. For example, the `Enable-PSBreakpoint` cmdlet makes a breakpoint active. This verb is paired with `Disable`. | Start, Begin |
+| [Install](/dotnet/api/System.Management.Automation.VerbsLifecycle.Install) (is) | Places a resource in a location, and optionally initializes it. This verb is paired with `Uninstall`. | Setup |
+| [Invoke](/dotnet/api/System.Management.Automation.VerbsLifecycle.Invoke) (i) | Performs an action, such as running a command or a method. | Run, Start |
+| [Register](/dotnet/api/System.Management.Automation.VerbsLifecycle.Register) (rg) | Creates an entry for a resource in a repository such as a database. This verb is paired with `Unregister`. | |
+| [Request](/dotnet/api/System.Management.Automation.VerbsLifecycle.Request) (rq) | Asks for a resource or asks for permissions. | |
+| [Restart](/dotnet/api/System.Management.Automation.VerbsLifecycle.Restart) (rt) | Stops an operation and then starts it again. For example, the `Restart-Service` cmdlet stops and then starts a service. | Recycle |
+| [Resume](/dotnet/api/System.Management.Automation.VerbsLifecycle.Resume) (ru) | Starts an operation that has been suspended. For example, the `Resume-Service` cmdlet starts a service that has been suspended. This verb is paired with `Suspend`. | |
+| [Start](/dotnet/api/System.Management.Automation.VerbsLifecycle.Start) (sa) | Initiates an operation. For example, the `Start-Service` cmdlet starts a service. This verb is paired with `Stop`. | Launch, Initiate, Boot |
+| [Stop](/dotnet/api/System.Management.Automation.VerbsLifecycle.Stop) (sp) | Discontinues an activity. This verb is paired with `Start`. | End, Kill, Terminate, Cancel |
+| [Submit](/dotnet/api/System.Management.Automation.VerbsLifecycle.Submit) (sb) | Presents a resource for approval. | Post |
+| [Suspend](/dotnet/api/System.Management.Automation.VerbsLifecycle.Suspend) (ss) | Pauses an activity. For example, the `Suspend-Service` cmdlet pauses a service. This verb is paired with `Resume`. | Pause |
+| [Uninstall](/dotnet/api/System.Management.Automation.VerbsLifecycle.Uninstall) (us) | Removes a resource from an indicated location. This verb is paired with `Install`. | |
+| [Unregister](/dotnet/api/System.Management.Automation.VerbsLifecycle.Unregister) (ur) | Removes the entry for a resource from a repository. This verb is paired with `Register`. | Remove |
+| [Wait](/dotnet/api/System.Management.Automation.VerbsLifecycle.Wait) (w) | Pauses an operation until a specified event occurs. For example, the `Wait-Job` cmdlet pauses operations until one or more of the background jobs are complete. | Sleep, Pause |
## Security Verbs
PowerShell uses the
[System.Management.Automation.VerbsSecurity](/dotnet/api/System.Management.Automation.VerbsSecurity) class to define actions that apply to security. The following table lists most of the defined verbs.
-|Verb (alias)|Action|Synonyms to avoid|
-|--------------------|------------|--------------|
-|[Block](/dotnet/api/System.Management.Automation.VerbsSecurity.Block) (bl)|Restricts access to a resource. This verb is paired with `Unblock`.|Prevent, Limit, Deny|
-|[Grant](/dotnet/api/System.Management.Automation.VerbsSecurity.Grant) (gr)|Allows access to a resource. This verb is paired with `Revoke`.|Allow, Enable|
-|[Protect](/dotnet/api/System.Management.Automation.VerbsSecurity.Protect) (pt)|Safeguards a resource from attack or loss. This verb is paired with `Unprotect`.|Encrypt, Safeguard, Seal|
-|[Revoke](/dotnet/api/System.Management.Automation.VerbsSecurity.Revoke) (rk)|Specifies an action that does not allow access to a resource. This verb is paired with `Grant`.|Remove, Disable|
-|[Unblock](/dotnet/api/System.Management.Automation.VerbsSecurity.Unblock) (ul)|Removes restrictions to a resource. This verb is paired with `Block`.|Clear, Allow|
-|[Unprotect](/dotnet/api/System.Management.Automation.VerbsSecurity.Unprotect) (up)|Removes safeguards from a resource that were added to prevent it from attack or loss. This verb is paired with `Protect`.|Decrypt, Unseal|
+| Verb (alias) | Action | Synonyms to avoid |
+| ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------ |
+| [Block](/dotnet/api/System.Management.Automation.VerbsSecurity.Block) (bl) | Restricts access to a resource. This verb is paired with `Unblock`. | Prevent, Limit, Deny |
+| [Grant](/dotnet/api/System.Management.Automation.VerbsSecurity.Grant) (gr) | Allows access to a resource. This verb is paired with `Revoke`. | Allow, Enable |
+| [Protect](/dotnet/api/System.Management.Automation.VerbsSecurity.Protect) (pt) | Safeguards a resource from attack or loss. This verb is paired with `Unprotect`. | Encrypt, Safeguard, Seal |
+| [Revoke](/dotnet/api/System.Management.Automation.VerbsSecurity.Revoke) (rk) | Specifies an action that does not allow access to a resource. This verb is paired with `Grant`. | Remove, Disable |
+| [Unblock](/dotnet/api/System.Management.Automation.VerbsSecurity.Unblock) (ul) | Removes restrictions to a resource. This verb is paired with `Block`. | Clear, Allow |
+| [Unprotect](/dotnet/api/System.Management.Automation.VerbsSecurity.Unprotect) (up) | Removes safeguards from a resource that were added to prevent it from attack or loss. This verb is paired with `Protect`. | Decrypt, Unseal |
## Other Verbs
PowerShell uses the
to define canonical verb names that do not fit into a specific verb name category such as the common, communications, data, lifecycle, or security verb names verbs.
-|Verb (alias)|Action|Synonyms to avoid|
-|--------------------|------------|--------------|
-|[Use](/dotnet/api/System.Management.Automation.VerbsOther.Use) (u)|Uses or includes a resource to do something.||
+| Verb (alias) | Action | Synonyms to avoid |
+| ------------------------------------------------------------------ | -------------------------------------------- | ----------------- |
+| [Use](/dotnet/api/System.Management.Automation.VerbsOther.Use) (u) | Uses or includes a resource to do something. | |
## See Also
developer Windows Powershell Host Quickstart https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/docs-conceptual/developer/hosting/windows-powershell-host-quickstart.md
--- description: Windows PowerShell Host Quickstart Previously updated : 09/12/2016 Last updated : 01/25/2022
+no-loc: [AddCommand, AddScript, AddStatement, AddParameter]
Title: Windows PowerShell Host Quickstart --- # Windows PowerShell Host Quickstart
-To host Windows PowerShell in your application, you use the [System.Management.Automation.PowerShell](/dotnet/api/System.Management.Automation.PowerShell) class.
-This class provides methods that create a pipeline of commands and then execute those commands in a runspace.
-The simplest way to create a host application is to use the default runspace.
-The default runspace contains all of the core Windows PowerShell commands.
-If you want your application to expose only a subset of the Windows PowerShell commands, you must create a custom runspace.
+To host Windows PowerShell in your application, you use the
+[System.Management.Automation.PowerShell](/dotnet/api/System.Management.Automation.PowerShell)
+class. This class provides methods that create a pipeline of commands and then execute those
+commands in a runspace. The simplest way to create a host application is to use the default
+runspace. The default runspace contains all of the core Windows PowerShell commands. If you want
+your application to expose only a subset of the Windows PowerShell commands, you must create a
+custom runspace.
## Using the default runspace
-To start, we'll use the default runspace, and use the methods of the [System.Management.Automation.PowerShell](/dotnet/api/System.Management.Automation.PowerShell) class to add commands, parameters, statements, and scripts to a pipeline.
+To start, we'll use the default runspace, and use the methods of the
+[System.Management.Automation.PowerShell](/dotnet/api/System.Management.Automation.PowerShell) class
+to add commands, parameters, statements, and scripts to a pipeline.
### AddCommand
-You use the [System.Management.Automation.Powershell.AddCommand](/dotnet/api/System.Management.Automation.PowerShell.AddCommand) method to add commands to the pipeline.
-For example, suppose you want to get the list of running processes on the machine.
-The way to run this command is as follows.
+You use the
+[System.Management.Automation.PowerShell.AddCommand](/dotnet/api/System.Management.Automation.PowerShell.AddCommand)
+method to add commands to the pipeline. For example, suppose you want to get the list of running
+processes on the machine. The way to run this command is as follows.
-1. Create a [System.Management.Automation.PowerShell](/dotnet/api/System.Management.Automation.PowerShell) object.
+1. Create a
+ [System.Management.Automation.PowerShell](/dotnet/api/System.Management.Automation.PowerShell)
+ object.
```csharp PowerShell ps = PowerShell.Create(); ```
-2. Add the command that you want to execute.
+1. Add the command that you want to execute.
```csharp ps.AddCommand("Get-Process"); ```
-3. Invoke the command.
+1. Invoke the command.
```csharp ps.Invoke(); ```
-If you call the AddCommand method more than once before you call the [System.Management.Automation.Powershell.Invoke](/dotnet/api/System.Management.Automation.PowerShell.Invoke) method, the result of the first command is piped to the second, and so on.
-If you do not want to pipe the result of a previous command to a command, add it by calling the [System.Management.Automation.Powershell.AddStatement](/dotnet/api/System.Management.Automation.PowerShell.AddStatement) instead.
+If you call the AddCommand method more than once before you call the
+[System.Management.Automation.PowerShell.Invoke](/dotnet/api/System.Management.Automation.PowerShell.Invoke)
+method, the result of the first command is piped to the second, and so on. If you do not want to
+pipe the result of a previous command to a command, add it by calling the
+[System.Management.Automation.PowerShell.AddStatement](/dotnet/api/System.Management.Automation.PowerShell.AddStatement)
+instead.
### AddParameter
-The previous example executes a single command without any parameters.
-You can add parameters to the command by using the [System.Management.Automation.PSCommand.AddParameter](/dotnet/api/System.Management.Automation.PSCommand.AddParameter) method.
-For example, the following code gets a list of all of the processes that are named `PowerShell` running on the machine.
+The previous example executes a single command without any parameters. You can add parameters to the
+command by using the
+[System.Management.Automation.PSCommand.AddParameter](/dotnet/api/System.Management.Automation.PSCommand.AddParameter)
+method. For example, the following code gets a list of all of the processes that are named
+`PowerShell` running on the machine.
```csharp PowerShell.Create().AddCommand("Get-Process")
PowerShell.Create().AddCommand("Get-Process")
You can add additional parameters by calling the AddParameter method repeatedly.
-```csharp
+```csharp
PowerShell.Create().AddCommand("Get-ChildItem") .AddParameter("Path", @"c:\Windows") .AddParameter("Filter", "*.exe") .Invoke(); ```
-You can also add a dictionary of parameter names and values by calling the [System.Management.Automation.PowerShell.AddParameters](/dotnet/api/System.Management.Automation.PowerShell.AddParameters) method.
+You can also add a dictionary of parameter names and values by calling the
+[System.Management.Automation.PowerShell.AddParameters](/dotnet/api/System.Management.Automation.PowerShell.AddParameters)
+method.
```csharp IDictionary parameters = new Dictionary<String, String>();
PowerShell.Create().AddCommand("Get-Process")
### AddStatement
-You can simulate batching by using the [System.Management.Automation.PowerShell.AddStatement](/dotnet/api/System.Management.Automation.PowerShell.AddStatement) method, which adds an additional statement to the end of the pipeline.
-The following code gets a list of running processes with the name `PowerShell`, and then gets the list of running services.
+You can simulate batching by using the
+[System.Management.Automation.PowerShell.AddStatement](/dotnet/api/System.Management.Automation.PowerShell.AddStatement)
+method, which adds an additional statement to the end of the pipeline. The following code gets a
+list of running processes with the name `PowerShell`, and then gets the list of running services.
```csharp PowerShell ps = PowerShell.Create();
ps.Invoke();
### AddScript
-You can run an existing script by calling the [System.Management.Automation.PowerShell.AddScript](/dotnet/api/System.Management.Automation.PowerShell.AddScript) method.
-The following example adds a script to the pipeline and runs it.
-This example assumes there is already a script named `MyScript.ps1` in a folder named `D:\PSScripts`.
+You can run an existing script by calling the
+[System.Management.Automation.PowerShell.AddScript](/dotnet/api/System.Management.Automation.PowerShell.AddScript)
+method. The following example adds a script to the pipeline and runs it. This example assumes there
+is already a script named `MyScript.ps1` in a folder named `D:\PSScripts`.
```csharp PowerShell ps = PowerShell.Create(); ps.AddScript("D:\PSScripts\MyScript.ps1").Invoke(); ```
-There is also a version of the AddScript method that takes a boolean parameter named `useLocalScope`.
-If this parameter is set to `true`, then the script is run in the local scope.
-The following code will run the script in the local scope.
+There is also a version of the AddScript method that takes a boolean parameter named
+`useLocalScope`. If this parameter is set to `true`, then the script is run in the local scope. The
+following code will run the script in the local scope.
```csharp PowerShell ps = PowerShell.Create();
ps.AddScript(@"D:\PSScripts\MyScript.ps1", true).Invoke();
## Creating a custom runspace
-While the default runspace used in the previous examples loads all of the core Windows PowerShell commands, you can create a custom runspace that loads only a specified subset of all commands.
-You might want to do this to improve performance (loading a larger number of commands is a performance hit), or to restrict the capability of the user to perform operations.
-A runspace that exposes only a limited number of commands is called a constrained runspace.
-To create a constrained runspace, you use the [System.Management.Automation.Runspaces.Runspace](/dotnet/api/System.Management.Automation.Runspaces.Runspace) and [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) classes.
+While the default runspace used in the previous examples loads all of the core Windows PowerShell
+commands, you can create a custom runspace that loads only a specified subset of all commands. You
+might want to do this to improve performance (loading a larger number of commands is a performance
+hit), or to restrict the capability of the user to perform operations. A runspace that exposes only
+a limited number of commands is called a constrained runspace. To create a constrained runspace, you
+use the
+[System.Management.Automation.Runspaces.Runspace](/dotnet/api/System.Management.Automation.Runspaces.Runspace)
+and
+[System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState)
+classes.
### Creating an InitialSessionState object
-To create a custom runspace, you must first create an [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object.
-In the following example, we use the [System.Management.Automation.Runspaces.RunspaceFactory](/dotnet/api/System.Management.Automation.Runspaces.RunspaceFactory) to create a runspace after creating a default InitialSessionState object.
+To create a custom runspace, you must first create an
+[System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState)
+object. In the following example, we use the
+[System.Management.Automation.Runspaces.RunspaceFactory](/dotnet/api/System.Management.Automation.Runspaces.RunspaceFactory)
+to create a runspace after creating a default InitialSessionState object.
```csharp InitialSessionState iss = InitialSessionState.CreateDefault();
ps.Invoke();
### Constraining the runspace
-In the previous example, we created a default [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object that loads all of the built-in core Windows PowerShell.
-We could also have called the [System.Management.Automation.Runspaces.InitialSessionState.CreateDefault2](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState.CreateDefault2) method to create an InitialSessionState object that would load only the commands in the Microsoft.PowerShell.Core snapin.
-To create a more constrained runspace, you must create an empty InitialSessionState object by calling the [System.Management.Automation.Runspaces.InitialSessionState.Create](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState.Create) method, and then add commands to the InitialSessionState.
-
-Using a runspace that loads only the commands that you specify provides significantly improved performance.
-
-You use the methods of the [System.Management.Automation.Runspaces.SessionStateCmdletEntry](/dotnet/api/System.Management.Automation.Runspaces.SessionStateCmdletEntry) class to define cmdlets for the initial session state.
-The following example creates an empty initial session state, then defines and adds the `Get-Command` and `Import-Module` commands to the initial session state.
-We then create a runspace constrained by that initial session state, and execute the commands in that runspace.
+In the previous example, we created a default
+[System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState)
+object that loads all of the built-in core Windows PowerShell. We could also have called the
+[System.Management.Automation.Runspaces.InitialSessionState.CreateDefault2](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState.CreateDefault2)
+method to create an InitialSessionState object that would load only the commands in the
+Microsoft.PowerShell.Core snapin. To create a more constrained runspace, you must create an empty
+InitialSessionState object by calling the
+[System.Management.Automation.Runspaces.InitialSessionState.Create](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState.Create)
+method, and then add commands to the InitialSessionState.
+
+Using a runspace that loads only the commands that you specify provides significantly improved
+performance.
+
+You use the methods of the
+[System.Management.Automation.Runspaces.SessionStateCmdletEntry](/dotnet/api/System.Management.Automation.Runspaces.SessionStateCmdletEntry)
+class to define cmdlets for the initial session state. The following example creates an empty
+initial session state, then defines and adds the `Get-Command` and `Import-Module` commands to the
+initial session state. We then create a runspace constrained by that initial session state, and
+execute the commands in that runspace.
Create the initial session state.
Define and add commands to the initial session state.
```csharp SessionStateCmdletEntry getCommand = new SessionStateCmdletEntry(
- "Get-Command", typeof(Microsoft.PowerShell.Commands.GetCommandCommand), "");
+ "Get-Command", typeof(Microsoft.PowerShell.Commands.GetCommandCommand), "");
SessionStateCmdletEntry importModule = new SessionStateCmdletEntry(
- "Import-Module", typeof(Microsoft.PowerShell.Commands.ImportModuleCommand), "");
+ "Import-Module", typeof(Microsoft.PowerShell.Commands.ImportModuleCommand), "");
iss.Commands.Add(getCommand); iss.Commands.Add(importModule); ```
ps.AddCommand("Get-Command");
Collection<CommandInfo> result = ps.Invoke<CommandInfo>(); foreach (var entry in result) {
- Console.WriteLine(entry.Name);
+ Console.WriteLine(entry.Name);
} ```