Author Posts

October 4, 2017 at 12:58 pm


I have a script to delete the profiles folder for staff who have left

I am calling the txt document which contains the list of profiles that need deleting

When I run the script I get an error:

At C:\scripts\staff leavers\deleteprofiles.ps1:1 char:50
+ ... pts\Staff leavers\profiledel.txt' | %{Remove-Item $_ -Recurse -Force}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (AppData:DirectoryInfo) [Remove-Item], IOException
+ FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand
Remove-Item : Cannot remove item \\CONTAINS THE PROFILE PATH HERE: The directory is not empty.

October 4, 2017 at 1:20 pm

There's likely something in there it's unable to delete. Probably due to permissions.

October 4, 2017 at 7:13 pm

Try to run the script from an elevated shell. I'm with Don. This smells like permissions.

October 4, 2017 at 11:03 pm

The other option would be lock on the folder or file which might still be open for some other application.

October 6, 2017 at 7:11 am


How would I run with an elevated shell?