Sorry for the late response. I went to sleep.Thanks for taking time to answer my questions, and write that code on your phone, bet that was fiddly!![]()
Just a bit confused about that last line:
cmd /c "mklink /J `"$($junction.Key)`" `"$($junction.Value)`""
That works as is I assume?
That was the code I couldn't get to work on my PC. I just get the "You don't have permissions..." message, as I'm writing to ProgramFiles.
I am also wanting to create links in ProgramData, AppData, Documents.
Can I use this instead:
New-Item -ItemType Junction -Path `"$($junction.Key)`" -Target `"$($junction.Value)`"
Are the quote marks correctly placed?
EDIT: Doesn't work. Neither of the above works. Runs, but no Junctions created.
EDIT: Solved by removing the ` through out last line.
Thanks for the help
Ups, my bad

You can create variables like:
$path = "C:\Path\To\Junctions"
And you can simply use the variable by replacing the path with the variable ($path). The $ is necessary.
Anyway, sorry for my last answer, I was too sleepy when I wrote that. You can use this simpler approach:
Code:
$path = "C:\Path\To\Junctions"$junctions = @("C:\Target\Folder1", "C:\Target\Folder2")foreach ($junction in $junctions) { $junctionPath = "$path\$([System.IO.Path]::GetFileName($junction))" New-Item -ItemType Junction -Path $junctionPath -Target $junction}
Statistics: Posted by RicardoTM — Today, 12:56 am — Replies 11 — Views 514