Solved

Show computer name with Get-WmiObject win32_service

Posted on 2010-11-24
3
2,223 Views
Last Modified: 2012-05-10
Using PowerShell, I am trying to get a list of multiple computers' services with their computername, name, state, and startmode.

Essentially, I am looking to have a nicely formatted list of services with the computer name, service name, startup type, and current state. I am able to get a list of the services from multiple machines, but cannot get the computer name outputted.  Here is what I am working with, but in this case obviously the ComputerName column is blank:

Get-WmiObject win32_service -computername server1, server2, server3 | sort -property StartMode | format-table ComputerName, Name, StartMode, State -autosize

If I use Get-Service in a similar fashion as above, I am able to pull the computer/machine name, but then I am unable to pull the Startup type.

Any clues?
Get-WmiObject win32_service -computername server1, server2, server3 | sort -property StartMode | format-table ComputerName, Name, StartMode, State -autosize

ComputerName Name                                StartMode State
------------ ----                                --------- -----
             CryptSvc                            Auto      Running
             clr_optimization_v4.0.30319_64      Auto      Stopped


^It would be nice to see something like:

ComputerName Name                                StartMode State
------------ ----                                --------- -----
Server1      CryptSvc                            Auto      Running
Server2      clr_optimization_v4.0.30319_64      Auto      Stopped

Open in new window

0
Comment
Question by:CecilAdmin
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
KenMcF earned 500 total points
ID: 34206442
Instead of computername use __Server

There are two "_"
0
 

Author Comment

by:CecilAdmin
ID: 34206467
^Beast...

Is there a list of these variables around?
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34206543
The best thing to do is use the get-member or list all. Here is an example with pulling a single service so you do not get to much data back

gwmi win32_service | Where{$_.name -eq "Win32Time"} | FL *

gwmi win32_service | Where{$_.name -eq "Win32Time"} | get-member
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question