CompTIA A+ Core 2 (220-1202)Operational ProceduresEasy
A technician is writing a simple PowerShell script to check if a specific service is running on a Windows server. Which of the following cmdlets would be most appropriate for this task?
- AGet-Service
- BGet-Process
- CSet-Service
- DStart-Service
Show answer & explanationAnswer & explanation
Correct answer: A. Get-Service
The Get-Service cmdlet in PowerShell is specifically designed to retrieve information about services, including their status (running, stopped, etc.), making it the most appropriate choice for checking if a service is running.
Why the other options are wrong
- B. Get-Process retrieves information about running processes, not specifically Windows services.
- C. Set-Service is used to change the properties of a service, not to check its status.
- D. Start-Service is used to initiate a stopped service, not to query its current status.
Get-Service Cmdlet
A PowerShell cmdlet used to retrieve information about the services installed on a computer.
- Retrieves service status (running/stopped)
- Can filter by service name
- Part of PowerShell scripting
Memory trick: To see a service, you gotta Get it.