Created
February 14, 2016 13:05
-
-
Save megamorf/e4eea85512981c128651 to your computer and use it in GitHub Desktop.
Pester - Firewall test
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
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