Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes308downloads
RemotingCmdlets.Tests.ps128 linesDownload Raw Back to Microsoft.PowerShell.Core
1# Copyright (c) Microsoft Corporation.2# Licensed under the MIT License.3Describe "SSH Remoting Cmdlet Tests" -Tags "Feature" {4 5    It "Enter-PSSession HostName parameter set should throw error for invalid key path" {6        { Enter-PSSession -HostName localhost -UserName User -KeyFilePath NoKeyFile } |7            Should -Throw -ErrorId "PathNotFound,Microsoft.PowerShell.Commands.EnterPSSessionCommand"8    }9 10    It "New-PSSession HostName parameter set should throw error for invalid key path" {11        { New-PSSession -HostName localhost -UserName User -KeyFilePath NoKeyFile } |12            Should -Throw -ErrorId "PathNotFound,Microsoft.PowerShell.Commands.NewPSSessionCommand"13    }14 15    It "Invoke-Command HostName parameter set should throw error for invalid key path" {16        { Invoke-Command -HostName localhost -UserName User -KeyFilePath NoKeyFile -ScriptBlock { 1 } } |17            Should -Throw -ErrorId "PathNotFound,Microsoft.PowerShell.Commands.InvokeCommandCommand"18    }19 20    It "Invoke-Command should support positional parameter ScriptBlock when using parameter set '<ParameterSetName>'" -TestCases @{ParameterSetName = 'SSHHost' }, @{ParameterSetName = 'SSHHostHashParam' } {21        param ([string]$ParameterSetName)22        $commandInfo = Get-Command -Name Invoke-Command23        $sshParameterSet = $commandInfo.ParameterSets | Where-Object { $_.Name -eq $ParameterSetName }24        $scriptBlockPosition = $sshParameterSet.Parameters | Where-Object { $_.Name -eq 'ScriptBlock' } | Select-Object -ExpandProperty Position25        $scriptBlockPosition | Should -Be 126    }27}28