Service Bus
2 TopicsPowershell to export list of all services not running as SYSTEM account on all domain computers
I need to see if there are any services running as service accounts and wanted to query all our domain computers to get the service name, what state is it in (Running/Disabled/Stopped), the server it is running on and what account is running the service. I am not sure the best way to proceed so I pieced together some Powershell code from the web but it's not working when I try to use the $Servers variable to search the OU (line 2) & store that info so the code can run on all the machines. I'm not great with PowerShell & don't know if it needs a FOR EACH or not? It DOES work when I comment line 2 out & uncomment the line that specifies individual computers (line 3), but there are 2000+ machines I need to query. How can I have the script search my entire domain & get the ServiceName, ServiceDisplayName, StartName, State & servername it is running on, then export that to a CSV? I've tried Googling, but unfortuantely nothing I have tried works, any help is greatly appreciated, thank you in advance! # Get a list of all computers in the domain (you may need to customize this query) $Servers = Get-ADComputer -Filter * -SearchBase "OU=Citrix,OU=HCAA,DC=PACs,DC=local" # $Servers = ("cxap01", "msql01", "hwbr01") $ServiceName = @{ Name = 'ServiceName'; Expression = {$_.Name}} $ServiceDisplayname = @{ Name = 'Service DisplayName'; Expression = {$_.Caption}} Invoke-Command $Servers.servername -ScriptBlock { Get-CimInstance -Class Win32_Service -filter "StartName != 'LocalSystem' AND NOT StartName LIKE 'NT Authority%' " } | Select-Object SystemName, $ServiceName, $ServiceDisplayname, StartMode, StartName, State | format-table -autosize2.3KViews0likes4CommentsPowershell mapping\treeflow
hey to all I try to do mapping\tree flow with Powershell on SharePoint online I try to create a script to do all the mapping and give me the following details: Main Site name, Subsite name, Link Per the site, Size per site and export all data to CSV or Excel workbook486Views0likes0Comments