Skip to content

Instantly share code, notes, and snippets.

@billkindle
Created February 25, 2019 14:29
Show Gist options
  • Save billkindle/167550d4a65f3a05db7b0da8540c40c7 to your computer and use it in GitHub Desktop.
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 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