Skip to content

Compress-Archive doesn't respect SupportsShouldProcess=$true when called from advanced function #35

Closed
@shew00

Description

@shew00

Steps to reproduce

function TestCompress() {
    [CmdLetBinding(SupportsShouldProcess=$true)]
    param (
        [string]$source,
        [string]$dest
    )
    PROCESS {
        Compress-Archive -Path $source -DestinationPath $dest
    }
 }

Call with TestCompress -source testfile -dest $env:temp\testfile.zip -WhatIf

Expected behavior

Output should be:

What if: Performing the operation "Compress-Archive" on target ...\testfile.zip
No zip file archive should be created.

Actual behavior

Zip file archive is created in destination directory.

Notes

The -WhatIf parameter is passed through if Compress-Archive is replaced by Copy-Item in the function above.

Calling Compress-Archive with -WhatIf directly yields the correct results.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions