diff --git a/src/System.Management.Automation/resources/FileSystemProviderStrings.resx b/src/System.Management.Automation/resources/FileSystemProviderStrings.resx index 360c2eceb7e..1314f6a3a0c 100644 --- a/src/System.Management.Automation/resources/FileSystemProviderStrings.resx +++ b/src/System.Management.Automation/resources/FileSystemProviderStrings.resx @@ -205,7 +205,7 @@ Directory {0} cannot be removed because it is not empty. - The type is not a known type for the file system. Only "file","directory" or "symboliclink" can be specified. + The type is not a known type for the file system. Only "file", "directory", "symboliclink", "junction", or "hardlink" can be specified. Cannot process the path because the specified path refers to an item that is outside the basePath. diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 index 3899ace7e3b..113abd3bcc6 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 @@ -79,6 +79,17 @@ Describe "Basic FileSystem Provider Tests" -Tags "CI" { $newFile.Name | Should -BeExactly $newTestFile } + It "New-Item reports all supported file system item types for an unknown item type" { + $errorRecord = { + New-Item -Path (Join-Path $TestDrive "unknown-type") -ItemType UnknownType -ErrorAction Stop + } | Should -Throw -PassThru + + $errorRecord.FullyQualifiedErrorId | Should -BeExactly "Argument,Microsoft.PowerShell.Commands.NewItemCommand" + foreach ($itemType in '"file"', '"directory"', '"symboliclink"', '"junction"', '"hardlink"') { + $errorRecord.Exception.Message | Should -Match ([regex]::Escape($itemType)) + } + } + It "Verify Remove-Item for directory" { $existsBefore = Test-Path $testDir Remove-Item -Path $testDir -Recurse -Force