Created
February 25, 2019 14:29
-
-
Save billkindle/167550d4a65f3a05db7b0da8540c40c7 to your computer and use it in GitHub Desktop.
Sample foreach loop using an array inside a Pester test to check a number of hosts that are running the same service in an application cluster.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is an exmaple of Infrastructure testing that can be done with Pester DSL and PowerShell | |
$nodes = @('node1','node2','node3','node4','node5') | |
Describe -Name 'Windows Appplication Service Infrastructure' -Tag 'Prod' { | |
Context -Name 'Application01 Service Checks' { | |
foreach ($node in $nodes) { | |
It -Name "Application01 Service is Running on $node" { | |
$Svc = Get-Service -ComputerName $node -Name 'Application01' | |
$Svc.Status | Should -BeExactly 'Running' | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment