Apr 08 2021 08:05 PM
PSVersion:7.1.3
OS:Microsoft Windows 10.0.19042
OneDrive Version:21.052.0314.0001 (Office 365 A1)
Descriptions
Cannot remove nonempty folder in OneDrive directory
Step to reproduce
1. Launch PowerShell in OneDrive directory
PS C:\Users\MyUserName\OneDrive>
2. Try to use Remove-Item cmdlet to remove a nonempty folder in this directory, for example: the .\test\ folder
PS C:\Users\MyUserName\OneDrive> Remove-Item .\test\
Expected result
Without the -Recurse parameter, PowerShell should return a confirm message, such as
Confirm
The item at C:\Users\MyUserName\OneDrive\test\ has children and the Recurse parameter was not specified. If you continue, all children will be removed with the item. Are you sure you want to continue?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
Actual result
PowerShell return a error message
Remove-Item: Cannot remove item C:\Users\MyUserName\OneDrive\test\: The directory is not empty. : 'C:\Users\MyUserName\OneDrive\test\'
Note
1. PowerShell and Administrator:PowerShell get the same result;
2. If I exit OneDrive process and create a new nonempty folder under OneDrive directory, PowerShell can remove it as normal;
3. CMD can remove the folder successfully, which means I can use
cmd.exe /C "rd /s test"
in PowerShell to remove the folder too. But I want to accomplish this just by PowerShell cmdlet;
4. Get-ChildItem cmdlet shows that the mode of normal folders (not synced by OneDrive) is 'd'(directory), but the mode of synced folders is 'l'(link). However, "dir" command in CMD shows that both of them are <DIR> type. Is this the keypoint?
Sep 05 2021 12:39 PM