Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Equivalent for tasklist /svc ?

Reply
 
Old 06-08-2006   #1 (permalink)
Andrew Watt [MVP]


 
 

Equivalent for tasklist /svc ?

Is there a PowerShell equivalent for tasklist /svc. I feel it must be
there but can't find a PowerShell equivalent.

I want output like I get from
tasklist /FI "ImageName eq svchost.exe" /svc

Thanks

Andrew Watt MVP

My System SpecsSystem Spec
Old 06-08-2006   #2 (permalink)
Alex K. Angelopoulos [MVP]


 
 

Re: Equivalent for tasklist /svc ?

I don't think it's there, but I want it too, now.



"Andrew Watt [MVP]" <SVGDeveloper@aol.com> wrote in message
news:m4kg82d9lep7i3t9t0a4d989n1sjbqu27l@4ax.com...
> Is there a PowerShell equivalent for tasklist /svc. I feel it must be
> there but can't find a PowerShell equivalent.
>
> I want output like I get from
> tasklist /FI "ImageName eq svchost.exe" /svc
>
> Thanks
>
> Andrew Watt MVP



My System SpecsSystem Spec
Old 06-08-2006   #3 (permalink)
/\\/\\o\\/\\/


 
 

Re: Equivalent for tasklist /svc ?

Alex K. Angelopoulos [MVP] wrote:
> I don't think it's there, but I want it too, now.
>
>
>
> "Andrew Watt [MVP]" <SVGDeveloper@aol.com> wrote in message
> news:m4kg82d9lep7i3t9t0a4d989n1sjbqu27l@4ax.com...
>> Is there a PowerShell equivalent for tasklist /svc. I feel it must be
>> there but can't find a PowerShell equivalent.
>>
>> I want output like I get from
>> tasklist /FI "ImageName eq svchost.exe" /svc
>>
>> Thanks
>>
>> Andrew Watt MVP

>
>


$FormatEnumerationLimit = 100
gwmi win32_service |? {$_.PathName -match 'svchost.exe'} | group
ProcessId | ft -Wrap

gr /\/\o\/\/
My System SpecsSystem Spec
Old 06-08-2006   #4 (permalink)
/\\/\\o\\/\\/


 
 

Re: Equivalent for tasklist /svc ?

little bug some missed the .exe :

gwmi win32_service |? {$_.PathName -match 'svchost'} | group ProcessId |
ft -Wrap

will get some more (so now the same as tasklist )

gr /\/\o\/\/

/\/\o\/\/ wrote:
> Alex K. Angelopoulos [MVP] wrote:
>> I don't think it's there, but I want it too, now.
>>
>>
>>
>> "Andrew Watt [MVP]" <SVGDeveloper@aol.com> wrote in message
>> news:m4kg82d9lep7i3t9t0a4d989n1sjbqu27l@4ax.com...
>>> Is there a PowerShell equivalent for tasklist /svc. I feel it must be
>>> there but can't find a PowerShell equivalent.
>>>
>>> I want output like I get from
>>> tasklist /FI "ImageName eq svchost.exe" /svc
>>>
>>> Thanks
>>>
>>> Andrew Watt MVP

>>
>>

>
> $FormatEnumerationLimit = 100
> gwmi win32_service |? {$_.PathName -match 'svchost.exe'} | group
> ProcessId | ft -Wrap
>
> gr /\/\o\/\/

My System SpecsSystem Spec
Old 06-08-2006   #5 (permalink)
Jim Holbach


 
 

Re: Equivalent for tasklist /svc ?

I noticed a small anomaly between the tasklist result and your result. gwmi
is reporting on all services, even those that are not running. The stopped
processes are all shown as PID 0.

So I took the liberty of making a small change to your code to get rid of
these non-running services:

gwmi win32_service |? {$_.PathName -match 'svchost' -and $_.ProcessId -ne 0}
| group ProcessId | ft -Wrap


---
Jim Holbach

"/\/\o\/\/" <no@spam.mow> wrote in message
news:umDMkpyiGHA.4512@TK2MSFTNGP04.phx.gbl...
> little bug some missed the .exe :
>
> gwmi win32_service |? {$_.PathName -match 'svchost'} | group ProcessId |
> ft -Wrap
>
> will get some more (so now the same as tasklist )
>
> gr /\/\o\/\/
>
> /\/\o\/\/ wrote:
>> Alex K. Angelopoulos [MVP] wrote:
>>> I don't think it's there, but I want it too, now.
>>>
>>>
>>>
>>> "Andrew Watt [MVP]" <SVGDeveloper@aol.com> wrote in message
>>> news:m4kg82d9lep7i3t9t0a4d989n1sjbqu27l@4ax.com...
>>>> Is there a PowerShell equivalent for tasklist /svc. I feel it must be
>>>> there but can't find a PowerShell equivalent.
>>>>
>>>> I want output like I get from
>>>> tasklist /FI "ImageName eq svchost.exe" /svc
>>>>
>>>> Thanks
>>>>
>>>> Andrew Watt MVP
>>>
>>>

>>
>> $FormatEnumerationLimit = 100
>> gwmi win32_service |? {$_.PathName -match 'svchost.exe'} | group
>> ProcessId | ft -Wrap
>>
>> gr /\/\o\/\/



My System SpecsSystem Spec
Old 06-09-2006   #6 (permalink)
Abhishek Agrawal [MSFT]


 
 

Re: Equivalent for tasklist /svc ?

Actually I wrote a blog on it recently at
http://spaces.msn.com/abhishek225/blog/cns!13469C7B7CE6E911!140.entry

I extend the Process object with a Service member


--
Abhishek Agrawal [MSFT]
MSH Team
http://spaces.msn.com/abhishek225
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.

