Import-Module PSRight -ErrorAction Stop -Verbose:$false $Servers = Get-RFServerNames -Server # Get Alert State (if any) $BasePath = Join-Path -Path "\\c\WinRepo\Ws\Sub" -ChildPath "Prod" $AlertStatePath = Join-Path -Path $BasePath -ChildPath "ErrFileAlertState.xml" If (Test-Path -Path $AlertStatePath) { $AlertState = Import-Clixml -Path $AlertStatePath } Else { $AlertState = @{} } #Retreiving Error and Bad files from all Valid Fax servers $RunDate = Get-Date $RFJobs = ForEach ($Server in $Servers) { Invoke-Command -ComputerName $Server -ArgumentList $RunDate -AsJob -ScriptBlock { [CmdletBinding()] Param ( [datetime]$RunDate ) $Stack = $env:COMPUTERNAME -replace "srv" ForEach ($Type in "bad","err") { If ($Type -eq "bad") { $Path = "E:\Program Files (x86)\R\EDC\Processors" } Else { $Path = "E:\Program Files (x86)\R\EDC\Status\Processors" } Try { $Files = @(Get-ChildItem -Path $Path -Include "*.$Type" -File -Recurse -ErrorAction Stop) } Catch { Write-Error $_ -ErrorAction Stop } [PSCustomObject]@{ Stack = $Stack Name = "metrics.winops.$Stack.$($Type.Replace("err","error"))FileCount" Value = $Files.Count Date = $RunDate } } } }