Find all servers where service account is being used to start services

-3

could you please advise how to find all servers where a specific service account is being used to start windows services?

I am trying this in Powershell with these code:

Clear-Host
$address = Get-Content '.\asg connections.csv'
$serviceName = "startname='NT AUTHORITY\\LocalService'"
gwmi win32_service -filter $serviceName -computer $address

above piece of code works for "localhost", but gives below error for the remote hosts

gwmi : Access is denied. (Exception from HRESULT: 0x80070005 
(E_ACCESSDENIED))
At F:\Temp\powershell\play.ps1:30 char:1
+ gwmi win32_service -filter $serviceName -computer $address
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Get-WmiObject], UnauthorizedA 
ccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.Pow 
erShell.Commands.GetWmiObjectCommand

screenshot 's attached gwmi: Access is denied Thank you.

Yermek

powershell
asked on Stack Overflow Sep 26, 2018 by jhd235 • edited Oct 4, 2018 by jhd235

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0