I'm trying to display the name (just the name) of all of the installed services that contain the string "SQL". For example, I want to see
So I try this:
Get-WmiObject Win32_Service
This displays all of the services, but as a list.
Exit Code : 0
Name : ProtectedStorage
ProcessId : 664
StartMode : Manual
State : Running
Status : OK
Exit Code : 1077
Name : QWAVE
ProcessId : 0
StartMode : Manual
State : Stopped
Status : OK
(etc...)
This is good, but I just want to see the name. So I type:
Get-WmiObject Win32_Service | select-object Name
And I get what I expect:
sppuinotfy
SQLAgent$SQL2008_RT
SQLBrowser
SQLWriter
SSDPSRV
(etc ..)
All is good. I take the next step of filtering the names to only include SQL related ones:
Get-WmiObject Win32_Service | select-object Name | select-string -pattern 'SQL'
And now it's confusing. Here is my output:
@{Name=BcmSqlStartupSvc}
@{Name=MSOLAP$SQL2008_R2}
@{Name=MSSQL$SQL2008_R2}
(etc ...)
Why am I getting this output, instead of just the names? What should I be typing to get just the names?
You can use Get-Service instead of get-WMIObject and do it like this"
get-service sql* | select -expand name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With