Add -WhatIf switch to Start-Process cmdlet (#4735)

* Add -WhatIf switch to Start-Process cmdlet
* Add test for the -WhatIf switch 

* Added a test to ensure that using a whatif switch prevents the action from being performed.

* Incorporated code review comments

* merged two tests into one as suggested

* Included the error action at the end of the cmdlet

* Remove extra space before `StringUtil` and new line

* Renamed the resource string id ProcessStartInfo to StartProcessTarget
This commit is contained in:
Sarith Sutha
2017-09-08 09:18:13 +04:00
committed by Ilya
parent f41461825a
commit f4b075c856
3 changed files with 17 additions and 1 deletions
@@ -104,6 +104,16 @@ Describe "Start-Process" -Tags @("Feature") {
$process.Name | Should Be "notepad"
$process | Stop-Process
}
It "Should be able to use the -WhatIf switch without performing the actual action" {
$pingOutput = Join-Path $TestDrive "pingOutput.txt"
{ Start-Process -Wait $pingCommand -ArgumentList $pingParam -RedirectStandardOutput $pingOutput -WhatIf -ErrorAction Stop } | Should Not Throw
$pingOutput | Should Not Exist
}
It "Should return null when using -WhatIf switch with -PassThru" {
Start-Process $pingCommand -ArgumentList $pingParam -PassThru -WhatIf | Should Be $null
}
}
Describe "Start-Process tests requiring admin" -Tags "Feature","RequireAdminOnWindows" {