简体   繁体   中英

Remove all folders .old

I'm trying to delete all folders in \\\\kiewitplaza\\vdi\\Appsense_profiles that end with .old . The piece I have that says Write-Host $name is just me trying to test before I delete anything.

$name = Get-ChildItem "\\kiewitplaza\vdi\Appsense_profiles"
if ($name.name.EndsWith(".old")) {
    Write-Host $name
    #Remove-Item "\\kiewitplaza\vdi\Appsense_profiles\$name.old"
}

Get-ChildItem produces a list of objects. Use a pipeline for processing that list:

Get-ChildItem '\\kiewitplaza\vdi\Appsense_profiles' |
  Where-Object { $_.Name -like '*.old' } |
  Remove-Item

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM