3

For some PS script, I need Get-ChildItem to work with '\\?\...' I tried with the original version, 4.0, but no luck :

Get-ChildItem : Illegal characters in path.

I tried on my PC (Win 10 1703) and it works correctly :

Get-ChildItem -LiteralPath '\\?\C:\'


    Directory: \\?\C:


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       03/12/2018     16:23                driver
d-----       13/11/2018     12:14                EmpirumPackages
d-----       13/11/2018     10:27                FibocomLog
d-----       15/11/2018     16:01                Intel
d-----       15/06/2018     17:27                PerfLogs
d-r---       18/12/2018     08:12                Program Files
d-r---       12/12/2018     10:59                Program Files (x86)
d-r---       18/11/2018     07:06                Users
d-----       14/12/2018     08:36                Windows
-a----       18/12/2018     08:35        9756932 action.log
-a----       13/11/2018     10:11         655360 alertlog.dat
-a----       13/11/2018     12:14          15361 Thininstaller.log

(I copy pasted the command so no problem here)

I read somewhere that it was working from PS 5.0 and onwards, therefore I installed PS 5.1 on my Win 2012 server but still no luck.

Get-ChildItem : Illegal characters in path.

Here is my server output :

Name                           Value
----                           -----
PSVersion                      5.1.14409.1005
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1005
CLRVersion                     4.0.30319.34014
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

And my PC output

Name                           Value
----                           -----
PSVersion                      5.1.15063.1478
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.15063.1478
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Any idea what's happening ?

2
  • The versions are not the same. Refer to the build codes.
    – Colyn1337
    Dec 18, 2018 at 19:29
  • I know but I got the last package from MS
    – JeanneD4RK
    Dec 18, 2018 at 23:32

2 Answers 2

0

Looks like you are not running the newest PS 5.1 build. It should be something like 5.1.17xxx.xxx.

How did you update your PowerShell?
I would recommend getting newest WPF 5.1 from the MS Docs

Update

Did some digging, and it appears that for server 2012 and below the highest build number available is a 5.1.14xxx from the WPF 5.1 installer. If it does not update through Windows Updates I have not found any documentation that says you can update the build.

The only way I can think of to solve this would be to install PowerShell 6 (PowerShell Core). I have just tested and it works fine in Core also. This is installed side by side with your Windows PowerShell and uses the pwsh.exe to start.

However, do note that not all modules are available for Core yet, so if you use a module where you don't have it native for core, you can use the Windows PowerShell Compatibility module

2
0

On my System (not Windows Server), the command

Get-ChildItem -LiteralPath 

works as asumed. Maybe you try this?

1
  • I'm already using this arg (2nd code block)
    – JeanneD4RK
    Dec 18, 2018 at 8:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .