Remove-Item in use by another process

Welcome Forums General PowerShell Q&A Remove-Item in use by another process

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
3 months, 1 week ago.

  • Author
    Posts
  • #111122

    Participant
    Points: 31
    Rank: Member

    Hi,

    I am trying to delete users' home folders who no longer have an AD account. I found that Remove-Item only works properly if you use Get-ChildItem first and pipe it to Remove-Item.

    This is the command I am using:

    Get-ChildItem c:\whatever -Recurse -force | Remove-Item -force -recurse -Confirm:$true

    It properly deletes the folder contents (including Favorites), but it does not delete the folder itself. I then try to delete it using Remove-Item but it says the folder is being used by another process.

    Does anyone know how to get around this issue?

    Thanks!

     

  • #111211
    js

    Participant
    Points: 319
    Helping Hand
    Rank: Contributor

    Was the profile recently created? Some windows service might be processing it.

  • #111220

    Participant
    Points: 31
    Rank: Member

    Thanks I found out that was an apache process 🙁

    Thanks!

The topic ‘Remove-Item in use by another process’ is closed to new replies.