Skip to content

Instantly share code, notes, and snippets.

@megamorf
Created February 14, 2016 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save megamorf/e4eea85512981c128651 to your computer and use it in GitHub Desktop.
Save megamorf/e4eea85512981c128651 to your computer and use it in GitHub Desktop.
Pester - Firewall test
param($ComputerName = $env:computername)
Describe 'Firewall is enabled' {
BeforeAll {
$session = New-PSSession -ComputerName $ComputerName
$Param = @{Session=$session}
}
$testCases = @(
@{
FWProfile = 'DomainProfile'
Description = 'Domain Profile'
}
@{
FWProfile = 'PublicProfile'
Description = 'Public Profile'
}
@{
FWProfile = 'StandardProfile'
Description = 'Private Profile'
}
)
It 'tests if the <Description> is enabled' -TestCases $testCases {
param ($FWProfile)
$Expected = 1
$Actual = Invoke-Command @Param -ScriptBlock { (Get-ItemProperty "HKLM:\System\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\${using:FWProfile}" -Name EnableFirewall).EnableFirewall }
$actual | Should Be $Expected
}
AfterAll {
Remove-PSSession -Session $session
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment