question

ChristopherEllis-1514 avatar image
0 Votes"
ChristopherEllis-1514 asked PercivalYang-MSFT answered

how do i get a 4th column displaying the servername

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MotoX80 avatar image
0 Votes"
MotoX80 answered

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
 } 


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

cooldadtx avatar image
0 Votes"
cooldadtx answered

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AndreasBaumgarten avatar image
0 Votes"
AndreasBaumgarten answered AndreasBaumgarten edited

Hi @ChristopherEllis-1514 ,

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: https://docs.microsoft.com/en-us/answers/questions/466305/how-do-i-add-the-servers-queried-in-4th-colunmn-wh.html

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)

Regards
Andreas Baumgarten

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

PercivalYang-MSFT avatar image
0 Votes"
PercivalYang-MSFT answered

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.