how do i get a 4th column displaying the servername

Christopher Ellis 1 Reputation point

mY script is simple i get the servers names from a text file $servers = Get-Content c:\temp\servers.txti am only displaying Status, Name, and Display

here is my script

Status Name DisplayName

Running spooler Print Spooler
Running spooler Print Spooler
Running spooler Print Spooler
Running spooler Print Spooler
Running spooler Print Spooler
Running spooler Print Spooler
Running spooler Print Spooler
Running spooler Print Spoole

How do i make the servers appear in the report as a 4th column?

I know tthat t i am extracting the servers from a text file

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,035 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. MotoX80 31,556 Reputation points

    here is my script

    You forgot to include your script.

    $servers = Get-Content c:\temp\servers.txt
    foreach ($srv in $servers) {
        $out = "Something to display."
        "{0} - {1}" -f $out, $srv
    0 comments No comments

  2. Michael Taylor 47,461 Reputation points

    You didn't post your script, just what looks like some output. You also didn't specify what $servers contains (e.g. server names, contents of some program output, etc).

    Just completely taking a guess that you are getting a list of servers from some file, then calling some PS function to get the status of spooler on that server using something like Get-Service. You want to combine these into a table output. The key is how you're getting the service status. Get-Service in PS 5 can be used but PS Core removed support for remote computers.

    $servers = Get-Content 'c:\temp\servers.txt'
    Get-Service -ComputerName $servers -Name spooler | Select-Object -Property Status, Name, DisplayName, MachineName
    0 comments No comments

  3. Andreas Baumgarten 95,021 Reputation points MVP

    Hi @Christopher Ellis ,

    this is the third time you asked the same question within the last days. Your second time question is deleted now.
    But the first time question with an answer is still there:

    I don't see the reason why repeating the same question again and again is helpful.


    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Andreas Baumgarten

    0 comments No comments

  4. Percival Yang 721 Reputation points

    Please do not post the same question on the forum, for we will keep following up your question until solving it.

    0 comments No comments