Path Too Long

Ask your 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.
This topic is 8 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
waynecierkowski
Posts: 28
Last visit: Mon Jul 10, 2023 10:51 am

Path Too Long

Post by waynecierkowski »

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
Last visit: Thu Oct 22, 2015 1:10 pm

Path Too Long

Post by SAPIEN Support Forums »

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 ***
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Path Too Long

Post by jvierra »

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: 28
Last visit: Mon Jul 10, 2023 10:51 am

Re: Path Too Long

Post by waynecierkowski »

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...
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Path Too Long

Post by jvierra »

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: 28
Last visit: Mon Jul 10, 2023 10:51 am

Re: Path Too Long

Post by waynecierkowski »

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 3677 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Path Too Long

Post by jvierra »

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: 28
Last visit: Mon Jul 10, 2023 10:51 am

Re: Path Too Long

Post by waynecierkowski »

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 3675 times
This topic is 8 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked