question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New-Item cmdlet fails to create folder on PowerShell 7.0.0-preview.2

See original GitHub issue

Steps to reproduce

  1. Create Ubuntu 18.04 VM in Azure
  2. wget https://github.com/PowerShell/PowerShell/releases/download/v7.0.0-preview.2/powershell-preview_7.0.0-preview.2-1.ubuntu.18.04_amd64.deb
  3. sudo apt install ./powershell-preview_7.0.0-preview.2-1.ubuntu.18.04_amd64.deb
  4. pwsh-preview
  5. new-item -ItemType Directory ./newfolder

In bash run

export LC_ALL=C.UTF-8
export LANG=C.UTF-8
pwsh

Then, run

 New-Item -ItemType Directory ./bas

Expected behavior

new folder is created.


Actual behavior

PS /home/amitsaraf> new-item -ItemType Directory ./newfolder new-item : The type is not a known type for the file system. Only “file”,“directory” or “symboliclink” can be specified. At line:1 char:1

  • new-item -ItemType Directory ./newfolder
  • CategoryInfo : InvalidArgument: (😃 [New-Item], PSArgumentException
  • FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.NewItemCommand

Environment data


Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
adityapatwardhancommented, Jul 18, 2019

The problem reproduces when the LANG is set as C.UTF-8. To workaround:

export LANG=en_US.UTF-8
pwsh-preview
0reactions
msftbot[bot]commented, Aug 20, 2019

🎉This issue was addressed in #10186, which has now been successfully released as v7.0.0-preview.3.🎉

Handy links:

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using new-item to create folder occasionally throws error in ...
I have a powershell script which creates folders in an order, the same code creates the first folder, but throws error for the...
Read more >
New-Item (Microsoft.PowerShell.Management)
The New-Item cmdlet creates a new item and sets its value. The types of items that can be created depend on the location...
Read more >
Unable to create folders in current path with New-Item and ...
I am trying to use the New-Item -ItemType Directory in order make a folder, in the directory the script is located, and move...
Read more >
PowerShell can't create folder on network mount
The first command works fine (assuming you have a c$ share enabled and are able to access it), and the second command gives...
Read more >
How to Create Files and Folders with PowerShell
Let's dive in and look at how to create files and folders using the New-item, Add-Content, and Test-Path cmdlets. Advertisement. How to create...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found