mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
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:
@@ -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" {
|
||||
|
||||
Reference in New Issue
Block a user