Skip to content

Instantly share code, notes, and snippets.

@entelechyIT
entelechyIT / Example_CCI_List_Loop.ps1
Created January 1, 2017 21:10
Looping through the CCI List XML with PowerShell
## Note the snippet is the second part of the script which
## demonstrates extracting information from DISA NIST XML files
## Download and unzip the latest control list
## from: http://iase.disa.mil/stigs/cci/Pages/index.aspx
$CCIControlFile = '~\Documents\U_CCI_List.xml'
## This is the NIST Revision we are wanting to reference:
$CCIFilter = 'NIST SP 800-53 Revision 4'
@entelechyIT
entelechyIT / Example_XCCDF_Loop.ps1
Created January 1, 2017 21:07
Looping through XCCDF XML with PowerShell
## set the path to the xml xccdf file.
$BenchMarkFilePath = '~\Documents\U_Windows_2012_and_2012_R2_MS_STIG_V2R6_Manual-xccdf.xml'
## load the content as XML
[xml]$Stigx = Get-Content -Path $BenchMarkFilePath -EA Stop
# start by parsing the xccdf security benchmark
if($Stigx){
$StigCollection = @()
# loop through the xccdf benchmark collecting data into an object collection
foreach ($rule in $StigX.Benchmark.Group.Rule){
# Location and file name of the download
$DownloadFilePath = '~\Documents\u_cci_list.zip'
# URL to download the file from
$DownloadURL = 'http://iasecontent.disa.mil/stigs/zip/u_cci_list.zip'
# download the zip file
invoke-webrequest -Uri $DownloadURL -OutFile $DownloadFilePath
## location and file name of the download
$DownloadFilePath = '~\Documents\U_Windows_2012_and_2012_R2_MS_V2R6_STIG.zip'
## URL to download the file from
$DownloadURL = 'http://iasecontent.disa.mil/stigs/zip/Oct2016/U_Windows_2012_and_2012_R2_MS_V2R6_STIG.zip'
## download the zip file
invoke-webrequest -Uri $DownloadURL -OutFile $DownloadFilePath
# download and unzip your benchmark from DIA NISTA
# from: http://iase.disa.mil/stigs/compilations/Pages/index.aspx
$BenchMarkFilePath = '~\Documents\U_Windows_2012_and_2012_R2_MS_STIG_V2R6_Manual-xccdf.xml'
# Download and unzip the latest control list
# from: http://iase.disa.mil/stigs/cci/Pages/index.aspx
$CCIControlFile = '~\Documents\U_CCI_List.xml'
# This is the NIST Revision we are wanting to reference:
$CCIFilter = 'NIST SP 800-53 Revision 4'