You are here

PowerShell - Get "Logon As" Information From Remote (or local) Server

This was made possible by the Scripting Guy.  I have boiled it down to the answer.

If you want to use PowerShell to query for the log on account that normally is displayed in the services.msc service properties window:


Here is the PowerShell script:


$server_name = "name_of_server"; 
$services = Get-WmiObject win32_service -ComputerName $server_name |Where-Object {$ -like "*SQL*"}; 
$services|select StartName,name; 

This bothered me a little bit because Get-Service seemed to grab the data that I wanted very quickly and it seemed like the place that login information would be stored.  Unfortunately, it didn't work.  So, this Get-WmiObject approach takes 5-10 seconds to run, but it's worth it.

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
3 + 12 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer