`New-Item -ItemType Junction` checks for invalid parameter (Target)
See original GitHub issuePrerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
New-Item
parameter set / parameter checking gives an incorrect error message when trying to create a junction… It specifies that a Target
parameter is needed, however there is no parameter called Target
.
I raised this initially as a documentation issue #10199, but @sdwheeler advised that this is a bug as there is no parameter called Target
, and actually Target
is an alias for Value
Expected behavior
$JuncName = "Foo"
$JuncTarget = "D:\Junction_Target"
> New-Item -ItemType Junction -Name $JuncName -Path $JuncTarget
Junction created successfully.
Actual behavior
$JuncName = "Foo"
$JuncTarget = "D:\Junction_Target"
> New-Item -ItemType Junction -Name $JuncName -Path $JuncTarget
ERROR: Link "D:\Junction_Target" cannot be created because Target was not specified.
Error details
Link cannot be created because Target was not specified.
Environment data
> $PSVersionTable
Name Value
GitCommitId 7.3.4
OS Microsoft Windows 10.0.22621
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
Issue Analytics
- State:
- Created 3 months ago
- Comments:8
Top Results From Across the Web
New-Item (Microsoft.PowerShell.Management)
This command creates a directory named "Logfiles" in the C: drive. The ItemType parameter specifies that the new item is a directory, not...
Read more >powershell to resolve junction target path - symlink
The -ItemType parameter for New-Item accepts a new value, SymbolicLink. Now you can create symbolic links in a single line by running the...
Read more >PowerShell Create Directory with the New-Item Cmdlet
How to Create a Directory Junction with PowerShell. One of the parameters of the New-Item cmdlet is the ItemType parameter.
Read more >Visual Studio fails after upgradeing to 17.1.1.
InvalidOperationException : Failed to validate the Controller process being connected to. It then also shows The 'Global Hub Client Package' ...
Read more >readlink on Windows cannot read app exec links
msg349486 ‑ (view) Author: Steve Dower (steve.dower) * Date: 2019‑08‑12 18:49
msg349499 ‑ (view) Author: Steve Dower (steve.dower) * Date: 2019‑08‑12 21:20
msg349501 ‑ (view)...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@gaiking-uk I submitted a PR to change the error message.
The New-Item help page does document that Target is an alias for the Value parameter. We also include an example that uses
-Target
. The problem is the error message in PowerShell should reference the Value parameter, not its alias.See https://github.com/PowerShell/PowerShell/blob/04f503a3b7a1b6e493d86839efd70c542563bd3c/src/System.Management.Automation/resources/SessionStateStrings.resx#L595