how to list service accounts used to start services on a windows 2012 r2 server

DK Bridges 1 Reputation point
2021-12-09T03:25:55.01+00:00

I need to document which services on my Windows 2012 R2 and Windows 2016 servers have service accounts starting them. I do not want to log into hundreds of servers and manual gather this information. There has got to be a better way. Do you know how I accomplish this task?

Windows Server 2016
Windows Server 2016
A Microsoft server operating system that supports enterprise-level management updated to data storage.
2,436 questions
Windows Server 2012
Windows Server 2012
A Microsoft server operating system that supports enterprise-level management, data storage, applications, and communications.
1,571 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Clément BETACORNE 2,031 Reputation points
    2021-12-09T13:27:25.517+00:00

    Hello,

    Your best option for your request will be to use PowerShell and Active Directory Module, below an example of what you can do :

    $Computers = Get-ADComputer -Filter * -properties OperatingSystem | Where-Object {$_.OperatingSystem -like "*server*"}
    $colObj = @()
    foreach($Computer in $Computers) {
        try {
            $services = Get-WmiObject win32_service -computername $Computer.Name -ErrorAction Stop
            foreach($service in $services) {
                $hash = @{
                computerName = $Computer.Name
                serviceName = $service.name
                account = $service.startname
                startmode = $service.startmode
                }
                $exportObj = New-Object PSObject -Property $hash
                $colObj = $colObj + $exportObj
            }
        }
        catch {
            Write-Output "Could not request service"
        }
    }
    
    Write-Output $colObj
    

    Note : It can be improved but at least you have materials to start your documentation

    Regards,

    0 comments No comments

  2. Limitless Technology 39,511 Reputation points
    2021-12-09T14:02:31.497+00:00

    Hello @DK Bridges

    you can use powershell to get the information you are looking for:

    Get-ADServiceAccount
    https://learn.microsoft.com/en-us/powershell/module/activedirectory/get-adserviceaccount?view=windowsserver2019-ps

    Hope this helps with your query!

    ----
    --If the reply is helpful, please Upvote and Accept as answer--

    0 comments No comments