Glad I can help.
I'm not quite sure why the output file does not have a name. The "output.txt" in the 'Add-Content $"output.txt" $description' statement actually specifies the file name. You can try to specify it explicitly by adding -path instruction, so becomes 'Add-Content -path $"output.txt" $description'.
Hitting Enter twice is normal.
I'm changing the script so that it has formatting you want (the first option, it's easier):
- Code: Select all
$links = get-childitem * -include *.lnk
$shell = New-Object -COM WScript.Shell
foreach ($lnk in $links){
$shortcut = $shell.CreateShortcut($lnk.FullName);
$description = "Target: " + $shortcut.TargetPath + "`r`nStart in: " + $shortcut.WorkingDirectory
Add-Content -path $"output.txt" $description
}
Edit: As for learing PowerShell, Technet's documentation is surprisingly good:
http://technet.microsoft.com/en-us/library/bb978525.aspx. "Getting Started" and "User Guide" are good to get familiar with the shell.
Edit2: Oh, and I almost forgot, of course check this free ebook:
http://powershell.com/cs/blogs/ebook/. It was written for v1 (current is versions 2) of PowerShell, but is still very good.