0

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?

AdilZ
  • 1,107
  • 6
  • 27
  • 44
  • Why would you do this? So many things have issues with files that have long names, you are just asking for incompatibilities and trouble down the road. If you really need to know "long names" for things make a spreadsheet that's an index or put it in a wiki or something, but don't use super long names for the files. – TheMadTechnician Dec 12 '17 at 19:06
  • Because that is what is tasked of me, I would do it in a linux environment instead, and also a wiki, where such things arent an issue, but I do not have that option. What is requested is local copies of the webpage and the attachments, with their names intact. – AdilZ Dec 12 '17 at 19:19
  • Map a network drive `New-PSDrive` with a location that is pretty deep into the path. Then you can rename the file from that network drive. i.e. Map \\Server\Share\Really\Long\Path as Z:\. Then perform the `Rename-Item Z:\FileName.txt -NewName NewFileName.txt` – Shawn Esterman Dec 12 '17 at 19:47

1 Answers1

2

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

2 B
  • 114
  • 1
  • 12
  • 1
    Thank you that was helpful, well it gave some idea, even though it didnt resolve it, I will update again, if I manage to resolve it after trying a few things that were inspired by the articles. My problem is that I am limited to Windows Server 2012, and also Windows Server 2012 R2 in a virtualized datacenter environment, so many things that can work normally, dont work. – AdilZ Dec 22 '17 at 06:12