Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs for support of new hostname format #2321

Merged
merged 4 commits into from
Apr 10, 2018
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
8 changes: 6 additions & 2 deletions reference/6/Microsoft.PowerShell.Core/Enter-PSSession.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ You can also use the **Exit** keyword to end the interactive session.

### Example 6: Start an interactive session using SSH
```
PS C:\> Enter-PSSession -HostName LinuxServer01 -UserName UserA
PS C:\> Enter-PSSession -HostName UserA@LinuxServer01
```

This example shows how to start an interactive session using Secure Shell (SSH). If SSH is configured on the remote computer to prompt for passwords then you will get a password prompt. Otherwise you will have to use SSH key based user authentication.

### Example 7: Start an interactive session using SSH and specify the Port and user authentication key
```
PS C:\> Enter-PSSession -HostName LinuxServer02 -UserName UserA -Port 22 -KeyFilePath c:\<path>\userAKey_rsa
PS C:\> Enter-PSSession -HostName UserA@LinuxServer02:22 -KeyFilePath c:\<path>\userAKey_rsa
```

This example shows how to start an interactive session using SSH. It uses the *Port* parameter to specify the port to use and the *KeyFilePath* parameter to specify an RSA key used to authenticate the user on the remote computer.
Expand Down Expand Up @@ -419,6 +419,10 @@ Accept wildcard characters: False
### -HostName
Specifies a computer name for a Secure Shell (SSH) based connection.
This is similar to the *ComputerName* parameter except that the connection to the remote computer is made using SSH rather than Windows WinRM.
This parameter supports specifying the user name and/or port as part of the host name parameter value using
the form `user@hostname:port`.
The user name and/or port specified as part of the host name takes precedent over the `-UserName` and `-Port` parameters, if specified.
This allows passing multiple computer names to this parameter where some have specific user names and/or ports, while others use the user name and/or port from the `-UserName` and `-Port` parameters.

This parameter was introduced in PowerShell 6.0.

Expand Down
11 changes: 8 additions & 3 deletions reference/6/Microsoft.PowerShell.Core/Invoke-Command.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,21 +491,21 @@ To get the results of commands and scripts that run in disconnected sessions, us

### Example 17: Run a command on a remote computer using SSH
```
PS C:\> Invoke-Command -HostName LinuxServer01 -UserName UserA -ScriptBlock { Get-MailBox * }
PS C:\> Invoke-Command -HostName UserA@LinuxServer01 -ScriptBlock { Get-MailBox * }
```

This example shows how to run a command on a remote computer using Secure Shell (SSH). If SSH is configured on the remote computer to prompt for passwords then you will get a password prompt. Otherwise you will have to use SSH key based user authentication.

### Example 18: Run a command on a remote computer using SSH and specify a user authentication key
```
PS C:\> Invoke-Command -HostName LinuxServer01 -UserName UserA -ScriptBlock { Get-MailBox * } -KeyFilePath c:\<path>\userAKey_rsa
PS C:\> Invoke-Command -HostName UserA@LinuxServer01 -ScriptBlock { Get-MailBox * } -KeyFilePath c:\<path>\userAKey_rsa
```

This example shows how to run a command on a remote computer using SSH and specifying a key file for user authentication. You will not get a password prompt unless the key authentication fails and the remote computer is configured to allow basic password authentication.

### Example 19: Run a script file on multiple remote computers using SSH as a job
```
PS C:\> $sshConnections = @{ HostName="WinServer1"; UserName="domain\userA"; KeyFilePath="c:\users\UserA\id_rsa" }, @{ HostName="LinuxServer5"; UserName="UserB"; KeyFilePath="c:\UserB\<path>\id_rsa }
PS C:\> $sshConnections = @{ HostName="WinServer1"; UserName="domain\userA"; KeyFilePath="c:\users\UserA\id_rsa" }, @{ HostName="UserB@LinuxServer5"; KeyFilePath="c:\UserB\<path>\id_rsa }
PS C:\> $results = Invoke-Command -FilePath c:\Scripts\CollectEvents.ps1 -SSHConnection $sshConnections
```

Expand Down Expand Up @@ -1168,6 +1168,10 @@ Accept wildcard characters: False

### -HostName
Specifies an array of computer names for a Secure Shell (SSH) based connection. This is similar to the ComputerName parameter except that the connection to the remote computer is made using SSH rather than Windows WinRM.
This parameter supports specifying the user name and/or port as part of the host name parameter value using
the form `user@hostname:port`.
The user name and/or port specified as part of the host name takes precedent over the `-UserName` and `-Port` parameters, if specified.
This allows passing multiple computer names to this parameter where some have specific user names and/or ports, while others use the user name and/or port from the `-UserName` and `-Port` parameters.

