0

my power shell version is

5.0

In windows 10, to get all files from desktop, i use

Get-ChildItem C:\Desktop\

This returns only the files but i want to get only the short-cut icons name in that directory.

I also use this

Get-ChildItem C:\Desktop\ -force|  where {$_.extension -eq ".lnk"}

but it also does not work.

Is that possible or is there any better way or is there any administrator or security issue?

Thanks in advance.

GuidoG
  • 11,359
  • 6
  • 44
  • 79
user6633897
  • 185
  • 1
  • 8

1 Answers1

2

The earlier you filter your results the better and quicker your query will be, so I'd use:

Get-ChildItem C:\Desktop\ -Filter *.lnk

Your path should also probably be c:\users\'username'\desktop or "$($env:userprofile)\desktop"

Jim Moyle
  • 637
  • 4
  • 11