Availability Server uptime

hello.

Not loking for any help. Im lokoing to share what ive created with the hope it may help someone else? My requirement was to report on server availability for the previous month as a percentage. Couldnt find these requirements anywhere. Please see below. Hope this helps someone.

<#

.SYNOPSIS

Simple script to provide server availability uptime statistics

.DESCRIPTION

This script will define the amount of time a server has been unavaialble for in the past 31 days.

Scans the system event log for 6005 and 6006 event id's using an XML filter (faster). These event id's are startup and shutdown entires,

the first and last thing that happens on a server. We subtract the amount of time between the two events

and calculate the down time.

.NOTES

Author Matt Nicholas

#>

#$Diff = 86400000*$DaysAgo # Milliseconds in a day

$startDate

 

 

= get-date $(get-date).AddMonths(-1).ToString("01/MM/yyyy")

$endDate

 

 

= $startDate.AddMonths(1).AddMilliseconds(-1)

 

 

$XMLFilter = "<QueryList>

<Query Id=`"0`" Path=`"System`">

<Select Path=`"System`">*[System[( (EventID = 6005 or EventID = 6006) ) and TimeCreated[@SystemTime&gt;='

 

 

$($startDate.tostring("yyyy-MM-dd"))T00:00:00.000Z' and @SystemTime&lt;='$($endDate.tostring("yyyy-MM-dd"))T22:59:59.999Z']]]</Select>

</Query>

</QueryList>"

 

 

 

 

# Get the list of tartget servers

[

 

 

string[]]$Computers = (Get-Content "c:\utils\servers.txt")

# Foreach target server

 

 

 

ForEach

 

 

($computer in $Computers)

{

 

 

 

# Get the reboot info from event log on current target server

 

 

$RebootEvents = get-winevent -FilterXML $XMLFilter -computername $Computer | sort-object -Descending -property TimeCreated

 

 

$down = $null

 

 

$up = $null

 

 

[timespan]$TotalDownTime = New-TimeSpan

 

 

Foreach($rebootEvent in $RebootEvents)

{

 

 

if ($rebootEvent.ID -eq 6006)

{

 

 

$down = $rebootEvent.TimeCreated

 

}

 

#end if eventID

 

 

Else

{

 

 

$up = $rebootEvent.TimeCreated

}

 

#end else

 

 

if($down -AND $up)

{

 

 

if( 22679 48649 230 false Format output display Hi developer,

Here is my logic script:
$fileList = dir 'H:\aa.txt'

$regex = "(([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?))|((?<=\"")((\w+(\s+\w+)?|\d+))(?<!\""))|[a-zA-Z]]>foreach ($file in $fileList){
    $matchInfo = @((Get-Content $file) | ForEach-Object{ $_.Trim()}| Select-String -Pattern  $regex -AllMatches)
    $output = foreach($minfo in $matchInfo){
                foreach($match in @($minfo.Matches | Foreach {$_.Groups[0].value})){
                    $match 
                }
            }
    $output
}

where aa.txt:
aa aa aa
bb bb bb

I run it and display output like this:

aa aa aa bb bb bb

But i need to display output like this:

aa,aa,aa
bb,bb,bb

Any Idea?
Thanks