diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs index 96ce85ae0d..e0ec332504 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs @@ -1855,7 +1855,6 @@ namespace Microsoft.PowerShell.Commands } private string _redirectstandardoutput; -#if !CORECLR /// /// Verb /// @@ -1867,7 +1866,7 @@ namespace Microsoft.PowerShell.Commands [ValidateNotNullOrEmpty] public string Verb { get; set; } - +#if !CORECLR /// /// Window style of the process window /// @@ -1922,6 +1921,14 @@ namespace Microsoft.PowerShell.Commands /// protected override void BeginProcessing() { +#if CORECLR + if(this.ParameterSetName.Equals("UseShellExecute")) + { + String errorMessage = StringUtil.Format(ProcessResources.ParameterNotSupportedOnPSEdition, "-Verb", "Start-Process"); + ErrorRecord er = new ErrorRecord(new NotSupportedException(errorMessage), "NotSupportedException", ErrorCategory.NotImplemented, null); + ThrowTerminatingError(er); + } +#endif //create an instance of the ProcessStartInfo Class ProcessStartInfo startInfo = new ProcessStartInfo(); string message = String.Empty; diff --git a/src/Microsoft.PowerShell.Commands.Management/resources/ProcessResources.resx b/src/Microsoft.PowerShell.Commands.Management/resources/ProcessResources.resx index 06284436e0..57a5d9a97e 100644 --- a/src/Microsoft.PowerShell.Commands.Management/resources/ProcessResources.resx +++ b/src/Microsoft.PowerShell.Commands.Management/resources/ProcessResources.resx @@ -222,4 +222,7 @@ The parameter '{0}' is not supported for the cmdlet '{1}' on this edition of Windows. + + The parameter '{0}' is not supported for the cmdlet '{1}' on this edition of PowerShell. + \ No newline at end of file diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Start-Process.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Start-Process.Tests.ps1 index 65d03c8308..3fc5f15e02 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Start-Process.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Start-Process.Tests.ps1 @@ -69,5 +69,17 @@ Describe "Start-Process" -Tags @("CI","SLOW") { $dirEntry.Length | Should BeGreaterThan 0 } + It "Should give an error when Verb parameter is used" -Skip:(-not $IsCoreClr) { + try + { + Start-Process -Verb runas -FilePath $pingCommand -ArgumentList $pingParam + throw "No Exception!" + } + catch + { + $_.FullyQualifiedErrorId | Should be "NotSupportedException,Microsoft.PowerShell.Commands.StartProcessCommand" + $_.Exception.Message | Should match '-Verb' + } + } Remove-Item -Path $tempFile -Force }