0

Excuse my very limited knowledge of PowerShell commands but I basically want to get a service status report for all my servers. I know how to does this using a static list from a CSV file but ideally I would like to get it Dynamically each time.

I was looking at capturing this list to $servers as below:

$servers = Get-ADComputer -Filter {OperatingSystem -like "windowsserver"} -Properties * | sort Name | ft Name -Wrap -Auto*

This works and produces the output ok but I want to follow this up with something like this but i cant seem to get the $servers working for this command?

Get-Service -Computername $servers -Name wuauserv | Select-Object MachineName,Name,Displayname,Status | Sort-Object Status

Any help would be appreciated, thanks.

Dave
  • 1
  • Hello and welcome to SO, please update your question with the error that you're getting with the command. what is the error message when you run the command? – metablaster Nov 23 '22 at 14:39
  • 1
    Remove `ft Name -Wrap -Auto` from your command. `Format-*` cmdlets emit output objects whose sole purpose is to provide _formatting instructions_ to PowerShell's for-display output-formatting system. In short: only ever use `Format-*` cmdlets to format data _for display_, never for subsequent _programmatic processing_ - see the linked duplicate for more information. – mklement0 Nov 23 '22 at 14:50

0 Answers0