Skip to content

Commit 15c991d

Browse files
Enter-PSSession - Fix example 7 description (#9128)
* Fix example 7 description Not using `-Port` parameter but infer that from the `-HostName` parameter. * Editorial changes and copy to other versions Co-authored-by: Sean Wheeler <sean.wheeler@microsoft.com>
1 parent 920e539 commit 15c991d

File tree

4 files changed

+94
-90
lines changed

4 files changed

+94
-90
lines changed

reference/5.1/Microsoft.PowerShell.Core/Enter-PSSession.md

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: System.Management.Automation.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Core
5-
ms.date: 05/15/2019
5+
ms.date: 08/16/2022
66
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/enter-pssession?view=powershell-5.1&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: Enter-PSSession
@@ -108,8 +108,10 @@ session as text.
108108

109109
The first command uses the `Enter-PSSession` cmdlet to start an interactive session with Server01, a
110110
remote computer. When the session starts, the command prompt changes to include the computer name.
111-
The second command gets the Windows PowerShell process and redirects the output to the Process.txt
112-
file. The command is submitted to the remote computer, and the file is saved on the remote computer.
111+
112+
The second command gets the PowerShell process and redirects the output to the Process.txt file. The
113+
command is submitted to the remote computer, and the file is saved on the remote computer.
114+
113115
The third command uses the **Exit** keyword to end the interactive session and close the connection.
114116
The fourth command confirms that the Process.txt file is on the remote computer. A `Get-ChildItem`
115117
("dir") command on the local computer cannot find the file.
@@ -137,7 +139,7 @@ PS C:\> Enter-PSSession -Session $s
137139
```
138140

139141
These commands use the **Session** parameter of `Enter-PSSession` to run the interactive session in
140-
an existing Windows PowerShell session (**PSSession**).
142+
an existing PowerShell session (**PSSession**).
141143

142144
### Example 4: Start an interactive session and specify the Port and Credential parameters
143145

@@ -172,8 +174,8 @@ Allows redirection of this connection to an alternate Uniform Resource Identifie
172174
redirection is not allowed.
173175

174176
When you use the **ConnectionURI** parameter, the remote destination can return an instruction to
175-
redirect to a different URI. By default, Windows PowerShell does not redirect connections, but you
176-
can use this parameter to allow it to redirect the connection.
177+
redirect to a different URI. By default, PowerShell does not redirect connections, but you can use
178+
this parameter to allow it to redirect the connection.
177179

178180
You can also limit the number of times the connection is redirected by changing the
179181
**MaximumConnectionRedirectionCount** session option value. Use the **MaximumRedirection** parameter
@@ -187,7 +189,7 @@ Aliases:
187189

188190
Required: False
189191
Position: Named
190-
Default value: None
192+
Default value: False
191193
Accept pipeline input: False
192194
Accept wildcard characters: False
193195
```
@@ -239,11 +241,12 @@ of the Windows operating system.
239241
For more information about the values of this parameter, see
240242
[AuthenticationMechanism Enum](/dotnet/api/system.management.automation.runspaces.authenticationmechanism).
241243

242-
Caution: Credential Security Support Provider (CredSSP) authentication, in which the user's
243-
credentials are passed to a remote computer to be authenticated, is designed for commands that
244-
require authentication on more than one resource, such as accessing a remote network share. This
245-
mechanism increases the security risk of the remote operation. If the remote computer is
246-
compromised, the credentials that are passed to it can be used to control the network session.
244+
> [!CAUTION]
245+
> Credential Security Support Provider (CredSSP) authentication, in which the user's credentials are
246+
> passed to a remote computer to be authenticated, is designed for commands that require
247+
> authentication on more than one resource, such as accessing a remote network share. This mechanism
248+
> increases the security risk of the remote operation. If the remote computer is compromised, the
249+
> credentials that are passed to it can be used to control the network session.
247250

248251
```yaml
249252
Type: System.Management.Automation.Runspaces.AuthenticationMechanism
@@ -266,8 +269,7 @@ this action. Enter the certificate thumbprint of the certificate.
266269
Certificates are used in client certificate-based authentication. They can be mapped only to local
267270
user accounts; they do not work with domain accounts.
268271

269-
To get a certificate, use the `Get-Item` or `Get-ChildItem` command in the Windows PowerShell Cert:
270-
drive.
272+
To get a certificate, use the `Get-Item` or `Get-ChildItem` command in the PowerShell Cert: drive.
271273

272274
```yaml
273275
Type: System.String
@@ -296,9 +298,9 @@ computer. For instructions for adding a computer name to the TrustedHosts list,
296298
Computer to the Trusted Host List" in
297299
[about_Remote_Troubleshooting](About/about_Remote_Troubleshooting.md).
298300

299-
Note: In Windows Vista and later versions of the Windows operating system, to include the local
300-
computer in the value of the **ComputerName** parameter, you must start Windows PowerShell with the
301-
Run as administrator option.
301+
> [!NOTE]
302+
> On the Windows operating system, to include the local computer in the value of the
303+
> **ComputerName** parameter, you must start PowerShell with the Run as administrator option.
302304

303305
```yaml
304306
Type: System.String
@@ -355,11 +357,11 @@ and **ApplicationName** parameters to specify the **ConnectionURI** values.
355357

356358
Valid values for the Transport segment of the URI are HTTP and HTTPS. If you specify a connection
357359
URI with a Transport segment, but do not specify a port, the session is created by using standards
358-
ports: 80 for HTTP and 443 for HTTPS. To use the default ports for Windows PowerShell remoting,
359-
specify port 5985 for HTTP or 5986 for HTTPS.
360+
ports: 80 for HTTP and 443 for HTTPS. To use the default ports for PowerShell remoting, specify port
361+
5985 for HTTP or 5986 for HTTPS.
360362

361-
If the destination computer redirects the connection to a different URI, Windows PowerShell prevents
362-
the redirection unless you use the **AllowRedirection** parameter in the command.
363+
If the destination computer redirects the connection to a different URI, PowerShell prevents the
364+
redirection unless you use the **AllowRedirection** parameter in the command.
363365

364366
```yaml
365367
Type: System.Uri
@@ -556,7 +558,7 @@ Aliases:
556558
557559
Required: False
558560
Position: Named
559-
Default value: None
561+
Default value: False
560562
Accept pipeline input: False
561563
Accept wildcard characters: False
562564
```
@@ -637,7 +639,7 @@ Aliases:
637639
638640
Required: False
639641
Position: Named
640-
Default value: None
642+
Default value: False
641643
Accept pipeline input: False
642644
Accept wildcard characters: False
643645
```

reference/7.0/Microsoft.PowerShell.Core/Enter-PSSession.md

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: System.Management.Automation.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Core
5-
ms.date: 07/23/2020
5+
ms.date: 08/16/2022
66
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/enter-pssession?view=powershell-7&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: Enter-PSSession
@@ -133,7 +133,7 @@ The fourth command confirms that the Process.txt file is on the remote computer.
133133

134134
```powershell
135135
PS C:\> Enter-PSSession -ComputerName Server01
136-
[Server01]: PS>
136+
[Server01]: PS C:\>
137137
[Server01]: PS C:\> Get-Process PowerShell > C:\ps-test\Process.txt
138138
[Server01]: PS C:\> exit
139139
PS C:\>
@@ -188,18 +188,18 @@ PS> Enter-PSSession -HostName UserA@LinuxServer01
188188
```
189189

190190
This example shows how to start an interactive session using Secure Shell (SSH). If SSH is
191-
configured on the remote computer to prompt for passwords then you will get a password prompt.
192-
Otherwise you will have to use SSH key based user authentication.
191+
configured on the remote computer to use passwords then you are prompted to enter a password.
192+
Otherwise, you must use key-based user authentication.
193193

194-
### Example 7: Start an interactive session using SSH and specify the Port and user authentication key
194+
### Example 7: Start an interactive session using SSH with a port and user authentication key
195195

196196
```powershell
197-
PS> Enter-PSSession -HostName UserA@LinuxServer02:22 -KeyFilePath c:\<path>\userAKey_rsa
197+
PS> Enter-PSSession -HostName UserA@LinuxServer02:22 -KeyFilePath c:\sshkeys\userAKey_rsa
198198
```
199199

200-
This example shows how to start an interactive session using SSH. It uses the **Port** parameter to
201-
specify the port to use and the **KeyFilePath** parameter to specify an RSA key used to authenticate
202-
the user on the remote computer.
200+
This example shows how to start an interactive session using SSH. The username and SSH port number
201+
are specified as parts of the value of the **HostName** parameter. The **KeyFilePath** parameter
202+
specifies the location of an RSA key used to authenticate the user on the remote computer.
203203

204204
## PARAMETERS
205205

@@ -224,7 +224,7 @@ Aliases:
224224

225225
Required: False
226226
Position: Named
227-
Default value: None
227+
Default value: False
228228
Accept pipeline input: False
229229
Accept wildcard characters: False
230230
```
@@ -276,11 +276,12 @@ of the Windows operating system.
276276
For more information about the values of this parameter, see
277277
[AuthenticationMechanism Enum](/dotnet/api/system.management.automation.runspaces.authenticationmechanism).
278278

279-
Caution: Credential Security Support Provider (CredSSP) authentication, in which the user's
280-
credentials are passed to a remote computer to be authenticated, is designed for commands that
281-
require authentication on more than one resource, such as accessing a remote network share. This
282-
mechanism increases the security risk of the remote operation. If the remote computer is
283-
compromised, the credentials that are passed to it can be used to control the network session.
279+
> [!CAUTION]
280+
> Credential Security Support Provider (CredSSP) authentication, in which the user's credentials are
281+
> passed to a remote computer to be authenticated, is designed for commands that require
282+
> authentication on more than one resource, such as accessing a remote network share. This mechanism
283+
> increases the security risk of the remote operation. If the remote computer is compromised, the
284+
> credentials that are passed to it can be used to control the network session.
284285

285286
```yaml
286287
Type: System.Management.Automation.Runspaces.AuthenticationMechanism
@@ -332,9 +333,9 @@ computer. For instructions for adding a computer name to the TrustedHosts list,
332333
Computer to the Trusted Host List" in
333334
[about_Remote_Troubleshooting](About/about_Remote_Troubleshooting.md).
334335

335-
Note: In Windows Vista and later versions of the Windows operating system, to include the local
336-
computer in the value of the **ComputerName** parameter, you must start PowerShell with the Run as
337-
administrator option.
336+
> [!NOTE]
337+
> On the Windows operating system, to include the local computer in the value of the
338+
> **ComputerName** parameter, you must start PowerShell with the Run as administrator option.
338339

339340
```yaml
340341
Type: System.String
@@ -486,7 +487,7 @@ Aliases:
486487
487488
Required: False
488489
Position: Named
489-
Default value: None
490+
Default value: False
490491
Accept pipeline input: False
491492
Accept wildcard characters: False
492493
```
@@ -653,7 +654,7 @@ Aliases:
653654
654655
Required: False
655656
Position: Named
656-
Default value: None
657+
Default value: False
657658
Accept pipeline input: False
658659
Accept wildcard characters: False
659660
```
@@ -732,7 +733,7 @@ Accepted values: true
732733
733734
Required: False
734735
Position: Named
735-
Default value: None
736+
Default value: False
736737
Accept pipeline input: False
737738
Accept wildcard characters: False
738739
```
@@ -754,7 +755,7 @@ Aliases:
754755
755756
Required: False
756757
Position: Named
757-
Default value: powershell
758+
Default value: Powershell
758759
Accept pipeline input: True (ByPropertyName)
759760
Accept wildcard characters: False
760761
```
@@ -809,7 +810,7 @@ Aliases:
809810
810811
Required: False
811812
Position: Named
812-
Default value: None
813+
Default value: False
813814
Accept pipeline input: False
814815
Accept wildcard characters: False
815816
```
@@ -892,7 +893,7 @@ is available. To cancel the `Enter-PSSession` command, press <kbd>CTRL</kbd>+<kb
892893

893894
The **HostName** parameter set was included starting with PowerShell 6.0. It was added to provide
894895
PowerShell remoting based on Secure Shell (SSH). Both SSH and PowerShell are supported on multiple
895-
platforms (Windows, Linux, macOS) and PowerShell remoting will work over these platforms where
896+
platforms (Windows, Linux, macOS) and PowerShell remoting works over these platforms where
896897
PowerShell and SSH are installed and configured. This is separate from the previous Windows only
897898
remoting that is based on WinRM and much of the WinRM specific features and limitations do not
898899
apply. For example, WinRM based quotas, session options, custom endpoint configuration, and

0 commit comments

Comments
 (0)