Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Adding a fixed column to server status output

$
0
0

I have the below script which provides the server status output ( whether server is up or down):

===

$servers = $servers= get-content 'C:\servers.txt'

$collection = $()

foreach ($server in $servers)

{

    $status = @{ "ServerName" = $server }

    if (Test-Connection $server -Count 1 -ea 0 -Quiet)

    { 

        $status["Results"] = "Up"

    } 

    else 

    { 

        $status["Results"] = "Down" 

    }

    New-Object -TypeName PSObject -Property $status -OutVariable serverStatus

    $collection += $serverStatus

 

}

$collection | ConvertTo-Html | Set-Content C:\output.htm

====

 

It generates output in html as below:

 

Results     ServerName 

Up          Server1

Down        Server2

Up          Server3  

===

Now I want to add one more column to the ouput. The details inside this new column "Server order date" will be fixed .

For eg,

Results     ServerName  ServerOrderDate

Up             Server1           1stJan 

Down        Server2           20thJan 

Up             Server3           25thJan

 

Is there any way to get this done? I am just looking to add fixed column values to the output table.

Many Thanks


Viewing all articles
Browse latest Browse all 6937

Trending Articles