public/stigData.ps1

#region Header
using module .\..\private\stigData.psm1
#endregion Header
#region Data
$defaultParameterList = 'StigException|OrganizationSettingsPath|StigTitlePrefix|StigTitleSuffix'
#endregion Data
#region Main Functions
<#
    .SYNOPSIS
        A proxy function to get the Stig Content from the Windows Server STIG.
 
    .DESCRIPTION
        Sets parameters that are used used to filter an additional set of dynamic parameters.
 
        DYNAMIC PARAMETERS
 
        This function uses several dynamic parmaters that filter the validateset automatilcaly bassed on values provided to OsVersion and OsRole.
        For more information on the Common STIG parameters, Please run 'Get-Help Get-CommonStigParameters -Full'
 
    .PARAMETER OsVersion
        Filters the STIG version to the OS version.
 
    .PARAMETER OsRole
        Filters the STIG version list to the Domain Controller (DC) or Member Server (MS) role.
#>

function Get-WindowsServerStigData
{
    [CmdletBinding()]
    [outputtype([PSObject])]
    Param
    (
        [Parameter(Mandatory = $true)]
        [ValidateSet('2012R2','2016')]
        [string]
        $OsVersion,
        
        [Parameter(Mandatory = $true)]
        [ValidateSet('DC','MS')]
        [string]
        $OsRole
    )
    
    DynamicParam 
    {
        try
        {
            $CommonStigParameters = @{
                Technology        = 'WindowsServer' 
                TechnologyVersion = $OsVersion 
                TechnologyRole    = $OsRole
            }
            
            Get-CommonStigParameters @CommonStigParameters 
        }
        catch
        {
            Write-Error $Error[0]
            Write-Warning "Please run 'Get-Help Get-CommonStigParameters -Full' "
        }
    }
    
    begin 
    {
        ################################ Begin Set file path from #################################
        $fileName = "$OsVersion-$OsRole-$($PSBoundParameters['StigVersion']).xml"
        $path = "$(Get-StigDataRootPath)\WindowsServer\$fileName"
        Write-Verbose "$fileName exists --> $(Test-Path -Path $path ) "
        ################################ End Set file path from #################################
        ##################### Begin Standard entry on all public functions ######################
        $PSBoundParameters.Keys -notmatch $defaultParameterList | 
            ForEach-Object { $PSBoundParameters.Remove($PSItem) | Out-Null}
        $PSBoundParameters.Add('Path',$path)
        ##################### End Standard entry on all public functions ######################
    }

    end
    {
        Get-StigData @PSBoundParameters
    }
}

function Get-WindowsFirewallStigData
{
    [CmdletBinding()]
    Param( )
 
    DynamicParam 
    {
        try
        {
            $CommonStigParameters = @{
                Technology = 'WindowsFirewall' 
            }
            
            Get-CommonStigParameters @CommonStigParameters 
        }
        catch
        {
            Write-Error $Error[0]
            Write-Warning "Please run 'Get-Help Get-CommonStigParameters -Full' "
        }
    }

    begin 
    {
        ################################ Begin Set file path from #################################
        $fileName = "$($PSBoundParameters['StigVersion']).xml"
        $path = "$(Get-StigDataRootPath)\WindowsFirewall\$fileName"
        Write-Verbose "$fileName exists --> $(Test-Path -Path $path ) "
        ################################ End Set file path from #################################
        ##################### Begin Standard entry on all public functions ######################
        $PSBoundParameters.Keys -notmatch $defaultParameterList | 
            ForEach-Object { $PSBoundParameters.Remove($PSItem) | Out-Null}
        $PSBoundParameters.Add('Path', $path)
        ##################### End Standard entry on all public functions ######################
    }

    end
    {
        Get-StigData @PSBoundParameters
    }

}

function Get-WindowsDnsServerStigData
{
    [CmdletBinding()]
    [outputtype([PSObject])]
    Param
    (
        [Parameter(Mandatory = $true)]
        [ValidateSet('2012R2')]
        [string]
        $OsVersion
    )
    
    DynamicParam 
    {
        try
        {
            $CommonStigParameters = @{
                Technology        = 'WindowsDnsServer' 
                TechnologyVersion = $OsVersion 
            }
            
            Get-CommonStigParameters @CommonStigParameters 
        }
        catch
        {
            Write-Error $Error[0]
            Write-Warning "Please run 'Get-Help Get-CommonStigParameters -Full' "
        }
    }
    
    begin 
    {
        ################################ Begin Set file path from #################################
        $OsRole = "DNS"
        $fileName = "$OsVersion-$OsRole-$($PSBoundParameters['StigVersion']).xml"
        $path = "$(Get-StigDataRootPath)\WindowsDnsServer\$fileName"
        Write-Verbose "$fileName exists --> $(Test-Path -Path $path ) "
        ################################ End Set file path from #################################
        ##################### Begin Standard entry on all public functions ######################
        $PSBoundParameters.Keys -notmatch $defaultParameterList | 
            ForEach-Object { $PSBoundParameters.Remove($PSItem) | Out-Null}
        $PSBoundParameters.Add('Path', $path)
        ##################### End Standard entry on all public functions ######################
    }

    end
    {
        Get-StigData @PSBoundParameters
    }
}
#endregion Main Functions
#region Support Functions
<#
    .SYNOPSIS
        A discovery function that returns data about available SITG's in the module
 
    .PARAMETER Name
        The name of the technology that the STIG targets such as Windows Server or RHEL
 
    .PARAMETER ListAvailable
        A swtich that retunrs all available STIGs
 
    .EXAMPLE
        In this example all WindowsServer STIG details are returned.
 
        Get-Stig -Name WindowsServer
     
    .EXAMPLE
        In this example a list of all available STIGS is returned.
 
        Get-Stig -ListAvailable
#>

function Get-StigList
{
    [outputtype([psobject[]])]
    param
    (
        [parameter()]
        [string]
        $Technology
    )

    $childItemParameters = @{
        Path = "$(Get-StigDataRootPath)\$Technology"
        Exclude = "*.org.*" 
        Include = "*.xml" 
        File = $true
        Recurse = $true
    }
    
    $stigList = Get-ChildItem @childItemParameters

    [System.Collections.ArrayList] $returnlist = @() 
    
    foreach ($stig in $stigList)
    {
        $stigProperties = $stig.BaseName -Split "-"

        $stigPropertyList = New-Object PSobject
        $stigPropertyList | Add-Member -MemberType NoteProperty -Name 'Technology' -Value (Split-Path -Path $stig.Directory -Leaf)
        $stigPropertyList | Add-Member -MemberType NoteProperty -Name 'StigVersions' -Value $stigProperties[-1]
        $stigPropertyList | Add-Member -MemberType NoteProperty -Name 'TechnologyVersion' -Value $stigProperties[-3]
        $stigPropertyList | Add-Member -MemberType NoteProperty -Name 'TechnologyRole' -Value $stigProperties[-2]

        [void] $returnlist.Add($stigPropertyList)
    } 

    return $returnlist  
}
#endregion Support Functions