In order to create symlinks in PowerShell, you need to use the following command :
New-Item -Path C:\temp\myLink -Target C:\Users\{me}\Documents\target.txt -ItemType SymbolicLink
I would like to implement a more straightforward syntax as shown below :
"C:\temp\myLink", "C:\Users\{me}\Documents\target.txt" | Ln
Ln
is a filter defined as such :
filter Ln {
New-Item -Path $_[0] -Target $_[1] -ItemType SymbolicLink
}
However, it doesn't work, and I would like to know how to access single elements of $_
, for instance in our case shouldn't we have $_[0] == "C:\temp\myLink"
?
Thanks in advance for your help !
CodePudding user response:
If you want to use the syntax proposed in your question an easy workaround would be to change your
If you want to send both elements together