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
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ a certificate file in the file system directory.
At the PowerShell prompt, type:

```powershell
Get-ChildItem cert:\CurrentUser\my -CodeSigning
Get-ChildItem Cert:\CurrentUser\my -CodeSigning
```

This command uses the PowerShell Certificate provider to view information
Expand Down Expand Up @@ -241,7 +241,7 @@ To use this script, copy the following text into a text file, and name it

```powershell
## Signs a file
[cmdletbinding()]
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[string] $File
Expand All @@ -260,7 +260,7 @@ PowerShell command prompt:
$cert = Get-ChildItem Cert:\CurrentUser\My -CodeSigningCert |
Select-Object -First 1

Set-AuthenticodeSignature add-signature.ps1 $cert
Set-AuthenticodeSignature Add-Signature.ps1 $cert
```

The `Set-AuthenticodeSignature` cmdlet adds the signature to the script file as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ omit them from the command. Using aliases, you can further simplify the
commands:

```powershell
dir Cert:\LocalMachine\Root | Where FriendlyName -EQ 'Verisign'
dir Cert:\LocalMachine\Root | where FriendlyName -EQ 'Verisign'
dir Cert:\ -Recurse | foreach GetKeyAlgorithm
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ There is a vertical tab
between the words.
```

On printers or in a unix-based consoles, the vertical tab character advances to
On printers or in a Unix-based console, the vertical tab character advances to
the next line and writes the remaining output at that point.

```Output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ an array of strings.
```powershell
$array = 'Hello', 'World!'
Invoke-Command -ScriptBlock {
param([string[]]$words) $words -join ' '
param([string[]]$Words) $Words -join ' '
} -ArgumentList $array
```

Expand All @@ -142,7 +142,7 @@ Hello
```powershell
$array = 'Hello', 'World!'
Invoke-Command -ScriptBlock {
param([string[]]$words) $words -join ' '
param([string[]]$Words) $Words -join ' '
} -ArgumentList (,$array)
```

Expand Down Expand Up @@ -276,7 +276,7 @@ When you use the `Get-MyProcess` function, all unassigned parameters and
parameter values are passed to `@args`, as shown in the following commands.

```powershell
Get-MyProcess -Name PowerShell
Get-MyProcess -Name powershell
```

```Output
Expand All @@ -286,7 +286,7 @@ Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
```

```powershell
Get-MyProcess -Name PowerShell_Ise -FileVersionInfo
Get-MyProcess -Name powershell_ise -FileVersionInfo
```

```Output
Expand All @@ -302,12 +302,12 @@ passed to all instances of `@args`, as shown in the following example.
```powershell
function Get-MyCommand
{
Param ([switch]$P, [switch]$C)
param ([switch]$P, [switch]$C)
if ($P) { Get-Process @args }
if ($C) { Get-Command @args }
}

Get-MyCommand -P -C -Name PowerShell
Get-MyCommand -P -C -Name powershell
```

