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 @@ -531,9 +531,11 @@ public string JobName
[Parameter(Position = 1,
Mandatory = true,
ParameterSetName = InvokeCommandCommand.ContainerIdParameterSet)]
[Parameter(Mandatory = true,
[Parameter(Position = 1,
Mandatory = true,
ParameterSetName = InvokeCommandCommand.SSHHostParameterSet)]
[Parameter(Mandatory = true,
[Parameter(Position = 1,
Mandatory = true,
ParameterSetName = InvokeCommandCommand.SSHHostHashParameterSet)]
[ValidateNotNull]
[Alias("Command")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ Describe "SSH Remoting Cmdlet Tests" -Tags "Feature" {
}

It "Invoke-Command HostName parameter set should throw error for invalid key path" {
{ Invoke-Command -HostName localhost -UserName User -KeyFilePath NoKeyFile -ScriptBlock {1} } |
{ Invoke-Command -HostName localhost -UserName User -KeyFilePath NoKeyFile -ScriptBlock { 1 } } |
Should -Throw -ErrorId "PathNotFound,Microsoft.PowerShell.Commands.InvokeCommandCommand"
}

It "Invoke-Command should support positional parameter ScriptBlock when using parameter set '<ParameterSetName>'" -TestCases @{ParameterSetName = 'SSHHost' }, @{ParameterSetName = 'SSHHostHashParam' } {
param ([string]$ParameterSetName)
$commandInfo = Get-Command -Name Invoke-Command
$sshParameterSet = $commandInfo.ParameterSets | Where-Object { $_.Name -eq $ParameterSetName }
$scriptBlockPosition = $sshParameterSet.Parameters | Where-Object { $_.Name -eq 'ScriptBlock' } | Select-Object -ExpandProperty Position
$scriptBlockPosition | Should -Be 1
}
}