-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
HacktoberfestPotential candidate to participate in HacktoberfestPotential candidate to participate in HacktoberfestIssue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management modulecmdlets in the Microsoft.PowerShell.Management module
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Issue is -Force does not seem to understand junctions. It thinks they are directories and fails to remove them because they are not empty.
Works fine with file types. (see screenshot)
Most types including registry entries allow -Force to overwrite the item. Logically -Force should do the same for a Junction.
Due to -Force not working you must first Remove-Item prior to New-Item, which works perfectly fine. Remove-Item simply removes the junction and does not complain that it is not empty. New-Item -Force needs the same intelligence.
Expected behavior
PS> New-Item MyWindows -Type Junction -Value C:\Windows\
PS> New-Item MyWindows -Type Junction -Value C:\Windows\ -Force
PS>Actual behavior
PS> New-Item MyWindows -Type Junction -Value C:\Windows\
PS> New-Item MyWindows -Type Junction -Value C:\Windows\ -Force
New-Item: Directory C:\Temp\MyWindows cannot be removed because it is not empty.
PS>Error details
Exception :
Type : System.IO.IOException
Message : Directory C:\Temp\MyWindows cannot be removed because it is not empty.
HResult : -2146232800
TargetObject : C:\Temp\MyWindows
CategoryInfo : WriteError: (C:\Temp\MyWindows:String) [New-Item], IOException
FullyQualifiedErrorId : DirectoryNotEmpty,Microsoft.PowerShell.Commands.NewItemCommand
InvocationInfo :
MyCommand : New-Item
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 5
Line : New-Item MyWindows -Type Junction -Value C:\Windows\ -Force
PositionMessage : At line:1 char:1
+ New-Item MyWindows -Type Junction -Value C:\Windows\ -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : New-Item
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :Environment data
Name Value
---- -----
PSVersion 7.2.5
PSEdition Core
GitCommitId 7.2.5
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
mklement0
Metadata
Metadata
Assignees
Labels
HacktoberfestPotential candidate to participate in HacktoberfestPotential candidate to participate in HacktoberfestIssue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management modulecmdlets in the Microsoft.PowerShell.Management module
