Path Too Long

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
waynecierkowski
Posts: 23
Joined: Wed May 14, 2014 11:40 am

Path Too Long

Post by waynecierkowski » Tue Aug 04, 2015 11:54 am

I am writing code to modify files contained on our file servers. A majority of our users work from MAC's and they have created folder structure that exceeds the 260 character limit.

I am able to get into the folder using Cmdlet's from a module called NTFSsecurity which has a Get-ChildItem2 cmdlet. It also has a Remove-Item2 and Get-Item2 both able to work with longer paths. But the module does not have an alternative method for Add-Content.

I need a way to write to the file in question contained in this long path. I have been searching for days and have come up empty.

Anyone have any ideas as too how I can write to a file contained in a long path structure?

Thanks in advance for any and all help...

Wayne

User avatar
SAPIEN Support Forums
Posts: 945
Joined: Wed Dec 03, 2014 2:26 pm

Path Too Long

Post by SAPIEN Support Forums » Tue Aug 04, 2015 11:55 am

This is an automated post. A real person will respond soon.

Thank you for posting, waynecierkowski.

Here are some hints to help you get an accurate and complete answer to your question.

Ask in the best forum: If you asked in the wrong forum, just copy your question to the right forum.

Anticipate follow-up questions!

Did you remember to include the following?
  • 1. Product, version and build
    2. 32 or 64 bit product
    3. Operating system, e.g. Windows 7 64 bit.
    4. Attach a screenshot, if applicable
    5. Attach logs, crash reports, etc., in a ZIP file
If not, please take a moment to edit your original post or reply to this one.

*** Make sure you do not post any licensing information ***

User avatar
jvierra
Posts: 13792
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Path Too Long

Post by jvierra » Tue Aug 04, 2015 12:09 pm

Start by mapping a drive to the users folder then you an just use normal commands.

New-PsDrive X FileSystem \\server\share\userfolder

That usually is enough.

User avatar
waynecierkowski
Posts: 23
Joined: Wed May 14, 2014 11:40 am

Re: Path Too Long

Post by waynecierkowski » Wed Aug 05, 2015 6:13 am

I tried this out in the PowerShell console and I still get the same error, The specified path, file name, or both are too long...

User avatar
jvierra
Posts: 13792
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Path Too Long

Post by jvierra » Wed Aug 05, 2015 9:32 am

waynecierkowski wrote:I tried this out in the PowerShell console and I still get the same error, The specified path, file name, or both are too long...
Map the path further down.

User avatar
waynecierkowski
Posts: 23
Joined: Wed May 14, 2014 11:40 am

Re: Path Too Long

Post by waynecierkowski » Thu Aug 06, 2015 11:37 am

Maybe I'm missing something but I tried mapping down further in the folder tree and I still get the error.

I've attached a screen shot of my PS Session where I tried this.
Attachments
PS-Mapping.png
PS-Mapping.png (95.33 KiB) Viewed 2082 times

User avatar
jvierra
Posts: 13792
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Path Too Long

Post by jvierra » Thu Aug 06, 2015 11:46 am

You are going to have to install Mac support on the server. The issue is most likely due to illegal characters in the filenames. The Mac support, in most case, makes this work correctly.

This is not really a scripting issue. It is a compatibility and deployment issue.

User avatar
waynecierkowski
Posts: 23
Joined: Wed May 14, 2014 11:40 am

Re: Path Too Long

Post by waynecierkowski » Thu Aug 06, 2015 11:57 am

Not really. I have it working and I discovered the solution in the help section for New-PSDrive in PowerShell studio.

Please see the attached screen shot.
Attachments
PSDrive-Mapping.png
PSDrive-Mapping.png (28.8 KiB) Viewed 2080 times

Locked