Rename files in powershell to a much longer name above 260 limit

1k views Asked by At

So, I am trying to make a PowerShell scripted backup of our documentation, solutions, and white papers to a windows server which can be easily accessed

Unfortunately, when I download them I am unable to name the articles and attachments by their long names.

I did attempt a workaround, which somewhat works in some places, where I download the webpage and attachments and just do a Get-ChildItem "$ItemOriginalfilepath" | Rename-Item -NewName "$ItemFullNameWithExtension" -Force and that works for one location, I don't know why.

My main issue is how do I rename the file in other windows servers, where this trick seems to NOT work.

How do I overcome that 260 limit for renaming or maybe in general?

1

There are 1 answers

1
2 B On

You can tweak GPO or registry to overcome 260 character limits, but since there are no details in your question I am not sure if it'll help.

AFAIK it works in Windows 10 and Windows Server 2016. You will need GPO templates to make it available on windows server 2012r2

This article is pretty useful

https://www.saotn.org/ntfs-long-paths-windows-server-2016-gpo/

Please have a look at this question and answer.

https://serverfault.com/questions/847142/cant-use-long-path-names-in-windows-2016