Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need to find a way to see what account services have in their 'log on' properties

Posted on 2014-02-17
9
Medium Priority
?
323 Views
Last Modified: 2014-03-03
Hi, all. We have a user who is no longer with our company who used his username as a logon for some Windows services. I need to be able to run a query (report or 3rd party) on the domain to find out which services have this username associate with them. Any assistance would be greatly appreciated. Thanks in advance.

-R
0
Comment
Question by:roycbene
9 Comments
 
LVL 15

Expert Comment

by:Giovanni Heward
ID: 39865202
Try...

wmic service get Name,StartName

Open in new window


Combine with PsExec to run remotely.
0
 
LVL 3

Author Comment

by:roycbene
ID: 39865235
Thanks for the reply.

That works for an individual machine or even one machine at a time remotely. However, I need to be able to pinpoint an individual username. We have a lot of machines on our network and I need to be able to locate these logon accounts relatively quickly.
0
 
LVL 9

Expert Comment

by:Beartlaoi
ID: 39865242
Heres a VBScript that should do just what you want
Set args = Wscript.Arguments
If args.Count < 1 Then
	WScript.Echo "Usage: <ServerName> [UserName]"
	WScript.Quit
End If

strComputer = args(0)
WScript.Echo strComputer & " service accounts"
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery ("Select * from Win32_Service ")
For Each objService in colListOfServices
	bDisplayIt = True
	If args.Count >= 2 Then
		bDisplayIt = False
		For i = 1 to Args.Count - 1
			If UCase(objService.StartName) = UCase(args(i)) Then bDisplayIt = True
		Next
	End If
	If bDisplayIt Then wscript.echo objService.Name & ",""" & objService.DisplayName & """,""" & objService.StartName & """"
Next

Open in new window

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 3

Author Comment

by:roycbene
ID: 39865263
Beartlaoi,

Thanks for the reply. I need to be able to run this on all the servers in my domain. This seems to be for a single machine, or am I wrong? If I am wrong, where would I run it from?
0
 
LVL 3

Author Comment

by:roycbene
ID: 39865382
I actually found the answer just writing a simple powershell script that queries a list of servers in a text file. Thanks for trying!
0
 
LVL 3

Author Comment

by:roycbene
ID: 39865445
I've requested that this question be closed as follows:

Accepted answer: 0 points for roycbene's comment #a39865382

for the following reason:

Found my own answer.
0
 
LVL 15

Expert Comment

by:Giovanni Heward
ID: 39865446
Why don't you post the script for prosperity and then accept that answer?
0
 
LVL 57

Expert Comment

by:McKnife
ID: 39865462
You could use the freeware "service credential manager", does just what you need.
0
 
LVL 15

Accepted Solution

by:
Giovanni Heward earned 1500 total points
ID: 39865467
@echo off
setlocal enabledelayedexpansion
if not exist machines.txt	(
	for /f "tokens=2 delims==" %%c in ('dsquery * domainroot -limit 0 -filter "(&(objectCategory=computer)(operatingSystem=Windows Server*))"') do (
		set comp=%%c
		set comp=!comp:~0,-3!
		echo !comp!>>machines.txt
	)
)
for /f %%s in (machines.txt) do (call :getsvc %%s)
goto :eof

:getsvc
set /p p=Building service name list for %1...<nul
psservice \\%1 config>%1.txt 2>nul
echo Done.
goto :eof

Open in new window

0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

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

The top devops trends for 2017 are focused on improved deployment frequency, decreased lead time for change and decreased MTTR.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
Suggested Courses

972 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