Update New-Item unknown item type message#27522
Open
KirtiRamchandani wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
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
UnknownTyperesource string to includejunctionandhardlink - Add a Pester test asserting the updated error message when
New-Item -ItemTypeis 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> |
271df18 to
41e21d9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
junctionandhardlinkin the file-system provider's unknownNew-Item -ItemTypeerror messageDetails
The filesystem provider already recognizes
file,directory,symboliclink,junction, andhardlink, but the unknown-type error message still listed only the older three values.Fixes #27248
Validation
Start-PSBuild -NoPSModuleRestore -CI -SkipExperimentalFeatureGeneration -UseNuGetOrgreached publish and producedpwsh.exe; the Windows PowerShell-hosted local run failed afterward in post-publish cleanup (Clear-NativeDependenciesparameter binding).pwsh.exe:New-Item -ItemType UnknownTypenow rejects the type and the message includes bothjunctionandhardlink.FileSystem.Tests.ps1local 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.