top of page

PowerShell - Search Server List for all services

  • Writer: Jon Boyette
    Jon Boyette
  • Jan 12, 2022
  • 1 min read

Save as a ServerandServiceAccount.ps1 or named, this takes the servers/computers in c:\temp\servers.txt, and makes a C:\temp\ServiveAndServiceAccounts folder that is populated with a csv PER server in the test list, showing ALL services on remote Computer(S)

param (

[string[]]$ServerArray = (Get-Content -Path c:\temp\servers.txt),

[string]$SaveLocation = "C:\Temp\ServiceandServiceAccounts"

)

# Test if folder exists, otherwise create folder

if (-not (Test-Path -Path $SaveLocation)) {

New-Item -ItemType directory -Path $SaveLocation

}


# Main loop of script

Foreach ($Server in $ServerArray ) {

$CurrentLogFile = Join-path -Path $SaveLocation -ChildPath "$Server-Services.csv"

"Retrieving services for $Server"

Get-WmiObject win32_service -ComputerName $Server | select Name,

@{N="Startup Type";E={$_.StartMode}},

@{N="Service Account";E={$_.StartName}},

@{N="System Name";E={$_.Systemname}} |

Sort-Object "Name" | Export-Csv -Path $CurrentLogFile -NoTypeInformation

}


 
 
 

Recent Posts

See All
PowerShell - List All Domain SPNs

Save as same List_ALL_SPNs.ps1 or similar, this LDap calls the Domain for all Service Principal names and accounts related #Build LDAP...

 
 
 
PowerShell - Start-Monitoring

This is a great script used to Monitor and Email if a server is up or down, once ran, and smtp and from address is set, then run:...

 
 
 

Comments


Post: Blog2 Post
  • Facebook
  • Twitter
  • LinkedIn

©2022 by Boyette Technical Services. Proudly created with Wix.com

bottom of page