"Andrew Watt [MVP]" <SVGDeveloper@aol.com> wrote in message
news:m4kg82d9lep7i3t9t0a4d989n1sjbqu27l@4ax.com...
> Is there a PowerShell equivalent for tasklist /svc. I feel it must be
> there but can't find a PowerShell equivalent.
>
> I want output like I get from
> tasklist /FI "ImageName eq svchost.exe" /svc
>
> Thanks
>
> Andrew Watt MVP



My System SpecsSystem Spec
Old 06-12-2006   #7 (permalink)
DBMwS


 
 

Re: Equivalent for tasklist /svc ?

I have added a new Script property named, "Service" in "types.ps1.xml" to
return service associated with the current Process object.

<Type>
<Name>System.Diagnostics.Process</Name>
<Members>
... Other membersets and properties ...
<ScriptProperty>
<Name>Service</Name>
<GetScriptBlock>
@(, (Get-WmiObject Win32_Service -Filter "ProcessId='$($this.Id)'" |
Group-Object ProcessId).Group)
</GetScriptBlock>
</ScriptProperty>
</Members>
</Type>

Now you can do
[^_^]PS[1]>gps svchost | select name,id,service | ft -auto

Name Id Service
---- -- -------
SVCHOST 920 {DcomLaunch, TermService}
SVCHOST 1016 {RpcSs}
SVCHOST 1116 {Dnscache}
SVCHOST 1176 {Alerter, LmHosts, SSDPSRV, WebClient}
SVCHOST 1196 {AudioSrv, Browser, CryptSvc, dmserver...}

Have fun...


"Abhishek Agrawal [MSFT]" wrote:

> Actually I wrote a blog on it recently at
> http://spaces.msn.com/abhishek225/blog/cns!13469C7B7CE6E911!140.entry
>
> I extend the Process object with a Service member
>
>
> --
> Abhishek Agrawal [MSFT]
> MSH Team
> http://spaces.msn.com/abhishek225
> Microsoft Corporation
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "Andrew Watt [MVP]" <SVGDeveloper@aol.com> wrote in message
> news:m4kg82d9lep7i3t9t0a4d989n1sjbqu27l@4ax.com...
> > Is there a PowerShell equivalent for tasklist /svc. I feel it must be
> > there but can't find a PowerShell equivalent.
> >
> > I want output like I get from
> > tasklist /FI "ImageName eq svchost.exe" /svc
> >
> > Thanks
> >
> > Andrew Watt MVP

>
>
>

My System SpecsSystem Spec
Old 06-12-2006   #8 (permalink)
Keith Hill [MVP]


 
 

Re: Equivalent for tasklist /svc ?

"DBMwS" <DBMwS@discussions.microsoft.com> wrote in message
news:460DE895-B22F-46C7-A6B0-EDA19143DE0F@microsoft.com...
>I have added a new Script property named, "Service" in "types.ps1.xml" to
> return service associated with the current Process object.
>
> <Type>
> <Name>System.Diagnostics.Process</Name>
> <Members>
> ... Other membersets and properties ...
> <ScriptProperty>
> <Name>Service</Name>
> <GetScriptBlock>
> @(, (Get-WmiObject Win32_Service -Filter "ProcessId='$($this.Id)'" |
> Group-Object ProcessId).Group)
> </GetScriptBlock>
> </ScriptProperty>
> </Members>
> </Type>


Nice! It would be even better if the team could get this into PowerShell
before V1 ships. :-)

--
Keith


My System SpecsSystem Spec
Old 06-12-2006   #9 (permalink)
DBMwS


 
 

Re: Equivalent for tasklist /svc ?

"DBMwS" wrote:

> I have added a new Script property named, "Service" in "types.ps1.xml" to
> return service associated with the current Process object.


Woops, typo. "types.ps1.xml" -> $pshome\types.ps1xml

My System SpecsSystem Spec
Old 06-12-2006   #10 (permalink)
Abhishek Agrawal [MSFT]


 
 

Re: Equivalent for tasklist /svc ?

> Nice! It would be even better if the team could get this into PowerShell
> before V1 ships. :-)
>
> --
> Keith


I would love to get this included but the chances are very very low In
the meantime checkout the Serive tab in the task manager in Vista Beta2.
Thats cool as well.

--
Abhishek Agrawal [MSFT]
http://spaces.msn.com/abhishek225
Windows PowerShell Team
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.


"Keith Hill [MVP]" <r_keith_hill@no.spam.thank.u.hotmail.com> wrote in
message news:uQEPHTmjGHA.5036@TK2MSFTNGP04.phx.gbl...
> "DBMwS" <DBMwS@discussions.microsoft.com> wrote in message
> news:460DE895-B22F-46C7-A6B0-EDA19143DE0F@microsoft.com...
>>I have added a new Script property named, "Service" in "types.ps1.xml" to
>> return service associated with the current Process object.
>>
>> <Type>
>> <Name>System.Diagnostics.Process</Name>
>> <Members>
>> ... Other membersets and properties ...
>> <ScriptProperty>
>> <Name>Service</Name>
>> <GetScriptBlock>
>> @(, (Get-WmiObject Win32_Service -Filter "ProcessId='$($this.Id)'" |
>> Group-Object ProcessId).Group)
>> </GetScriptBlock>
>> </ScriptProperty>
>> </Members>
>> </Type>

>
> Nice! It would be even better if the team could get this into PowerShell
> before V1 ships. :-)
>
> --
> Keith
>



My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Sidebar appears twice in tasklist Vista General
VB6 Equivalent .NET General
'runwait' equivalent PowerShell
Equivalent to $0? PowerShell
what is the equivalent of xp pro Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46