-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-ExternalThe issue is caused by external component(s).The issue is caused by external component(s).
Description
When decorating a function with [CmdletBinding(SupportsShouldProcess=$true)], calling that function with -WhatIf will pass on the -WhatIf parameter to functions called within that also supports this. In the example below one can see this working for Move-Item, but not for Expand-Archive.
Steps to reproduce
function Demonstrate-Bug {
[CmdletBinding(SupportsShouldProcess=$true)]
param ()
# Does not rename file, but instead outputs the following:
# What if: Performing the operation "Move File" on target "Item: C:\Temp\Foo.zip Destination: C:\Temp\Bar.zip".
Move-Item -Path .\Foo.zip -Destination Bar.zip
# Would expect the following to not expand the archive, but instead only print a "What if" message similar to above.
Expand-Archive -Path .\Foo.zip
# If Expand-Arvhice is called explicitely with -WhatIf, I get the following output:
# What if: Performing the operation "Expand-Archive" on target "C:\Temp\Foo.zip".
}
Demonstrate-Bug -WhatIfExpected behavior
Expand-Archive isn't actually called, but instead a message explaining what would happen without -WhatIf is outputted.
Actual behavior
The Foo.zip archive gets expanded, even though Demonstrate-Bug is called with the -WhatIf parameter.
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.16299.248
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.16299.248
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1mklement0
Metadata
Metadata
Assignees
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-ExternalThe issue is caused by external component(s).The issue is caused by external component(s).