Skip to content

Remove-Item removes the symbolic links and junctions when used with -WhatIf parameter #16664

@Tospaa

Description

@Tospaa

Prerequisites

Steps to reproduce

  • Create a new junction (reparse point) of an arbitrary directory
New-Item -Path junction -ItemType Junction -Value 'C:\Program Files\'
  • Create a new symbolic link of an arbitrary directory
New-Item -Path symlink -ItemType SymbolicLink -Value 'C:\Program Files\'
  • Run the Remove-Item command with the -WhatIf switch parameter
Remove-Item -Path .\junction\ -WhatIf
Remove-Item -Path .\symlink\ -WhatIf

Expected behavior

Should not remove junction or symbolic link

Actual behavior

Removes the junction and symbolic link

Error details

No response

Environment data

PS C:\Users\tospaa> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.1
PSEdition                      Core
GitCommitId                    7.2.1
OS                             Microsoft Windows 10.0.19043
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

2021-12-22.10-43-06.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-FileSystem-Providerspecific to the FileSystem providerNeeds-TriageThe issue is new and needs to be triaged by a work group.WG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions