Delete user folder via Access Denied script

Asked

Viewed 11 times

-2

Good afternoon! I am trying to run a script to delete all user folders in C: Users The script:

Get-Childitem "C: Users" -recurse -Include . | Where-Object {$_. psIsContainer -eq $true} | remove-item -r

I’m filtering how . to delete only users I wish. But while trying to delete folders it gives denied access to the following directory on all users:

C: Users*. * Print environment access denied.

I am running the script as a local machine administrator on a local user. The users I’m trying to delete belong to a specific domain.

Could you help me?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.