# Get-ChildItem -LiteralPath $Path -Directory -Recurse -ErrorVariable errvar | Select-Object -ExpandProperty FullName

**URL:** <https://forums.powershell.org/t/get-childitem-literalpath-path-directory-recurse-errorvariable-errvar-select-object-expandproperty-fullname/23116>\
**Category:** PowerShell Help\
**Created:** [November 7, 2023, 8:44am UTC](https://forums.powershell.org/t/get-childitem-literalpath-path-directory-recurse-errorvariable-errvar-select-object-expandproperty-fullname/23116 "2023-11-07T08:44:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![brindha](https://avatars.discourse-cdn.com/v4/letter/b/9d8465/32.png) [@brindha](https://forums.powershell.org/u/brindha)\
**Post date:** [November 7, 2023, 8:44am UTC](https://forums.powershell.org/t/get-childitem-literalpath-path-directory-recurse-errorvariable-errvar-select-object-expandproperty-fullname/23116/1 "2023-11-07T08:44:29Z")

</div>

Use case: Trying to get all the folders in the D folder with folder size and there are folders whose name is very long resulting in the below error. Using Powershell version of 5.0 and tried literal path still error remains the same.  
Error:  
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 charac  
ters.

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [November 7, 2023, 9:55am UTC](https://forums.powershell.org/t/get-childitem-literalpath-path-directory-recurse-errorvariable-errvar-select-object-expandproperty-fullname/23116/2 "2023-11-07T09:55:53Z")

</div>

Brindha,  
Welcome to the forum. 👋🏼

Have you enabled the Long Path Support?

> **[Maximum Path Length Limitation - Win32 apps](https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry#enable-long-paths-in-windows-10-version-1607-and-later)**
>
> Maximum path length limitation.

---

<div class="post-metadata">

**Author:** ![brindha](https://avatars.discourse-cdn.com/v4/letter/b/9d8465/32.png) [@brindha](https://forums.powershell.org/u/brindha)\
**Post date:** [November 7, 2023, 10:21am UTC](https://forums.powershell.org/t/get-childitem-literalpath-path-directory-recurse-errorvariable-errvar-select-object-expandproperty-fullname/23116/3 "2023-11-07T10:21:37Z")

</div>

@Olaf, Thanks. We will be taking the directory size of remote servers where we don’t have access to enable long paths or change any existing values in HKLM

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [November 7, 2023, 10:54am UTC](https://forums.powershell.org/t/get-childitem-literalpath-path-directory-recurse-errorvariable-errvar-select-object-expandproperty-fullname/23116/4 "2023-11-07T10:54:27Z")

</div>

Then you might talk to the responsible people about. 🤷🏼‍♂️

---

<div class="post-metadata">

**Author:** ![brindha](https://avatars.discourse-cdn.com/v4/letter/b/9d8465/32.png) [@brindha](https://forums.powershell.org/u/brindha)\
**Post date:** [November 7, 2023, 11:48am UTC](https://forums.powershell.org/t/get-childitem-literalpath-path-directory-recurse-errorvariable-errvar-select-object-expandproperty-fullname/23116/5 "2023-11-07T11:48:17Z")

</div>

Without enabling the long path is there any workaround.

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [November 7, 2023, 11:50am UTC](https://forums.powershell.org/t/get-childitem-literalpath-path-directory-recurse-errorvariable-errvar-select-object-expandproperty-fullname/23116/6 "2023-11-07T11:50:04Z")

</div>

Nothing I know of. 🤷🏼‍♂️

---

<div class="post-metadata">

**Author:** ![brindha](https://avatars.discourse-cdn.com/v4/letter/b/9d8465/32.png) [@brindha](https://forums.powershell.org/u/brindha)\
**Post date:** [November 7, 2023, 11:57am UTC](https://forums.powershell.org/t/get-childitem-literalpath-path-directory-recurse-errorvariable-errvar-select-object-expandproperty-fullname/23116/7 "2023-11-07T11:57:50Z")

</div>

ok. Thanks for the info.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [November 7, 2023, 7:52pm UTC](https://forums.powershell.org/t/get-childitem-literalpath-path-directory-recurse-errorvariable-errvar-select-object-expandproperty-fullname/23116/8 "2023-11-07T19:52:40Z")

</div>

> [@brindha](#):
>
> 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 charac  
> ters.

Take a look at this:

[.net - How can I get PowerShell’s Get-ChildItem command to list files in a path longer than 260 characters? - Stack Overflow](https://stackoverflow.com/questions/76833147/how-can-i-get-powershells-get-childitem-command-to-list-files-in-a-path-longer)

TLDR; there’s a workaround that someone mentions that doesn’t seem to require enabling long path support.

Not confident it will work but might be worth giving a shot as it seems pretty easy to add.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [February 7, 2024, 6:27am UTC](https://forums.powershell.org/t/get-childitem-literalpath-path-directory-recurse-errorvariable-errvar-select-object-expandproperty-fullname/23116/9 "2024-02-07T06:27:21Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
