I can't delete folder or file at powershell event run it as administrator?

Anonymous
2025-05-14T15:52:49+00:00

I have tried both of commands Remove-Item blog and Remove-Item blog -Recurse

Windows for home | Windows 10 | Settings

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. Udit Tanwar 3,315 Reputation points Independent Advisor
    2025-05-14T16:51:00+00:00

    Hello

    Thank you so much for reaching out, I am Udit an independent advisor, and I am glad to assist you today with this issue.

    To resolve the issue where you're unable to delete a file or folder using PowerShell, follow these steps:

    1. Ensure the file/folder is not in use: Sometimes a file or folder may be locked by another process. You can close any programs or processes that might be using the file.
    2. Use the correct command for deletion Open PowerShell as Administrator. If you have already tried Remove-Item blog and Remove-Item blog -Recurse without success, try using the -Force option to bypass restrictions and delete it forcefully: Remove-Item blog -Recurse -Force
    3. Check for read-only files: Some files may be set to read-only, preventing their deletion. You can remove the read-only attribute by running: attrib -r blog /s /d After this, try deleting the file again using Remove-Item.
    4. Check if the file is locked by a system process Open Task Manager (Ctrl + Shift + Esc) and check for processes that might be using the file. If you find such processes, you can end them, and then try deleting the file again.
    5. Use the TakeOwn command Sometimes the file may not be owned by your user account. To take ownership of the file or folder, you can use the TakeOwn command: takeown /f blog /r /d y After taking ownership, try deleting it again.
    6. Check file permissions If you're still unable to delete the file, check the file permissions. Right-click the file, select Properties, go to the Security tab, and ensure that your user account has full permissions. If not, adjust the permissions and try deleting again.

    By following these steps, you should be able to delete the file or folder from PowerShell. Let me know if you need further clarification!

    Regards

    Udit

    0 comments No comments
  2. Anonymous
    2025-05-14T19:24:44+00:00

    These want too many energy. I'm admin user and just want to delete a folder which is created by mkdir

    0 comments No comments
  3. Udit Tanwar 3,315 Reputation points Independent Advisor
    2025-05-15T01:55:27+00:00

    Since you’re an admin and created the folder, try this in PowerShell (as Administrator):

    Remove-Item -Path .\blog -Recurse -Force

    Make sure no programs or windows are using that folder. If it still won’t delete, try restarting your PC and try again.

    Let me know if it helps!

    Regards,

    Udit

    0 comments No comments
  4. Anonymous
    2025-05-15T14:14:53+00:00

    -force is works but I don't want to use it because the command is getting longer, it's not practical, I'm an administrator, I want to do everything, the folder is not open either

    0 comments No comments
  5. Udit Tanwar 3,315 Reputation points Independent Advisor
    2025-05-15T18:26:36+00:00

    Got it, you want a simple way to delete the folder as an admin.

    Even with admin rights, Windows sometimes protects folders with hidden settings that stop deletion unless you use -Force. That’s why the longer command works.

    If you want, I can help you create a short PowerShell shortcut like this:

    function rmd($path) { Remove-Item $path -Recurse -Force }

    Then you can just type:

    rmd .\blog

    Also, make sure no programs are using the folder, as that can block deletion too.

    Let me know if you want a hand setting this up!

    Best,

    Udit

    0 comments No comments