question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`New-Item -ItemType Junction` checks for invalid parameter (Target)

See original GitHub issue

Prerequisites

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:closed
  • Created 3 months ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
sdwheelercommented, Jun 23, 2023

@gaiking-uk I submitted a PR to change the error message.

1reaction
sdwheelercommented, Jun 23, 2023

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found