?
Solved

Show computer name with Get-WmiObject win32_service

Posted on 2010-11-24
3
Medium Priority
?
2,689 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 2000 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

A Cyber Security RX to Protect Your Organization

Join us on December 13th for a webinar to learn how medical providers can defend against malware with a cyber security "Rx" that supports a healthy technology adoption plan for every healthcare organization.

Question has a verified solution.

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

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Loops Section Overview

839 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