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 = \'\\\\
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