我是PowerShell的新手.当试图编写一个删除文件夹内容的简单脚本,然后用从不同文件夹复制的文件填充它时,我总是收到PermissionDenied错误.
细节:
+ remove-item <<<< D:\path\* -recurse
+ CategoryInfo : PermissionDenied: (save.gif:FileInfo) [Remove-Item], IOException
+ FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
Run Code Online (Sandbox Code Playgroud)
问题出在哪儿?我可以通过资源管理器操作这两个文件夹.从脚本文件和shell(使用Windows PowerShell ISE)运行时都会发生错误.ISE流程在我的帐户下运行.我正在运行Windows 7 Professional并且是本地管理员.
编辑: 在理查德的建议之后,我尝试了详细模式(似乎没有效果).
PS Z:\> $error[0] | fl * -force
PSMessageDetails :
Exception : System.IO.IOException: Not Enough permission to perform operation.
TargetObject : D:\path\file.txt
CategoryInfo : PermissionDenied: (D:\path\file.txt:FileInfo) [Remove-Item], IOException
FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
ErrorDetails : Cannot remove item D:\path\file.txt: Not Enough permission to perform operation.
InvocationInfo : System.Management.Automation.InvocationInfo
PipelineIterationInfo : {0, 1}
Run Code Online (Sandbox Code Playgroud)
我没有看到任何有用的东西(但感谢提示).
编辑2: 好的,这是脚本来源:
remove-item …Run Code Online (Sandbox Code Playgroud) 我喜欢Python语言,主要使用标准的CPython 3. +版本进行简单的脚本编写和算法沙箱.有时我需要.NET集成,所以我使用IronPython,现在是2.7版本.
我喜欢3. +更好,因此我不愿意使用旧的2.7.是否有任何关于何时发布以及预计迁移过程有多难的信息?