[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Need PS script to get List of Services for non-system accounts

Posted on 2013-01-30
4
Medium Priority
?
318 Views
Last Modified: 2013-02-03
Hello Experts,

      I am in need of a special Power-Shell script that can scan a list of servers (located in text document), get a list of “Windows Services” running “that are started by none-system account” and then dump information in to excel document for each device.  What do I mean by “none-system account”..?  I need to get the pasiffic windows services running on each computer that have been started by the “Administrator user account” or other User accounts (i.e. not the System/Local-Resource). Then Export that information for each device in to an excel file…..
0
Comment
Question by:Mike
  • 2
  • 2
4 Comments
 
LVL 41

Expert Comment

by:footech
ID: 38836522
I'm unclear on a few points.  Do you want a separate document for each computer?  Is a .CSV file OK?  What information about the service do you need?  Do you only want the services that are running or ones that are in other states as well?
0
 

Author Comment

by:Mike
ID: 38836579
I looking to put everything on to one spreadsheet( i.e. csv) with the computer name, service running,  the status, and user account its tied too ( i.e. administrator, other user accounts) that are not running by the system account... thank you for your help with this task...
0
 
LVL 41

Accepted Solution

by:
footech earned 2000 total points
ID: 38836864
This should do what you asked.  I haven't included any error checking for down computers or blank results, so you may see some errors.  BTW, above you mentioned "status" of a service, so that's what I included, but just wanted make sure you knew that "status" is different than "state".
$out = @()
$computers = Get-Content c:\temp\computerlist.txt
ForEach ($computer in $computers)
{
  $out += ((gwmi win32_service -computername $computer -filter "StartName != 'LocalSystem' AND NOT StartName LIKE 'NT Authority\\%' AND State = 'Running'") | Select @{name="Computer";expression={$computer}},Name,Status,@{name="Account";expression={$_.StartName}})
}
$out | Export-CSV c:\temp\services.csv -notype

Open in new window

0
 

Author Closing Comment

by:Mike
ID: 38849245
The script worked perfect....  thank you for your help.......:;;
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will learn how to dynamically set the form action using jQuery.
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month19 days, 11 hours left to enroll

872 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