Kudu REST API Command endpoint error when executing powershell

后端 未结 3 1283
情书的邮戳
情书的邮戳 2021-01-25 01:46

When trying to execute the POST to /api/command according to this description the following error occurs:

PS C:\\> $Result.Error
remove-item : The Win32 int         


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-25 02:08

    If the accepted answer isn't appropriate for your situation (i.e. you don't want to use -Recurse on the call to Remove-Item because that would blast an item you want to exclude from deletion, when its containing folder is recursively deleted), the following worked for me:

    Get-ChildItem d:\mypath -Recurse -Exclude FileToExclude.ext | Select -ExpandProperty FullName | sort length -Descending | foreach { Remove-Item -Path "$_" -Force }
    

    It seems that simply piping the file object to Remove-Item doesn't work because of this bug, but piping the full filename and then using that as the -Path argument, gets around it.

提交回复
热议问题