```Output
Expand Down
22 changes: 11 additions & 11 deletions reference/5.1/Microsoft.PowerShell.Core/About/about_Split.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ The parameter names do not appear in the command. Include only the parameter
values. The values must appear in the order specified in the syntax diagram.

```
-Split <String>
-Split (<String[]>)
<String> -Split <Delimiter>[,<Max-substrings>[,"<Options>"]]
<String> -Split {<ScriptBlock>} [,<Max-substrings>]
-split <String>
-split (<String[]>)
<String> -split <Delimiter>[,<Max-substrings>[,"<Options>"]]
<String> -split {<ScriptBlock>} [,<Max-substrings>]
```

You can substitute `-iSplit` or `-cSplit` for `-split` in any binary Split
You can substitute `-isplit` or `-csplit` for `-split` in any binary Split
statement (a Split statement that includes a delimiter or script block). The
`-iSplit` and `-split` operators are case-insensitive. The `-cSplit` operator
`-isplit` and `-split` operators are case-insensitive. The `-csplit` operator
is case-sensitive, meaning that case is considered when the delimiter rules
are applied.

Expand Down Expand Up @@ -223,15 +223,15 @@ The SimpleMatch options are:

- **SimpleMatch**: Use simple string comparison when evaluating the
delimiter. Cannot be used with RegexMatch.
- **IgnoreCase**: Forces case-insensitive matching, even if the -cSplit
- **IgnoreCase**: Forces case-insensitive matching, even if the -csplit
operator is specified.

The RegexMatch options are:

- **RegexMatch**: Use regular expression matching to evaluate the
delimiter. This is the default behavior. Cannot be used with
SimpleMatch.
- **IgnoreCase**: Forces case-insensitive matching, even if the -cSplit
- **IgnoreCase**: Forces case-insensitive matching, even if the -csplit
operator is specified.
- **CultureInvariant**: Ignores cultural differences in language when
evaluating the delimiter. Valid only with RegexMatch.
Expand Down Expand Up @@ -343,7 +343,7 @@ cury,Venus,Earth,Mars,Jupit
The following statement performs a case-sensitive split at the letter "N".

```powershell
"Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune" -cSplit 'N'
"Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune" -csplit 'N'
```

```Output
Expand Down Expand Up @@ -441,7 +441,7 @@ $a = @'
2The second line.
3The third of three lines.
'@
$a -split "^\d", 0, "multiline"
$a -split "^\d", 0, "Multiline"
```

```Output
Expand Down Expand Up @@ -480,7 +480,7 @@ can use options, such as SimpleMatch, only when the Max-substrings value is
specified.

```powershell
"This.is.a.test" -split ".", 0, "simplematch"
"This.is.a.test" -split ".", 0, "SimpleMatch"
```

```Output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ statement conditions.

```powershell
switch ("Test") {
{ $_ -is [String] } { "Found a string" }
{ $_ -is [string] } { "Found a string" }
"Test" { "This $_ executes as well" }
}
```
Expand Down Expand Up @@ -383,7 +383,7 @@ non-number is encountered, execution is terminated with the `break` keyword.
```powershell
switch (1,4,-1,3,"Hello",2,1) {
{$_ -lt 0} { continue }
{$_ -isnot [Int32]} { break }
{$_ -isnot [int32]} { break }
{$_ % 2} { "$_ is Odd" }
{-not ($_ % 2)} { "$_ is Even" }
}
Expand Down Expand Up @@ -445,7 +445,7 @@ switch -File $fileEscaped { foo { 'Foo' } }

## See also

- [about_break][03]
- [about_Break][03]
- [about_Continue][05]
- [about_If][06]
- [about_Script_Blocks][07]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ms.date: 06/13/2024
no-loc: [<kbd>Tab</kbd>, <kbd>Ctrl</kbd>, <kbd>Space</kbd>]
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_tab_expansion?view=powershell-5.1&WT.mc_id=ps-gethelp
schema: 2.0.0
title: About_tab_expansion
title: about_Tab_Expansion
---
# about_Tab_Expansion

Expand Down Expand Up @@ -77,7 +77,7 @@ You can then partially specify the path to the Active Setup log file and use
tab expansion again:

```powershell
PS> Get-Content c:\windows\acts<Tab>
PS> Get-Content C:\windows\acts<Tab>
```

When you press the <kbd>Tab</kbd> key, the command expands to:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
description: Describes the Throw keyword, which generates a terminating error.
description: Describes the `throw` keyword, which generates a terminating error.
Locale: en-US
ms.date: 08/24/2022
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_throw?view=powershell-5.1&WT.mc_id=ps-gethelp
Expand Down Expand Up @@ -80,7 +80,7 @@ throw (Get-Process pwsh)

