diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/ParsePathCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/ParsePathCommand.cs index 0cf95e8ac9d..5e0711e55fa 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/ParsePathCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/ParsePathCommand.cs @@ -107,7 +107,7 @@ public string[] LiteralPath /// The qualifier is the drive or provider that is qualifying /// the MSH path. /// - [Parameter(Position = 1, ValueFromPipelineByPropertyName = true, ParameterSetName = qualifierSet, Mandatory = false)] + [Parameter(ValueFromPipelineByPropertyName = true, ParameterSetName = qualifierSet)] public SwitchParameter Qualifier { get; set; } /// @@ -476,4 +476,3 @@ private string RemoveQualifier(string path) } } } - diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Split-Path.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Split-Path.Tests.ps1 index ed524c5aa9d..b9537a4a961 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Split-Path.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Split-Path.Tests.ps1 @@ -29,6 +29,10 @@ Describe "Split-Path" -Tags "CI" { { Split-Path -Qualifier -ErrorAction Stop abcdef } | Should -Throw } + It "Should error given positional parameter #2" { + { Split-Path env: $NULL } | Should -Throw -ErrorId 'PositionalParameterNotFound,Microsoft.PowerShell.Commands.SplitPathCommand' + } + It "Should return the path when the noqualifier switch is used" { Split-Path env:PATH -NoQualifier | Should -BeExactly "PATH" }