私は完全にディレクトリを削除するpowershell関数を持っています。私はPowerShellのを介して実行した場合、それは何の問題も働きませんCMDLINEPowershell Remove-Itemは、実行中に失敗したときにのみ失敗します。
function DeleteFolderAndContents()
{
param(
[Parameter(Mandatory=$true, Position=1)] [string] $folder_path
)
Get-ChildItem -Path "$folder_path" -Recurse -Force | Remove-Item -Force -Recurse
Write-Host "Deleted all files in directory. Will attempt to delete directory next"
Start-Sleep 3
Write-Host "Slept for 3 seconds. Now trying to remove folder"
Remove-Item "$folder_path" -Force
Write-Host "DeleteFolderAndContents worked seemingly without error"
while (Test-Path "$folder_path") { Start-Sleep 10 }
}
(そこにいくつかの余分なトレースで)ようにPowerShellの推奨ごとのように私はそれを構築しました。 Anabilitiesが同じスクリプトを(Scriptタスクを通じて)実行しようとすると、Get-ChildItemの部分が機能し、すべてのフォルダの内容が削除されますが、Remove-Itemはディレクトリを完全に削除できません。
私はこれが起こる理由はわかりません、次のエラーメッセージ
System.Management.Automation.PSArgumentException:
An object at the specified path C:\\bblabla\\blabla\\blabla\\A.C.S.Api does not exist.
at Microsoft.PowerShell.Commands.FileSystemProvider.NormalizeThePath(String basepath, Stack`1 tokenizedPathStack),
at Microsoft.PowerShell.Commands.FileSystemProvider.NormalizeRelativePathHelper(String path, String basePath)
を取得します。私はそのAnsible問題はかなり確信していますが、それがどうなるかわからないし、何をすべきかわからない。
あなたは@techrafを手に入れました – Mark