Skip to content

Update New-Item unknown item type message#27522

Open
KirtiRamchandani wants to merge 1 commit into
PowerShell:masterfrom
KirtiRamchandani:fix/new-item-itemtype-message
Open

Update New-Item unknown item type message#27522
KirtiRamchandani wants to merge 1 commit into
PowerShell:masterfrom
KirtiRamchandani:fix/new-item-itemtype-message

Conversation

@KirtiRamchandani
Copy link
Copy Markdown

Summary

  • Include junction and hardlink in the file-system provider's unknown New-Item -ItemType error message
  • Add a regression assertion for the supported item-type list

Details

The filesystem provider already recognizes file, directory, symboliclink, junction, and hardlink, but the unknown-type error message still listed only the older three values.

Fixes #27248

Validation

  • Start-PSBuild -NoPSModuleRestore -CI -SkipExperimentalFeatureGeneration -UseNuGetOrg reached publish and produced pwsh.exe; the Windows PowerShell-hosted local run failed afterward in post-publish cleanup (Clear-NativeDependencies parameter binding).
  • Direct validation with the built pwsh.exe: New-Item -ItemType UnknownType now rejects the type and the message includes both junction and hardlink.
  • Full FileSystem.Tests.ps1 local run includes the new regression as passing, but this non-admin Windows session has unrelated existing failures for symlink/admin-dependent cases and a missing Windows Calculator AppX path.

Copilot AI review requested due to automatic review settings May 24, 2026 18:52
@KirtiRamchandani KirtiRamchandani requested a review from a team as a code owner May 24, 2026 18:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates the FileSystem provider’s “unknown item type” messaging to reflect additional supported item types, and adds a regression test to validate the behavior.

Changes:

  • Expand the UnknownType resource string to include junction and hardlink
  • Add a Pester test asserting the updated error message when New-Item -ItemType is unknown

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 Adds a test to validate the error surfaced for an unknown -ItemType includes all supported types.
src/System.Management.Automation/resources/FileSystemProviderStrings.resx Updates the UnknownType localized string to include junction and hardlink.

New-Item -Path (Join-Path $TestDrive "unknown-type") -ItemType UnknownType -ErrorAction Stop
} | Should -Throw -PassThru

$errorRecord.Exception.Message | Should -BeExactly 'The type is not a known type for the file system. Only "file","directory","symboliclink","junction" or "hardlink" can be specified.'
</data>
<data name="UnknownType" xml:space="preserve">
<value>The type is not a known type for the file system. Only "file","directory" or "symboliclink" can be specified.</value>
<value>The type is not a known type for the file system. Only "file","directory","symboliclink","junction" or "hardlink" can be specified.</value>
@KirtiRamchandani KirtiRamchandani force-pushed the fix/new-item-itemtype-message branch from 271df18 to 41e21d9 Compare May 24, 2026 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"The type is not a known type for the file system" error message misses Junction and HardLink

2 participants