mjm21
asked on
Powershell / Quest script that will pull list of servers and output to csv all of the services started, stopped, automatic and manual
Powershell / Quest script that will pull list of servers and output to csv all of the server hostname and services started, stopped, automatic and manual...etc.
ASKER
Thanks...Need this to be on one excel spread sheet including server hostname. So: server hostname, status, name (service) and display name. There is a ton of servers that we need to check. Would appreciate!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That's Perfect!!! Thanks
ASKER
Thanks!
You're welcome!
ASKER
One issue! It seems to be pulling my local services from my machine and applying to the list of servers I am trying to get that info from.
forgot to add the -computername switch to gwmi. Here you go!
$results = @()
$servers = GC C:\Servers.txt
foreach ($server in $servers) {
$results += get-wmiobject win32_service -ComputerName $server | Select @{Name="Hostname";Expression={$server}},Name,DisplayName,@{Name="Status";Expression={$_.state}},Startmode
}
$results | Export-Csv C:\Services.csv -nti
ASKER
So, this first one works fine. But creates separate spreadsheets for each server which will take too long for me to go through 700 + machine spreadsheets
$servers = GC C:\Servers.txt
foreach ($server in $servers) {
Get-Service -ComputerName $server | Select Status,Name,DisplayName | Sort-Object Status,Name,DisplayName | Export-Csv "C:\$server Services.csv" -nti
This one below takes the content of the txt file and runs. The output is the server names etc.., but next to them is my local machine services, not the remote machine service.
$results = @()
$servers = GC C:\Servers1.txt
foreach ($server in $servers) {
$results += get-wmiobject win32_service | Select @{Name="Hostname";Expressi on={$serve r}},Name,D isplayName ,@{Name="S tatus";Exp ression={$ _.state}}, Startmode
}
$results | Export-Csv C:\Services_result.csv -nti
$servers = GC C:\Servers.txt
foreach ($server in $servers) {
Get-Service -ComputerName $server | Select Status,Name,DisplayName | Sort-Object Status,Name,DisplayName | Export-Csv "C:\$server Services.csv" -nti
This one below takes the content of the txt file and runs. The output is the server names etc.., but next to them is my local machine services, not the remote machine service.
$results = @()
$servers = GC C:\Servers1.txt
foreach ($server in $servers) {
$results += get-wmiobject win32_service | Select @{Name="Hostname";Expressi
}
$results | Export-Csv C:\Services_result.csv -nti
ASKER
oh - ok I did not see your comment. Let me test :)
Lol ok
ASKER
Works! Thank you Sir!
you're welcome.
Open in new window