Q. How can I get just the first entry from a list of entries?

A. Assuming you're running something like this

$services = Get-Service

the easiest way to get just a certain number of first or last entries is

$service = Get-Service | Select-Object -first 1

There's also the -last parameter that works in a similar way. If you've saved the objects in a variable, as in these examples, you could also use syntax such as $services[0] to access the first object in the collection.

Do you have a Windows PowerShell question? Find more PowerShell FAQs, articles, and other resources at windowsitpro.com/go/DonJonesPowerShell.