Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8820843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:42:31+00:00 2026-06-14T05:42:31+00:00

On a Windows Server 2008 R2 VM, I upgraded PowerShell to v3 hoping to

  • 0

On a Windows Server 2008 R2 VM, I upgraded PowerShell to v3 hoping to take advantage of the Get-ChildItem (gci) performance improvement. This line ran without error in v2:

$search = gci $dir -recurse -exclude "*.mdf" | where {$_.length -gt 100mb}

After upgrading to v3, why does the same line give this error? The $dir value is unchanged.

gci : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less
than 248 characters.
At line:1 char:11
+ $search = gci $dir -recurse -exclude “*.mdf” | where {$_.length -gt 100mb}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ReadError: (\server.domain…DETAILS 1.0.prt:String) [Get-ChildItem], PathTooLongException
+ FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand

There is no change after applying Windows Updates and rebooting. I took a snapshot of the VM before upgrading PowerShell, so I have the luxury of toggling back and forth easily.

$errorActionPreference is Continue in both v2 and v3.

$search.count is 8 in both v2 and v3, so I’m not super concerned about missing stuff, but would like to understand the change in behavior.

I tried addding -force in v2, saw similar PathTooLong errors, and .count is 10. After adding -force in v3, .count was 9. I then reverted to v2 and again found 10 files with -force. It’s nevertheless possible that changing data under $dir could explain the .count difference, but in our environment, changing data couldn’t realistically explain the consistent presence of PathTooLong errors in v3, but not v2. Now that my curiosity has gotten the better of me, I’m hoping someone has a lead on this mystery and will spare me the error handling which, I admit, might offer more clues.

FWIW, the usage documentation on TechNet says it applies to both v2 and v3. The -Force parameter’s default value is False.

Some background on PowerShell and MAX_PATH from the v1 days.

On a Windows Server 2008 R2 VM, I upgraded PowerShell to v3 hoping to take advantage of the Get-ChildItem (gci) performance improvement. This line ran without error in v2:

$search = gci $dir -recurse -exclude "*.mdf" | where {$_.length -gt 100mb}

After upgrading to v3, why does the same line give this error? The $dir value is unchanged.

gci : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less
than 248 characters.
At line:1 char:11
+ $search = gci $dir -recurse -exclude “*.mdf” | where {$_.length -gt 100mb}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ReadError: (\server.domain…DETAILS 1.0.prt:String) [Get-ChildItem], PathTooLongException
+ FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand

There is no change after applying Windows Updates and rebooting. I took a snapshot of the VM before upgrading PowerShell, so I have the luxury of toggling back and forth easily.

$errorActionPreference is Continue in both v2 and v3.

$search.count is 8 in both v2 and v3, so I’m not super concerned about missing stuff, but would like to understand the change in behavior.

I tried addding -force in v2, saw similar PathTooLong errors, and .count is 10. After adding -force in v3, .count was 9. I then reverted to v2 and again found 10 files with -force. It’s nevertheless possible that changing data under $dir could explain the .count difference, but in our environment, changing data couldn’t realistically explain the consistent presence of PathTooLong errors in v3, but not v2. Now that my curiosity has gotten the better of me, I’m hoping someone has a lead on this mystery and will spare me the error handling which, I admit, might offer more clues.

FWIW, the usage documentation on TechNet says it applies to both v2 and v3. The -Force parameter’s default value is False.

Some background on PowerShell and MAX_PATH from the v1 days.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:42:32+00:00Added an answer on June 14, 2026 at 5:42 am

    I know that the PathTooLongException is not specific to PowerShell. It is thrown by the Win32 APIs that are called behind the scene. If you must work with long paths, you might find out if PowerShell will allow you to make use of the Unicode versions of the Win32 APIs instead. See here for information

    As for why version 2 did not throw the error, I can only presume that version 2 had “better” internal handling of the exception.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I run this Windows Server 2008 security update and this code block is
Environment: Windows Server 2008 R2 on Amazon EC2 Netbeans IDE with Glassfish started on
In Windows Server 2008 and Windows 7 there are new Events categorized under Applications
When Windows Server 2008 R2 was launched, the server core edition started to become
we are using Windows Server 2008 R2 O/S. We want to execute an script
I am connecting from Windows Server 2008 R2 to a Linux FTP Server running
I'm using a Windows Server 2008 x64 R2 machine as a development box. Amongst
I have a new WIndows Server 2008 R2 x64 DataCentre with Framework 3.5 SP1
We have Windows Server 2008 as our Production server hosted in RackSpace environment. Following
So on my server running Windows Server 2008 x64 R2 I installed the Java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.