Return count of items deleted using Get-ChildItem with Remove-Item

后端 未结 2 1859
情话喂你
情话喂你 2021-01-21 09:57

I am successfully deleting files as expected using the below command; however, I\'d like to get a count of the items deleted.

Get-ChildItem $dPath -Filter \"*.bl         


        
2条回答
  •  天命终不由人
    2021-01-21 10:30

    You can write the FileInfo returned by Get-ChildItem to the output pipeline after deleting them:

    Get-ChildItem -Path $path | 
       ForEach-Object { Remove-Item $_; Write-Output $_} | 
       Measure-Object
    

提交回复
热议问题