This parameter was introduced in PowerShell 6.0.

Expand Down Expand Up @@ -1248,6 +1252,7 @@ Accept wildcard characters: False
This parameter takes an array of hashtables where each hashtable contains one or more connection parameters needed to establish a Secure Shell (SSH) connection (HostName, Port, UserName, KeyFilePath).

The hashtable connection parameters are the same as defined for the HostName parameter set.
Note that the order of the keys in the hashtable result in user name and port being used for the connection where the last one specified is used. For example, if you use `@{UserName="first";HostName="second@host"}`, then the user name `second` will be used. However, if you use `@{HostName="second@host:22";Port=23}`, then port 23 will be used.

The SSHConnection parameter is useful for creating multiple sessions where each session requires different connection information.

Expand Down
14 changes: 10 additions & 4 deletions reference/6/Microsoft.PowerShell.Core/New-PSSession.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,19 +213,19 @@ The value of the SessionOption parameter is the **SessionOption** object in the

### Example 12: Create a session using SSH
```
PS C:\> New-PSSession -HostName LinuxServer01 -UserName UserA
PS C:\> New-PSSession -HostName UserA@LinuxServer01
```
This example shows how to create a new **PSSession** using Secure Shell (SSH). If SSH is configured on the remote computer to prompt for passwords then you will get a password prompt. Otherwise you will have to use SSH key based user authentication.

### Example 13: Create a session using SSH and specify the port and user authentication key
```
PS C:\> New-PSSession -HostName LinuxServer01 -UserName UserA -Port 22 -KeyFilePath c:\<path>\userAKey_rsa
PS C:\> New-PSSession -HostName UserA@LinuxServer01:22 -KeyFilePath c:\<path>\userAKey_rsa
```
This example shows how to create a **PSSession** using Secure Shell (SSH). It uses the *Port* parameter to specify the port to use and the *KeyFilePath* parameter to specify an RSA key used to identify and authenticate the user on the remote computer.

### Example 14: Create multiple sessions using SSH
```
PS C:\> $sshConnections = @{ HostName="WinServer1"; UserName="domain\userA"; KeyFilePath="c:\users\UserA\id_rsa" }, @{ HostName="LinuxServer5"; UserName="UserB"; KeyFilePath="c:\UserB\<path>\id_rsa }
PS C:\> $sshConnections = @{ HostName="WinServer1"; UserName="domain\userA"; KeyFilePath="c:\users\UserA\id_rsa" }, @{ HostName="UserB@LinuxServer5"; KeyFilePath="c:\UserB\<path>\id_rsa }
PS C:\> New-PSSession -SSHConnection $sshConnections
```
This example shows how to create multiple sessions using Secure Shell (SSH) and the **SSHConnection** parameter set. The *SSHConnection* parameter takes an array of hash tables that contain connection information for each session. Note that this example requires that the target remote computers have SSH configured to support key based user authentication.
Expand Down Expand Up @@ -693,6 +693,10 @@ Accept wildcard characters: False

### -HostName
Specifies an array of computer names for a Secure Shell (SSH) based connection. This is similar to the ComputerName parameter except that the connection to the remote computer is made using SSH rather than Windows WinRM.
This parameter supports specifying the user name and/or port as part of the host name parameter value using
the form `user@hostname:port`.
The user name and/or port specified as part of the host name takes precedent over the `-UserName` and `-Port` parameters, if specified.
This allows passing multiple computer names to this parameter where some have specific user names and/or ports, while others use the user name and/or port from the `-UserName` and `-Port` parameters.

This parameter was introduced in PowerShell 6.0.

Expand Down Expand Up @@ -773,10 +777,12 @@ Accept wildcard characters: False
This parameter takes an array of hashtables where each hashtable contains one or more connection parameters needed to establish a Secure Shell (SSH) connection (HostName, Port, UserName, KeyFilePath).

The hashtable connection parameters are the same as defined for the **HostName** parameter set.
Note that the order of the keys in the hashtable result in user name and port being used for the connection where the last one specified is used. For example, if you use `@{UserName="first";HostName="second@host"}`, then the user name `second` will be used. However, if you use `@{HostName="second@host:22";Port=23}`, then port 23 will be used.

This parameter was introduced in PowerShell 6.0.

The *SSHConnection* parameter is useful for creating multiple sessions where each session requires different connection information.

This parameter was introduced in PowerShell 6.0.

```yaml
Type: hashtable
Expand Down