-
-
Save p0w3rsh3ll/9c9573eb36f677f104ce9cc4ef0377c1 to your computer and use it in GitHub Desktop.
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
$here = Split-Path -Parent $MyInvocation.MyCommand.Path | |
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.' | |
. "$here\$sut" | |
#region Security policy | |
Describe 'Security Policy' { | |
BeforeAll { | |
& (gcm secedit.exe) @('/export','/Cfg','C:\Windows\temp\secpol.SECURITYPOLICY.txt','/areas','SECURITYPOLICY') | |
$CurrentSecPolicy = (Get-Content -Path 'C:\Windows\temp\secpol.SECURITYPOLICY.txt' -ReadCount 1) ` | |
-match '^([A-Z\s0-9_\\]+)=(.*)$' -replace '=',',' | | |
ConvertFrom-Csv -Header Key,Value1,Value2 | |
} | |
$SecurityPolicy | ForEach-Object -Process { | |
$k = $v1 = $v2 = $null | |
$k = $_.Key | |
$v1= $_.Value1 | |
$v2 = $_.Value2 | |
if ($v2) { | |
It "should have its $k policy type set to $v1" { | |
($CurrentSecPolicy | Where { $_.Key -eq $k }).'Value1' -eq $v1 | Should be $true | |
} | |
It "should have its $k policy value set to $v2" { | |
($CurrentSecPolicy | Where { $_.Key -eq $k }).'Value2' -eq $v2 | Should be $true | |
} | |
} else { | |
It "should have its $k policy set to $v1" { | |
($CurrentSecPolicy | Where { $_.Key -eq $k }).'Value1' -eq $v1 | Should be $true | |
} | |
} | |
} | |
} | |
#endregion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment