Update New-Item unknown item type message#27522
Conversation
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.' |
There was a problem hiding this comment.
Addressed in 41e21d913: the test now asserts the stable FullyQualifiedErrorId and checks only the supported item-type tokens instead of matching the full localized message.
| </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> |
There was a problem hiding this comment.
Addressed in 41e21d913: the resource string now uses a spaced conventional list: "file", "directory", "symboliclink", "junction", or "hardlink".
271df18 to
41e21d9
Compare
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 -UseNuGetOrgpwsh.exe:New-Item -ItemType UnknownTyperejects the type and the message includes bothjunctionandhardlink.