Define "service account"! Context is important.
If all you want is the name of a service and the account under which the service runs, then this will work:
Get-WmiObject Win32_Service | Select-Object name,startname
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello :)
I am looking for a powershell script to retrieve the list of local service accounts
Thank you
Define "service account"! Context is important.
If all you want is the name of a service and the account under which the service runs, then this will work:
Get-WmiObject Win32_Service | Select-Object name,startname
Or a summary.
Get-CimInstance win32_service | Where-Object {$_.StartName} | Select-Object StartName -Unique
Here is a PowerShell script that retrieves the list of local service accounts on a Windows system:
Get-WmiObject Win32_UserAccount | Where-Object {$.LocalAccount -eq $True -and $.AccountType -eq "512"} | Select-Object Name
This script uses the Get-WmiObject
cmdlet to retrieve a list of user accounts from the Win32_UserAccount
WMI class. The Where-Object
cmdlet filters the list to include only local accounts that have an AccountType
value of 512, which represents service accounts. The Select-Object
cmdlet is then used to display only the Name
property of each service account.