```Output
At line:1 char:6
+ throw <<<< (get-process PowerShell)
+ throw <<<< (Get-Process powershell)
+ CategoryInfo : OperationStopped: (System.Diagnostics.Process (Pow
erShell):Process) [],
RuntimeException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ terminating errors.
## Long description

Use `try`, `catch`, and `finally` blocks to respond to or handle terminating
errors in scripts. The `Trap` statement can also be used to handle terminating
errors in scripts. The `trap` statement can also be used to handle terminating
errors in scripts. For more information, see [about_Trap][05].

A terminating error stops a statement from running. If PowerShell does not
Expand All @@ -29,8 +29,8 @@ PowerShell to monitor for errors. When an error occurs within the `try` block,
the error is first saved to the `$Error` automatic variable. PowerShell then
searches for a `catch` block to handle the error. If the `try` statement does
not have a matching `catch` block, PowerShell continues to search for an
appropriate `catch` block or `Trap` statement in the parent scopes. After a
`catch` block is completed or if no appropriate `catch` block or `Trap`
appropriate `catch` block or `trap` statement in the parent scopes. After a
`catch` block is completed or if no appropriate `catch` block or `trap`
statement is found, the `finally` block is run. If the error cannot be handled,
the error is written to the error stream.

Expand Down Expand Up @@ -134,7 +134,7 @@ two `catch` blocks:
```powershell
try {
$wc = New-Object System.Net.WebClient
$wc.DownloadFile("http://www.contoso.com/MyDoc.doc","c:\temp\MyDoc.doc")
$wc.DownloadFile("http://www.contoso.com/MyDoc.doc","C:\temp\MyDoc.doc")
} catch [System.Net.WebException],[System.IO.IOException] {
"Unable to download MyDoc.doc from http://www.contoso.com."
} catch {
Expand Down Expand Up @@ -179,12 +179,12 @@ block for the derived class before the `catch` block for the general class.

## Using Traps in a Try Catch

When a terminating error occurs in a `try` block with a `Trap` defined within
the `try` block, even if there is a matching `catch` block, the `Trap`
When a terminating error occurs in a `try` block with a `trap` defined within
the `try` block, even if there is a matching `catch` block, the `trap`
statement takes control.

If a `Trap` exists at a higher block than the `try`, and there is no matching
`catch` block within the current scope, the `Trap` will take control, even if
If a `trap` exists at a higher block than the `try`, and there is no matching
`catch` block within the current scope, the `trap` will take control, even if
any parent scope has a matching `catch` block.

## Accessing exception information
Expand Down Expand Up @@ -236,18 +236,18 @@ To free resources used by a script, add a `finally` block after the `try` and
before the script terminates or before the current block goes out of scope.

A `finally` block runs even if you use <kbd>CTRL</kbd>+<kbd>C</kbd> to stop the
script. A `finally` block also runs if an Exit keyword stops the script from
script. A `finally` block also runs if an `exit` keyword stops the script from
within a `catch` block.

In the following example, the `try` block attempts to download a file to the
`c:\temp` folder. The `catch` blocks handle errors that occur during the
`C:\temp` folder. The `catch` blocks handle errors that occur during the
download. The `finally` block disposes of the `WebClient` object and removes
the temporary file if it exists.

```powershell
try {
$wc = New-Object System.Net.WebClient
$tempFile = "c:\temp\MyDoc.doc"
$tempFile = "C:\temp\MyDoc.doc"
$wc.DownloadFile("http://www.contoso.com/MyDoc.doc",$tempFile)
} catch [System.Net.WebException],[System.IO.IOException] {
"Unable to download MyDoc.doc from http://www.contoso.com."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ PowerShell also assigns types to literal values automatically.

Numeric literals are implicitly typed by default. Numbers are typed based on
their size. For example, `42` is small enough to be stored as an **Int32** type
and `1.2` is stored as a **Double**. Integers larger than `[Int32]::MaxValue`
and `1.2` is stored as a **Double**. Integers larger than `[int32]::MaxValue`
are stored as **Int64**. While `42` can be stored as a **Byte** and `1.2` can
be stored as a **Single** type, the implicit typing uses **Int32** and
**Double** respectively. For more information, see
Expand Down Expand Up @@ -229,7 +229,7 @@ These contexts include:
PowerShell attempts to convert values passed to parameters to match the
parameter type. Type conversion of parameter values occurs in cmdlets,
functions, scripts, scriptblocks, or .NET methods where the parameter is
declared with a specific type. Declaring a parameter with the type `[object]`
declared with a specific type. Declaring a parameter with the type `[Object]`
or not defining a specific type allows any value type to be passed to a
parameter. Parameters can also have custom conversions defined by decorating
parameters with [ArgumentTransformationAttribute][17] attribute.
Expand Down Expand Up @@ -302,7 +302,7 @@ New-Object: Cannot find an overload for "Guid" and the argument count: "16".
```

PowerShell treats the `$bytes` array as a list of individual parameters even
though `$bytes` is an array of bytes and `System.Guid` has a `Guid(Byte[])`
though `$bytes` is an array of bytes and `System.Guid` has a `Guid(byte[])`
constructor.

This common code pattern is an instance of _pseudo method syntax_, which
Expand All @@ -314,7 +314,7 @@ PS> New-Object -TypeName System.Guid -ArgumentList $bytes
New-Object: Cannot find an overload for "Guid" and the argument count: "16".
```

Given that the type of **ArgumentList** is `[object[]]`, a single argument that
Given that the type of **ArgumentList** is `[Object[]]`, a single argument that
happens to be an array (of any type) binds to it _element by element_. The
workaround is to wrap `$bytes` in an outer array so that PowerShell looks for a
constructor with parameters that match the contents of the outer array.
Expand All @@ -329,8 +329,8 @@ Guid
04030201-0605-0807-090a-0b0c0d0e0f10
```

The first item of the wrapped array is our original `Byte[]` instance. That
value matches the `Guid(Byte[]]` constructor.
The first item of the wrapped array is our original `[byte[]]` instance. That
value matches the `Guid(byte[])` constructor.

An alternative to the array wrapping workaround is to use the intrinsic static
`new()` method.
Expand Down Expand Up @@ -402,7 +402,7 @@ If you want the result to be an **Int64**, you can cast the result type or
operands.

```powershell
PS> ([Int64]([int]::MaxValue + 1)).GetType().Name
PS> ([int64]([int]::MaxValue + 1)).GetType().Name
Int64
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ a certificate file in the file system directory.
At the PowerShell prompt, type:

```powershell
Get-ChildItem cert:\CurrentUser\my -CodeSigning
Get-ChildItem Cert:\CurrentUser\my -CodeSigning
```

This command uses the PowerShell Certificate provider to view information
Expand Down Expand Up @@ -243,7 +243,7 @@ To use this script, copy the following text into a text file, and name it

```powershell
## Signs a file
[cmdletbinding()]
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[string] $File
Expand All @@ -262,7 +262,7 @@ PowerShell command prompt:
$cert = Get-ChildItem Cert:\CurrentUser\My -CodeSigningCert |
Select-Object -First 1

Set-AuthenticodeSignature add-signature.ps1 $cert
Set-AuthenticodeSignature Add-Signature.ps1 $cert
```

The `Set-AuthenticodeSignature` cmdlet adds the signature to the script file as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ omit them from the command. Using aliases, you can further simplify the
commands:

```powershell
dir Cert:\LocalMachine\Root | Where FriendlyName -EQ 'Verisign'
dir Cert:\LocalMachine\Root | where FriendlyName -EQ 'Verisign'
dir Cert:\ -Recurse | foreach GetKeyAlgorithm
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ There is a vertical tab
between the words.
```

On printers or in a unix-based consoles, the vertical tab character advances to
On printers or in a Unix-based console, the vertical tab character advances to
the next line and writes the remaining output at that point.

```Output
Expand Down
Loading