Skip to content

Remove-Item -WhatIf on Junctions and SymbolicLinks (ReparsePoints) doesn't honor -WhatIf, removes the item anyway. #19714

@msftrncs

Description

@msftrncs

Prerequisites

Steps to reproduce

While testing deleting symbolic links with Remove-Item in Windows PowerShell I ran in to issues and switched to PowerShell 7.3.4, where the command ran as expected, until I realized it deleted the files even though I had used the -WhatIf parameter.

Specifically I was deleting a symbolic link, but I also tested it on a junction point.

The actual command:

Remove-Item "$_\Documents" -force -whatif

$_ contained the directory info object of a user's folder on a file store. I was using the local file store at the time, so a local hard drive, not UNC paths.

I believe Windows PowerShell has the same issue, as it was providing an error regarding deleting the symbolic link after printing the verbose 'whatif:' response, due to some mismatch of tag information.

Expected behavior

Expected the file/folder to not be deleted.

Actual behavior

Folder was deleted even though the verbose output indicated 'whatif:'

What if: Performing the operation "Remove Directory" on target "E:\Shares\Users Folders\RNE_LdrFF\Documents".

Error details

No response

Environment data

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

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productResolution-DuplicateThe issue is a duplicate.WG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management moduleWG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions