260 Character Limit, Get-ChildItem

前端 未结 2 1253
小鲜肉
小鲜肉 2021-01-24 05:54

I understand there is a 260 character limit for win32, but I am curious as to why my code is half working. See below.

$Age_of_Files = -30
$Path = \'\\\\         


        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-24 06:13

    This is a limitation of the Win32 API (see also). There's a PowerShell Module that supposedly works around the issue (haven't used it myself, though).

    A common workaround is to shorten the path by substing the longest accessible path to a drive letter

    & subst X: C:\longest\parent\folder
    

    working on drive X:, then deleting the temporary drive afterwards:

    & subst X: /d
    

    For network paths use net use to the same end:

    & net use X: \\server\share\longest\parent\folder
    ...
    & net use X: /d
    

提交回复
热议问题