How to include Server Name in Test-ServiceHealth
**Problem Description: **
How to Include Server Name in Test-ServiceHealth command of Exchange 2007 / 2010.
[PS] D:\>Test-ServiceHealth -Server Server01 Role : Client Access Server Role |
Cause:-
Add-Member adds the new members to the input object. However, when the input object is a string, Add-Member cannot add the member to the input object. For these objects, use the PassThru parameter to create an output object.
** Solution:**
Run below command, We will get output with servername (Server01). Here we have given input of server names in a *.txt file
** Get-Content C:\server.txt | foreach-object {test-servicehealth -server $_ | Add-Member -MemberType noteproperty -Name Server -Value $_ -PassThru} | fl** *
RunspaceId : 86ffa9e4-34cd-4aae-a506-925b61f14f9a |
** If we want to check this for all Exchange server in Organization (Only for exchange 2007, 2010)**
** **$servers = Get-ExchangeServer
foreach ($server in $servers) {Write-Host "Checking" $server.name ;Test-ServiceHealth $server | ft * }