So i'm trying to delete a few remote folders but am running into permission issues.
I've tried:
Get-ChildItem \\$Comp\c$\eQube-Tools -Force | Remove-Item -Recurse
Get-ChildItem \\$Comp\c$\Gecko -Force | Remove-Item -Recurse
Remove-Item \\$Comp\c$\eQube-Tools -Force -Recurse
Remove-Item \\$Comp\c$\Gecko -Force -Recurse
But that gave me permission errors, So i added:
takeown /a /r /d Y /f \\$Comp\c$\eQube-Tools
takeown /a /r /d Y /f \\$Comp\c$\Gecko
Only to get:RemoveItem Error
About it being not empty.. i was reading that:
Remove-Item \\$Comp\c$\eQube-Tools -Force -Recurse
would delete the empty folder that:
Get-ChildItem \\$Comp\c$\eQube-Tools -Force | Remove-Item -Recurse
had created.
I did look into the ownership of the folders:Folder Owner **the only issues i can see is with the owner being the built in Admin Account
Im open to using:
rmdir (tried using psexec with this, this was my first attempt)
Object.Delete() *this is going to be my next try
My setup is:
Local Account: Administrator
Win 10 laptop running the code (PSVer 5.1)
on a workgroup
Remote Units: \\ip\C$ i can delete the folders fine this way (once the program has been killed)
Local Account: Administrator
Win 7 Home
Workgroup
PSver 2.0
Just to be sure if you and i are on the right way to find your solution here are some questions and suggestions.
Are the computers you are trying to access member of an active directory? If yes, you might prefer deleting the folder with a GPO. This would work extremely easy if "system" still has permissions. Just create a new GPO and link it to the GPO you need it, and or filter the computer you want to apply to. Open it and go to "Computer configuration" > "settings" > "Windows-Settings" > "Folder" and create a new folder there. Select in the options of this folder "Delete" and check all checkboxes you need (all except the last) Just tried it works even if i am not owner and got no permissions - but system needs permission.
did you start your PowerShell with highest privileges? Depending on how you test this might affect your testing.
Can you post your exact error message? In some cases, error messages contain helpful information
Found that article that might help - could you try that either? PowerShell Change owner of files and folders