Skip to content

Instantly share code, notes, and snippets.

@p0w3rsh3ll
Created December 7, 2016 12:25
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 p0w3rsh3ll/9c9573eb36f677f104ce9cc4ef0377c1 to your computer and use it in GitHub Desktop.
Save p0w3rsh3ll/9c9573eb36f677f104ce9cc4ef0377c1 to your computer and use it in GitHub Desktop.
$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