Skip to content

Commit 83832b3

Browse files
authored
Markdown and PS Styles (#11731)
1 parent 654f7e0 commit 83832b3

25 files changed

+497
-446
lines changed

reference/7.5/Microsoft.PowerShell.Core/About/about_PSSession_Details.md

Lines changed: 128 additions & 130 deletions
Large diffs are not rendered by default.

reference/7.5/Microsoft.PowerShell.Core/About/about_PSSessions.md

Lines changed: 71 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ title: about_PSSessions
1010

1111
## Short description
1212

13-
Describes PowerShell sessions (PSSessions) and explains how to
14-
establish a persistent connection to a remote computer.
13+
Describes PowerShell sessions (PSSessions) and explains how to establish a
14+
persistent connection to a remote computer.
1515

1616
## Long description
1717

1818
To run PowerShell commands on a remote computer, you can use the
19-
**ComputerName** parameter of a cmdlet, or you can create a PowerShell
20-
session (PSSession) and run commands in the PSSession.
19+
**ComputerName** parameter of a cmdlet, or you can create a PowerShell session
20+
(PSSession) and run commands in the PSSession.
2121

22-
When you create a PSSession, PowerShell establishes a persistent
23-
connection to the remote computer. Use a PSSession to run a series of related
24-
commands on a remote computer. Commands that run in the same PSSession can
25-
share data, such as the values of variables, aliases, and functions.
22+
When you create a PSSession, PowerShell establishes a persistent connection to
23+
the remote computer. Use a PSSession to run a series of related commands on a
24+
remote computer. Commands that run in the same PSSession can share data, such
25+
as the values of variables, aliases, and functions.
2626

2727
You can also create a PSSession on the local computer and run commands in it.
28-
A local PSSession uses the PowerShell remoting infrastructure to
29-
create and maintain the PSSession.
28+
A local PSSession uses the PowerShell remoting infrastructure to create and
29+
maintain the PSSession.
3030

3131
Beginning in Windows PowerShell 3.0, PSSessions on Windows are independent
3232
of the sessions in which they are created. Active PSSessions are maintained
@@ -36,36 +36,33 @@ on a remote Windows computer and reconnect to it at a later time from the
3636
same computer or from a different Windows computer.
3737

3838
This topic explains how to create, use, get, and delete PSSessions. For more
39-
advanced information, see
40-
[about_PSSession_Details](about_PSSession_Details.md).
39+
advanced information, see [about_PSSession_Details][01].
4140

42-
Note: PSSessions use the PowerShell remoting infrastructure. To use
43-
PSSessions, the local and remote computers must be configured for remoting.
44-
For more information, see
45-
[about_Remote_Requirements](about_Remote_Requirements.md).
41+
Note: PSSessions use the PowerShell remoting infrastructure. To use PSSessions,
42+
the local and remote computers must be configured for remoting. For more
43+
information, see [about_Remote_Requirements][02].
4644

4745
In Windows Vista and later versions of Windows, to create a PSSession on a
48-
local computer, you must start PowerShell with the "Run as
49-
administrator" option.
46+
local computer, you must start PowerShell with the "Run as administrator"
47+
option.
5048

5149
## What Is a Session?
5250

5351
A session is an environment in which PowerShell runs.
5452

55-
Each time you start PowerShell, a session is created for you, and you
56-
can run commands in the session. You can also add items to your session, such
57-
as modules and snap-ins, and you can create items, such as variables,
58-
functions, and aliases. These items exist only in the session and are deleted
59-
when the session ends.
60-
61-
You can also create user-managed sessions, known as " PowerShell
62-
sessions" or "PSSessions," on the local computer or on a remote computer. Like
63-
the default session, you can run commands in a PSSession and add and create
64-
items. However, unlike the session that starts automatically, you can control
65-
the PSSessions that you create. You can get, create, configure, and remove
66-
them, disconnect and reconnect to them, and run multiple commands in the same
67-
PSSession. The PSSession remains available until you delete it or it times
68-
out.
53+
Each time you start PowerShell, a session is created for you, and you can run
54+
commands in the session. You can also add items to your session, such as
55+
modules and snap-ins, and you can create items, such as variables, functions,
56+
and aliases. These items exist only in the session and are deleted when the
57+
session ends.
58+
59+
You can also create user-managed sessions, known as "PowerShell sessions" or
60+
"PSSessions," on the local computer or on a remote computer. Like the default
61+
session, you can run commands in a PSSession and add and create items.
62+
However, unlike the session that starts automatically, you can control the
63+
PSSessions that you create. You can get, create, configure, and remove them,
64+
disconnect and reconnect to them, and run multiple commands in the same
65+
PSSession. The PSSession remains available until you delete it or it times out.
6966

7067
Typically, you create a PSSession to run a series of related commands on a
7168
remote computer. When you create a PSSession on a remote computer, PowerShell
@@ -74,15 +71,14 @@ session.
7471

7572
If you use the **ComputerName** parameter of the `Invoke-Command` or
7673
`Enter-PSSession` cmdlet to run a remote command or to start an interactive
77-
session, PowerShell creates a temporary session on the remote computer
78-
and closes the session as soon as the command is complete or as soon as the
74+
session, PowerShell creates a temporary session on the remote computer and
75+
closes the session as soon as the command is complete or as soon as the
7976
interactive session ends. You cannot control these temporary sessions, and you
80-
cannot use them for more than a single command or a single interactive
81-
session.
77+
cannot use them for more than a single command or a single interactive session.
8278

83-
In PowerShell, the "current session" is the session that you are
84-
working in. The "current session" can refer to any session, including a
85-
temporary session or a PSSession.
79+
In PowerShell, the "current session" is the session that you are working in.
80+
The "current session" can refer to any session, including a temporary session
81+
or a PSSession.
8682

8783
## Why Use a PSSession?
8884

@@ -96,10 +92,9 @@ You can run remote commands without creating a PSSession. Use the
9692
or a series of unrelated commands on one or many computers.
9793

9894
When you use the **ComputerName** parameter of `Invoke-Command` or
99-
`Enter-PSSession`, PowerShell establishes a temporary connection to
100-
the remote computer and then closes the connection as soon as the command is
101-
complete. Any data elements that you create are lost when the connection is
102-
closed.
95+
`Enter-PSSession`, PowerShell establishes a temporary connection to the remote
96+
computer and then closes the connection as soon as the command is complete.
97+
Any data elements that you create are lost when the connection is closed.
10398

10499
Other cmdlets that have a **ComputerName** parameter, such as `Get-Eventlog`
105100
and `Get-WmiObject`, use different remoting technologies to gather data. None
@@ -108,8 +103,8 @@ create a persistent connection like a PSSession.
108103
## How to Create a PSSession
109104

110105
To create a PSSession, use the `New-PSSession` cmdlet. To create the PSSession
111-
on a remote computer, use the **ComputerName** parameter of the
112-
`New-PSSession` cmdlet.
106+
on a remote computer, use the **ComputerName** parameter of the `New-PSSession`
107+
cmdlet.
113108

114109
For example, the following command creates a new PSSession on the Server01
115110
computer.
@@ -151,7 +146,8 @@ To get the PSSessions that were created in your current session, use the
151146
`Get-PSSession` cmdlet without the **ComputerName** parameter. `Get-PSSession`
152147
returns the same type of object that `New-PSSession` returns.
153148

154-
The following command gets all the PSSessions that were created in the current session.
149+
The following command gets all the PSSessions that were created in the current
150+
session.
155151

156152
```powershell
157153
Get-PSSession
@@ -239,7 +235,7 @@ until it times out.
239235

240236
You can also use the **IdleTimeout** parameter of the `New-PSSessionOption`
241237
cmdlet to set an expiration time for an idle PSSession. For more information,
242-
see [New-PSSessionOption](xref:Microsoft.PowerShell.Core.New-PSSessionOption).
238+
see [New-PSSessionOption][03].
243239

244240
## The PSSession Cmdlets
245241

@@ -263,22 +259,37 @@ Get-Help *-PSSession
263259
> Disconnected sessions are only supported on Windows. The `Connect-PSSession`,
264260
> `Disconnect-PSSession`, and `Receive-PSSession` cmdlets are only available
265261
> on Windows. For more information about disconnected sessions, see
266-
> [about_Remote_Disconnected_Session](about_Remote_Disconnected_Sessions.md)
262+
> [about_Remote_Disconnected_Session][04].
267263
268264
## For More Information
269265

270-
For more information about PSSessions, see [about_PSSession_Details](about_PSSession_Details.md).
266+
For more information about PSSessions, see [about_PSSession_Details][01].
271267

272268
## See also
273269

274-
- [about_Remote](about_Remote.md)
275-
- [about_Remote_Disconnected_Sessions](about_Remote_Disconnected_Sessions.md)
276-
- [about_Remote_Requirements](about_Remote_Requirements.md)
277-
- [Invoke-Command](xref:Microsoft.PowerShell.Core.Invoke-Command)
278-
- [Connect-PSSession](xref:Microsoft.PowerShell.Core.Connect-PSSession)
279-
- [Disconnect-PSSession](xref:Microsoft.PowerShell.Core.Disconnect-PSSession)
280-
- [Enter-PSSession](xref:Microsoft.PowerShell.Core.Enter-PSSession)
281-
- [Exit-PSSession](xref:Microsoft.PowerShell.Core.Exit-PSSession)
282-
- [Get-PSSession](xref:Microsoft.PowerShell.Core.Get-PSSession)
283-
- [New-PSSession](xref:Microsoft.PowerShell.Core.New-PSSession)
284-
- [Remove-PSSession](xref:Microsoft.PowerShell.Core.Remove-PSSession)
270+
- [about_Remote][05]
271+
- [about_Remote_Disconnected_Sessions][04]
272+
- [about_Remote_Requirements][02]
273+
- [Invoke-Command][06]
274+
- [Connect-PSSession][07]
275+
- [Disconnect-PSSession][08]
276+
- [Enter-PSSession][09]
277+
- [Exit-PSSession][10]
278+
- [Get-PSSession][11]
279+
- [New-PSSession][12]
280+
- [Remove-PSSession][13]
281+
282+
<!-- link references -->
283+
[01]: about_PSSession_Details.md
284+
[02]: about_Remote_Requirements.md
285+
[03]: xref:Microsoft.PowerShell.Core.New-PSSessionOption
286+
[04]: about_Remote_Disconnected_Sessions.md
287+
[05]: about_Remote.md
288+
[06]: xref:Microsoft.PowerShell.Core.Invoke-Command
289+
[07]: xref:Microsoft.PowerShell.Core.Connect-PSSession
290+
[08]: xref:Microsoft.PowerShell.Core.Disconnect-PSSession
291+
[09]: xref:Microsoft.PowerShell.Core.Enter-PSSession
292+
[10]: xref:Microsoft.PowerShell.Core.Exit-PSSession
293+
[11]: xref:Microsoft.PowerShell.Core.Get-PSSession
294+
[12]: xref:Microsoft.PowerShell.Core.New-PSSession
295+
[13]: xref:Microsoft.PowerShell.Core.Remove-PSSession

reference/7.5/Microsoft.PowerShell.Core/About/about_Pwsh.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ Running `pwsh -File -` without redirected standard input starts a regular
108108
session. This is the same as not specifying the `File` parameter at all. When
109109
reading from standard input, the input statements are executed one statement at
110110
a time as though they were typed at the PowerShell command prompt. If a
111-
statement doesn't parse correctly, the statement isn't executed. The process exit code is
112-
determined by status of the last (executed) command within the input. With
113-
normal termination, the exit code is always `0`. When the script file
114-
terminates with an `exit` command, the process exit code is set to the numeric
115-
argument used with the `exit` command.
111+
statement doesn't parse correctly, the statement isn't executed. The process
112+
exit code is determined by status of the last (executed) command within the
113+
input. With normal termination, the exit code is always `0`. When the script
114+
file terminates with an `exit` command, the process exit code is set to the
115+
numeric argument used with the `exit` command.
116116

117117
Similar to `-Command`, when a script-terminating error occurs, the exit code is
118118
set to `1`. However, unlike with `-Command`, when the execution is interrupted
@@ -152,7 +152,7 @@ script block curly braces are often not required in the first place when
152152
running from `cmd.exe`. To execute an inline script block defined inside a
153153
string, the [call operator][03] `&` can be used:
154154

155-
```
155+
```powershell
156156
pwsh -Command "& {Get-WinEvent -LogName security}"
157157
```
158158

@@ -289,7 +289,7 @@ For example:
289289
$command = 'dir "c:\program files" '
290290
$bytes = [System.Text.Encoding]::Unicode.GetBytes($command)
291291
$encodedCommand = [Convert]::ToBase64String($bytes)
292-
pwsh -encodedcommand $encodedCommand
292+
pwsh -EncodedCommand $encodedCommand
293293
```
294294

295295
### -ExecutionPolicy | -ex | -ep
@@ -326,7 +326,8 @@ To set up `pwsh` as the login shell on UNIX-like operating systems:
326326
- Verify that the full absolute path to `pwsh` is listed under `/etc/shells`
327327
- This path is usually something like `/usr/bin/pwsh` on Linux or
328328
`/usr/local/bin/pwsh` on macOS
329-
- With some installation methods, this entry will be added automatically at installation time
329+
- With some installation methods, this entry will be added automatically at
330+
installation time
330331
- If `pwsh` isn't present in `/etc/shells`, use an editor to append the path
331332
to `pwsh` on the last line. This requires elevated privileges to edit.
332333
- Use the [chsh][04] utility to set your current
@@ -408,7 +409,8 @@ non-Windows platforms results in an error.
408409

409410
### -Version | -v
410411

411-
Displays the version of this PowerShell executable. Additional parameters are ignored.
412+
Displays the version of this PowerShell executable. Additional parameters are
413+
ignored.
412414

413415
### -WindowStyle | -w
414416

@@ -431,6 +433,6 @@ prepend the command parameters with a hyphen (`-`), not a forward slash (`/`).
431433
<!-- link references -->
432434
[01]: /powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1&preserve-view=true
433435
[02]: about_Automatic_Variables.md#lastexitcode
434-
[03]: about_operators.md#special-operators
436+
[03]: about_Operators.md#special-operators
435437
[04]: https://linux.die.net/man/1/chsh
436438
[05]: about_Parsing.md#passing-arguments-that-contain-quote-characters

reference/7.5/Microsoft.PowerShell.Core/About/about_Quoting_Rules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ For more information about this behavior, see the [about_Parsing][03] article.
465465
[01]: #including-quote-characters-in-a-string
466466
[02]: about_Parsing.md#argument-mode
467467
[03]: about_Parsing.md#passing-arguments-that-contain-quote-characters
468-
[04]: about_preference_variables.md#ofs
468+
[04]: about_Preference_Variables.md#ofs
469469
[05]: about_Special_Characters.md
470470
[06]: https://en.wikipedia.org/wiki/Quotation_marks_in_English#Smart_quotes
471471
[07]: xref:Microsoft.PowerShell.Utility.ConvertFrom-StringData

reference/7.5/Microsoft.PowerShell.Core/About/about_Redirection.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Explains how to redirect output from PowerShell to text files.
1515
## Long description
1616

1717
By default, PowerShell sends output to the PowerShell host. Usually this is the
18-
console application. However, you can redirect the output to a text file and you
19-
can redirect error output to the regular output stream.
18+
console application. However, you can redirect the output to a text file and
19+
you can redirect error output to the regular output stream.
2020

2121
You can use the following methods to redirect output:
2222

@@ -79,8 +79,7 @@ PowerShell 7.4 changed the behavior of the redirection operators when used to
7979
redirect the **stdout** stream of a native command. The redirection operators
8080
now preserve the byte-stream data when redirecting output from a native
8181
command. PowerShell doesn't interpret the redirected data or add any additional
82-
formatting. For more information, see
83-
[Example #7](#example-7-redirecting-binary-data-from-a-native-command).
82+
formatting. For more information, see [Example #7][17].
8483

8584
## Examples
8685

@@ -134,8 +133,7 @@ file called `script.log`.
134133
### Example 5: Suppress all Write-Host and Information stream data
135134

136135
This example suppresses all information stream data. To read more about
137-
**Information** stream cmdlets, see
138-
[Write-Host][11] and
136+
**Information** stream cmdlets, see [Write-Host][11] and
139137
[Write-Information][12]
140138

141139
```powershell
@@ -154,27 +152,27 @@ particular stream. The script in this example shows how the value of
154152
```powershell
155153
$ErrorActionPreference = 'Continue'
156154
$ErrorActionPreference > log.txt
157-
get-item /not-here 2>&1 >> log.txt
155+
Get-Item /not-here 2>&1 >> log.txt
158156
159157
$ErrorActionPreference = 'SilentlyContinue'
160158
$ErrorActionPreference >> log.txt
161-
get-item /not-here 2>&1 >> log.txt
159+
Get-Item /not-here 2>&1 >> log.txt
162160
163161
$ErrorActionPreference = 'Stop'
164162
$ErrorActionPreference >> log.txt
165163
Try {
166-
get-item /not-here 2>&1 >> log.txt
164+
Get-Item /not-here 2>&1 >> log.txt
167165
}
168166
catch {
169167
"`tError caught!" >> log.txt
170168
}
171169
$ErrorActionPreference = 'Ignore'
172170
$ErrorActionPreference >> log.txt
173-
get-item /not-here 2>&1 >> log.txt
171+
Get-Item /not-here 2>&1 >> log.txt
174172
175173
$ErrorActionPreference = 'Inquire'
176174
$ErrorActionPreference >> log.txt
177-
get-item /not-here 2>&1 >> log.txt
175+
Get-Item /not-here 2>&1 >> log.txt
178176
179177
$ErrorActionPreference = 'Continue'
180178
```
@@ -387,7 +385,7 @@ used. For more information, see the `-gt` operator in
387385
[03]: about_Operators.md
388386
[04]: about_Output_Streams.md
389387
[05]: about_Path_Syntax.md
390-
[06]: about_preference_variables.md#psdefaultparametervalues
388+
[06]: about_Preference_Variables.md#psdefaultparametervalues
391389
[07]: xref:Microsoft.PowerShell.Utility.Out-File
392390
[08]: xref:Microsoft.PowerShell.Utility.Tee-Object
393391
[09]: xref:Microsoft.PowerShell.Utility.Write-Debug
@@ -398,3 +396,4 @@ used. For more information, see the `-gt` operator in
398396
[14]: xref:Microsoft.PowerShell.Utility.Write-Progress
399397
[15]: xref:Microsoft.PowerShell.Utility.Write-Verbose
400398
[16]: xref:Microsoft.PowerShell.Utility.Write-Warning
399+
[17]: #example-7-redirecting-binary-data-from-a-native-command

0 commit comments

Comments
 (0)