For more technical explainers on PowerShell, read our updated 2021 report: PowerShell 101: A Technical Explainer for IT Pros.
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 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.