New to PS – learning foreach and need a hand

I have a list of URL’s that I want to make shortcuts of on a folder on my desktop. It’s 25 URL’s and I want to name each shortcut to match the URL and so I have a list of these items.

Everything around the foreach cmdlet has a $key and $var.key and I’m not sure how to name/list my URL’s so that I reference them again in my script. Here is my script:

#URL's $URL =@{ "$1" = 'mypathorurl' $2 = 'mysecondpathurl' $3 = 'thisgoesontill25' $url = @{"key" = "value"} foreach($key in $url.Keys) { $WshShell = New-Object -ComObject Wscript.Shell $Shortcut = $WshShell.CreateSHortcut("C:UsersusernameDesktopyour shortcuts$($SECONDVARIABLE) $Shortcut.TargetPath = "$URL" $Shortcut.Save() } 

It is obviously missing a bunch. I don’t know where or how to put in my second set of variables (the name convention for the shortcuts).

I know it’s a lot to ask and I’m very behind on knowledge, but just curious if I’m close or miles off to the point where I’ll just need to learn a bit more and then do this manually for now?

submitted by /u/MyOtherSide1984
[link] [comments]

Leave a Reply