Delete directory regardless of 260 char limit

后端 未结 17 1799
無奈伤痛
無奈伤痛 2020-12-08 02:03

I\'m writing a simple script to delete USMT migration folders after a certain amount of days:

## Server List ##
$servers = \"Delorean\",\"Adelaide\",\"Brisba         


        
17条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-08 02:44

    This is a known limitation of PowerShell. The work around is to use dir cmd (sorry, but this is true).

    http://asysadmin.tumblr.com/post/17654309496/powershell-path-length-limitation

    or as mentioned by AaronH answer use \?\ syntax is in this example to delete build

    dir -Include build -Depth 1 | Remove-Item -Recurse -Path "\\?\$($_.FullName)"
    

提交回复
热议问题