取得所有权并;删除文件夹错误
所以我试图删除一些远程文件夹,但遇到权限问题。
我已经尝试过:
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
但这给了我权限错误,所以我添加了:
takeown /a /r /d Y /f \\$Comp\c$\eQube-Tools
takeown /a /r /d Y /f \\$Comp\c$\Gecko
仅获取:RemoveItem Error
关于它不为空..我正在阅读:
Remove-Item \\$Comp\c$\eQube-Tools -Force -Recurse
空文件夹
Get-ChildItem \\$Comp\c$\eQube-Tools -Force | Remove-Item -Recurse
将删除已创建的
。我确实调查了文件夹的所有权:文件夹所有者 **我能看到的唯一问题是所有者是内置管理员帐户
我愿意使用:
rmdir (tried using psexec with this, this was my first attempt)
Object.Delete() *this is going to be my next try
我的设置是:
本地帐户:管理员
Win 10笔记本电脑运行 上的代码 (PSVer 5.1)
工作组
远程单元 \\ip\C$ 我可以通过这种方式删除文件夹(一旦程序被杀死)
本地帐户:管理员
Win 7 Home
Workgroup
PSver 2.0
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是为了确定您和我是否以正确的方式找到解决方案,这里有一些问题和建议。
您尝试访问的计算机是活动目录的成员吗?
如果是,您可能更愿意删除带有 GPO 的文件夹。如果“系统”仍然有权限,这将非常容易。只需创建一个新的 GPO 并将其链接到您需要的 GPO,或者过滤您想要应用到的计算机。打开它并转到“计算机配置”> “设置”> “Windows-设置”> “文件夹”并在那里创建一个新文件夹。在此文件夹的选项中选择“删除”并选中您需要的所有复选框(除最后一个之外的所有复选框)
刚刚尝试过,即使我不是所有者并且没有权限,它也能工作 - 但系统需要权限。
您是否以最高权限启动 PowerShell?
根据您的测试方式,这可能会影响您的测试。
您能发布具体的错误消息吗?
在某些情况下,错误消息包含有用的信息
找到可能有帮助的文章 - 您可以尝试一下吗?
PowerShell 更改文件和文件夹的所有者
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