?
Solved

List Service Accounts on Services.

Posted on 2011-09-08
9
Medium Priority
?
773 Views
Last Modified: 2012-06-27
Dear All,

I need your help, I would like to list all Service Accounts used on Services, but we have to ignore the Services that use "LocalSystem - Local Service - Network Service"

I would like to see "Service Name" & "Service Account" for each service in Excel file if is possible.

e.g.

I would like to specify mutiple computers, because I have to gather all service accounts used.


Thanks in advance,
0
Comment
Question by:Gonzalo Becerra
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 13

Expert Comment

by:Felix Leven
ID: 36503617
gwmi win32_service | where {($_.startname -ne "LocalSystem") -and ($_.startname -ne "networkservice") } | select name, startname, caption | Export-Csv c:test.csv

0
 
LVL 1

Author Comment

by:Gonzalo Becerra
ID: 36503875
Thanks,

Just to change something I would like to change the where I would like only include the startname that start with "domain\"

And the last think is how can I specify .txt file to read the servers and execute the same query in all servers?.

Thanks in advance,
0
 
LVL 1

Author Comment

by:Gonzalo Becerra
ID: 36504003
I just filter only by the accounts with specific domains:

gwmi win32_service | where {($_.startname -like "domain\*")} | select name, startname, caption | Export-Csv c:test.csv
 

Could you please help me to run in multiple servers? I would like to read .txt file with all servernames.
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 71

Expert Comment

by:Chris Dent
ID: 36506098
There are a couple of approaches you can adopt. You can lump all your servers together:
$Servers = Get-Content MyList.txt
Get-WmiObject Win32_Service -Filter "StartName LIKE "domain\\%" -ComputerName $Servers |
  Select-Object Name, StartName, Caption | Export-Csv c:\test.csv -NoTypeInformation

Open in new window

Alternatively, you can manually loop, which is perhaps a bit more fault tolerant:
Get-Content MyList.txt | ForEach-Object {
  Get-WmiObject Win32_Service -Filter "StartName LIKE "domain\\%" -ComputerName $_
} | Select-Object Name, StartName, Caption | Export-Csv c:\test.csv -NoTypeInformation

Open in new window

I moved your Where-Object filter into the Filter parameter in the WMI query, it's a bit more efficient, if you get your head around the syntax :) % is equivalent to *, and we have to escape \ with another \.

Chris
0
 
LVL 1

Author Comment

by:Gonzalo Becerra
ID: 36506620
Hi Chris,

Thank you for your collaboration, I would like to comment I have the following error when I run the alternative #2.


Error.jpg
0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 36506628
Apologies, I thought I fixed that.
Get-Content MyList.txt | ForEach-Object {
  Get-WmiObject Win32_Service -Filter "StartName LIKE 'domain\\%'" -ComputerName $_
} | Select-Object Name, StartName, Caption | Export-Csv c:\test.csv -NoTypeInformation

Open in new window

Chris
0
 
LVL 1

Author Comment

by:Gonzalo Becerra
ID: 36506658
Cool Chris Thanks a lot...It's working the last think how can I add column with the ServerName? To identify this service is from this server.
0
 
LVL 71

Accepted Solution

by:
Chris Dent earned 2000 total points
ID: 36506669
We can either take the value from the file we read, or we can pick on one of the values it returns. This version picks on the returned values, it's simpler :)
Get-Content MyList.txt | ForEach-Object {
  Get-WmiObject Win32_Service -Filter "StartName LIKE 'domain\\%'" -ComputerName $_
} | Select-Object SystemName, Name, StartName, Caption | Export-Csv c:\test.csv -NoTypeInformation

Open in new window

Chris
0
 
LVL 1

Author Closing Comment

by:Gonzalo Becerra
ID: 36506703
Excellent, you are the best Chris, Thanks a lot for your help.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
This tutorial will show how to push an installation of Backup Exec to an additional server in both 2012 and 2014 versions of the software. Click on the Backup Exec button in the upper left corner. From here, select Installation and Licensing, then I…
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…

719 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