目前遇到问题,我目前正在这样做:
Get-ChildItem $PATH -Recurse -ErrorAction SilentlyContinue |
Where-Object {($_.Attributes -notmatch '\"Directory\"') -and
($_.LastWriteTime -lt (Get-Date).AddHours(-12))}|
Remove-Item -Force -Recurse
Run Code Online (Sandbox Code Playgroud)
现在,如果我没有符号链接,它会很好地删除,但我有。我收到此错误:
Remove-Item :请求中指定的标记与重新分析点中存在的标记不匹配第 line:1 char:184 + ... ($_.LastWriteTime -lt (Get-Date).AddHours(- 12))}| 删除项目 -Force + ~~~~~~~~~~~~~~~~~~ + CategoryInfo :未指定:(:) [删除项目],Win32Exception + ExcellentQualifiedErrorId :System.ComponentModel.Win32Exception,Microsoft。 PowerShell.Commands.RemoveItemCommand
我无法将 powershell 升级到 v6。它似乎与: https: //github.com/powershell/powershell/issues/621#issuecomment-289230180
有人有解决方法吗?
我正在尝试通过CLI删除存储在持久卷中的文件。我知道路径,但不确定如何通过CLI删除文件。我要通过CLI进行操作的原因是,我正在自动化某些工作流程,该工作流程需要触发运行OpenShift CLI的Powershell脚本才能删除大量文件并按比例缩小。