Start - Service w3svc
fixes this problem. To check on an individual service, issue Get-Service service name .
This cmdlet can have its usefulness expanded by using it in a pipeline with other cmdlets. Thus far it has
been used only on a single server. If you wanted to check the health of all of your Exchange servers
within your organization, you could issue Get-ExchangeServer | Test-ServiceHealth . The output
is displayed in Figure 14 - 2 .
Figure 14-2
Though this is informative, in its current state it is not very useful. All the services for each server are
listed, but none of the server names are present. When troubleshooting this can be frustrating, and needs
a little more PowerShell to be functional:
$a=Get-ExchangeServer
foreach ($z in $a) {echo $z.name (Test-ServiceHealth $z)}
The variable $a contains the value of the output of Get-ExchangeServer . Next a foreach loop is
constructed to test each value in the array. Once the foreach loops has its value it needs to execute the
parameters that are contained within the {} . This script echoes the name of the server ( $z.name ) and
then runs through Test-ServiceHealth using $z as the server name. The output in Figure 14 - 3 shows
the server name associated with each set of service health checks.
Part III: Working with PowerShell in a Production Environment
392
To perform a health check on servers that contain a particular role, modify the Get-ExchangeServer to
include the role that you will query.
Pages:
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540