i cant delete a folder on my external hardrive created by my windows

Meoturo 0 Reputation points
2023-03-08T11:57:46.09+00:00
Remove-Item : Cannot remove item D:\WindowsApps\MutableBackup: Access to the path is denied.
At line:1 char:1
+ Remove-Item –path "D:\WindowsApps" -force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (MutableBackup:DirectoryInfo) [Remove-Item], ArgumentException
    + FullyQualifiedErrorId : RemoveFileSystemItemArgumentError,Microsoft.PowerShell.Commands.RemoveItemCommand
Remove-Item : Cannot remove item D:\WindowsApps\Deleted: Access to the path is denied.
At line:1 char:1
+ Remove-Item –path "D:\WindowsApps" -force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (Deleted:DirectoryInfo) [Remove-Item], ArgumentException
    + FullyQualifiedErrorId : RemoveFileSystemItemArgumentError,Microsoft.PowerShell.Commands.RemoveItemCommand
Remove-Item : Cannot remove item D:\WindowsApps: Access to the path is denied.
At line:1 char:1
+ Remove-Item –path "D:\WindowsApps" -force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (D:\WindowsApps:DirectoryInfo) [Remove-Item], ArgumentException
    + FullyQualifiedErrorId : RemoveFileSystemItemArgumentError,Microsoft.PowerShell.Commands.RemoveItemCommand
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 47,901 Reputation points
    2023-03-09T20:33:57.2333333+00:00

    Does your account have permission to remove the directory?

    Try running the script using "Run as administrator". If that doesn't work, take ownership of the directory and try again (using run as administrator).

    PowerShell is just reporting the problem, it's up to you, as the owner of the system, to assure that the necessary permission is assigned to the accounts that need a required access to resource.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.