<commit_before>$Script:SP2013Features = @("Application-Server", "AS-NET-Framework", 
                            "AS-TCP-Port-Sharing", "AS-Web-Support", "AS-WAS-Support", 
                            "AS-HTTP-Activation", "AS-Named-Pipes", "AS-TCP-Activation","Web-Server", 
                            "Web-WebServer", "Web-Common-Http", "Web-Default-Doc", "Web-Dir-Browsing", 
                            "Web-Http-Errors", "Web-Static-Content", "Web-Http-Redirect", "Web-Health", 
                            "Web-Http-Logging", "Web-Log-Libraries", "Web-Request-Monitor", 
                            "Web-Http-Tracing", "Web-Performance", "Web-Stat-Compression", 
                            "Web-Dyn-Compression", "Web-Security", "Web-Filtering", "Web-Basic-Auth", 
                            "Web-Client-Auth", "Web-Digest-Auth", "Web-Cert-Auth", "Web-IP-Security", 
                            "Web-Url-Auth", "Web-Windows-Auth", "Web-App-Dev", "Web-Net-Ext", 
                            "Web-Net-Ext45", "Web-Asp-Net", "Web-Asp-Net45", "Web-ISAPI-Ext", 
                            "Web-ISAPI-Filter", "Web-Mgmt-Tools", "Web-Mgmt-Console", "Web-Mgmt-Compat", 
                            "Web-Metabase", "Web-Lgcy-Scripting", "Web-WMI", "Web-Scripting-Tools", 
                            "NET-Framework-Features", "NET-Framework-Core", "NET-Framework-45-ASPNET", 
                            "NET-WCF-HTTP-Activation45", "NET-WCF-Pipe-Activation45", 
                            "NET-WCF-TCP-Activation45", "Server-Media-Foundation", 
                            "Windows-Identity-Foundation", "PowerShell-V2", "WAS", "WAS-Process-Model", 
                            "WAS-NET-Environment", "WAS-Config-APIs", "XPS-Viewer")

$Script:SP2016Win16Features = @("Web-Server", "Web-WebServer", 
                                "Web-Common-Http", "Web-Default-Doc", "Web-Dir-Browsing", 
                                "Web-Http-Errors", "Web-Static-Content", "Web-Health", 
                                "Web-Http-Logging", "Web-Log-Libraries", "Web-Request-Monitor", 
                                "Web-Http-Tracing", "Web-Performance", "Web-Stat-Compression", 
                                "Web-Dyn-Compression", "Web-Security", "Web-Filering", "Web-Basic-Auth", 
                                "Web-Digest-Auth", "Web-Windows-Auth", "Web-App-Dev", "Web-Net-Ext", 
                                "Web-Net-Ext45Web-Asp-Net", "Web-Asp-Net45", "Web-ISAPI-Ext", 
                                "Web-ISAPI-Filter", "Web-Mgmt-Tools", "Web-Mgmt-Console", 
                                "Web-Mgmt-Compat", "Web-Metabase", "Web-Lgcy-Scripting", "Web-WMI", 
                                "NET-Framework-Features", "NET-HTTP-Activation", "NET-Non-HTTP-Activ", 
                                "NET-Framework-45-ASPNET", "NET-WCF-Pipe-Activation45", 
                                "Windows-Identity-Foundation", "WAS", "WAS-Process-Model", 
                                "WAS-NET-Environment", "WAS-Config-APIs", "XPS-Viewer")

$Script:SP2016Win12r2Features = @("Application-Server", "AS-NET-Framework", 
                                "AS-Web-Support", "Web-Server", "Web-WebServer", "Web-Common-Http", 
                                "Web-Default-Doc", "Web-Dir-Browsing", "Web-Http-Errors", 
                                "Web-Static-Content", "Web-Http-Redirect", "Web-Health", 
                                "Web-Http-Logging", "Web-Log-Libraries", "Web-Request-Monitor", 
                                "Web-Performance", "Web-Stat-Compression", "Web-Dyn-Compression", 
                                "Web-Security", "Web-Filtering", "Web-Basic-Auth", "Web-Client-Auth", 
                                "Web-Digest-Auth", "Web-Cert-Auth", "Web-IP-Security", "Web-Url-Auth", 
                                "Web-Windows-Auth", "Web-App-Dev", "Web-Net-Ext", "Web-Net-Ext45", 
                                "Web-Asp-Net45", "Web-ISAPI-Ext", "Web-ISAPI-Filter", "Web-Mgmt-Tools", 
                                "Web-Mgmt-Console", "Web-Mgmt-Compat", "Web-Metabase", 
                                "Web-Lgcy-Mgmt-Console", "Web-Lgcy-Scripting", "Web-WMI", 
                                "Web-Scripting-Tools", "NET-Framework-Features", "NET-Framework-Core", 
                                "NET-HTTP-Activation", "NET-Non-HTTP-Activ", "NET-Framework-45-ASPNET", 
                                "NET-WCF-HTTP-Activation45", "Windows-Identity-Foundation", 
                                "PowerShell-V2", "WAS", "WAS-Process-Model", "WAS-NET-Environment", 
                                "WAS-Config-APIs")


function Get-TargetResource
{
    [CmdletBinding()]
    [OutputType([System.Collections.Hashtable])]
    param
    (
        [parameter(Mandatory = $true)]  
        [System.String]  
        $InstallerPath,

        [parameter(Mandatory = $true)]  
        [System.Boolean] 
        $OnlineMode,
        
        [parameter(Mandatory = $false)] 
        [System.String] 
        $SXSpath,
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $SQLNCli,        
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $PowerShell,        
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $NETFX,        
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $IDFX,        
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $Sync,        
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $AppFabric,        
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $IDFX11,        
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $MSIPCClient,        
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $WCFDataServices,        
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $KB2671763,        
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $WCFDataServices56,
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $MSVCRT11,
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $MSVCRT14,
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $KB3092423,
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $ODBC,
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $DotNetFx,
        
        [parameter(Mandatory = $false)] 
        [ValidateSet("Present","Absent")] 
        [System.String] 
        $Ensure = "Present"
    )
    
    Write-Verbose -Message "Detecting SharePoint version from binaries"
    $majorVersion = (Get-SPDSCAssemblyVersion -PathToAssembly $InstallerPath)
    if ($majorVersion -eq 15) 
    {
        Write-Verbose -Message "Version: SharePoint 2013"
    }
    if ($majorVersion -eq 16) 
    {
        Write-Verbose -Message "Version: SharePoint 2016"
    }

    Write-Verbose -Message "Getting installed windows features"
        
    if ($majorVersion -eq 15) 
    {
        $WindowsFeatures = Get-WindowsFeature -Name $Script:SP2013Features
    }
    if ($majorVersion -eq 16) 
    {
        $osVersion = [System.Environment]::OSVersion.Version.Major
        if ($osVersion -eq 10) 
        {
            # Server 2016
            $WindowsFeatures = Get-WindowsFeature -Name $Script:SP2016Win16Features
        } 
        else 
        {
            # Server 2012 R2
            $WindowsFeatures = Get-WindowsFeature -Name $Script:SP2016Win12r2Features  
        }
    }
    
    $windowsFeaturesInstalled = $true
    foreach ($feature in $WindowsFeatures) 
    {
        if ($feature.Installed -eq $false) 
        {
            $windowsFeaturesInstalled = $false
            Write-Verbose -Message "Windows feature $($feature.Name) is not installed"
        }
    }

    Write-Verbose -Message "Checking windows packages from the registry"

    $x86Path = "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
    $installedItemsX86 = Get-ItemProperty -Path $x86Path | Select-Object -Property DisplayName
    
    $x64Path = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*"
	$installedItemsX64 = Get-ItemProperty -Path $x64Path | Select-Object -Property DisplayName

	$installedItems = $installedItemsX86 + $installedItemsX64

    # Common prereqs
    $prereqsToTest = @(
        [PSObject]@{
            Name = "AppFabric 1.1 for Windows Server"
            SearchType = "Equals"
            SearchValue = "AppFabric 1.1 for Windows Server"
        },
        [PSObject]@{
            Name = "Microsoft CCR and DSS Runtime 2008 R3"<commit_msg>Got caught by those damn tabs again - first time in a while!<commit_after>$Script:SP2013Features = @("Application-Server", "AS-NET-Framework", 
                            "AS-TCP-Port-Sharing", "AS-Web-Support", "AS-WAS-Support", 
                            "AS-HTTP-Activation", "AS-Named-Pipes", "AS-TCP-Activation","Web-Server", 
                            "Web-WebServer", "Web-Common-Http", "Web-Default-Doc", "Web-Dir-Browsing", 
                            "Web-Http-Errors", "Web-Static-Content", "Web-Http-Redirect", "Web-Health", 
                            "Web-Http-Logging", "Web-Log-Libraries", "Web-Request-Monitor", 
                            "Web-Http-Tracing", "Web-Performance", "Web-Stat-Compression", 
                            "Web-Dyn-Compression", "Web-Security", "Web-Filtering", "Web-Basic-Auth", 
                            "Web-Client-Auth", "Web-Digest-Auth", "Web-Cert-Auth", "Web-IP-Security", 
                            "Web-Url-Auth", "Web-Windows-Auth", "Web-App-Dev", "Web-Net-Ext", 
                            "Web-Net-Ext45", "Web-Asp-Net", "Web-Asp-Net45", "Web-ISAPI-Ext", 
                            "Web-ISAPI-Filter", "Web-Mgmt-Tools", "Web-Mgmt-Console", "Web-Mgmt-Compat", 
                            "Web-Metabase", "Web-Lgcy-Scripting", "Web-WMI", "Web-Scripting-Tools", 
                            "NET-Framework-Features", "NET-Framework-Core", "NET-Framework-45-ASPNET", 
                            "NET-WCF-HTTP-Activation45", "NET-WCF-Pipe-Activation45", 
                            "NET-WCF-TCP-Activation45", "Server-Media-Foundation", 
                            "Windows-Identity-Foundation", "PowerShell-V2", "WAS", "WAS-Process-Model", 
                            "WAS-NET-Environment", "WAS-Config-APIs", "XPS-Viewer")

$Script:SP2016Win16Features = @("Web-Server", "Web-WebServer", 
                                "Web-Common-Http", "Web-Default-Doc", "Web-Dir-Browsing", 
                                "Web-Http-Errors", "Web-Static-Content", "Web-Health", 
                                "Web-Http-Logging", "Web-Log-Libraries", "Web-Request-Monitor", 
                                "Web-Http-Tracing", "Web-Performance", "Web-Stat-Compression", 
                                "Web-Dyn-Compression", "Web-Security", "Web-Filering", "Web-Basic-Auth", 
                                "Web-Digest-Auth", "Web-Windows-Auth", "Web-App-Dev", "Web-Net-Ext", 
                                "Web-Net-Ext45Web-Asp-Net", "Web-Asp-Net45", "Web-ISAPI-Ext", 
                                "Web-ISAPI-Filter", "Web-Mgmt-Tools", "Web-Mgmt-Console", 
                                "Web-Mgmt-Compat", "Web-Metabase", "Web-Lgcy-Scripting", "Web-WMI", 
                                "NET-Framework-Features", "NET-HTTP-Activation", "NET-Non-HTTP-Activ", 
                                "NET-Framework-45-ASPNET", "NET-WCF-Pipe-Activation45", 
                                "Windows-Identity-Foundation", "WAS", "WAS-Process-Model", 
                                "WAS-NET-Environment", "WAS-Config-APIs", "XPS-Viewer")

$Script:SP2016Win12r2Features = @("Application-Server", "AS-NET-Framework", 
                                "AS-Web-Support", "Web-Server", "Web-WebServer", "Web-Common-Http", 
                                "Web-Default-Doc", "Web-Dir-Browsing", "Web-Http-Errors", 
                                "Web-Static-Content", "Web-Http-Redirect", "Web-Health", 
                                "Web-Http-Logging", "Web-Log-Libraries", "Web-Request-Monitor", 
                                "Web-Performance", "Web-Stat-Compression", "Web-Dyn-Compression", 
                                "Web-Security", "Web-Filtering", "Web-Basic-Auth", "Web-Client-Auth", 
                                "Web-Digest-Auth", "Web-Cert-Auth", "Web-IP-Security", "Web-Url-Auth", 
                                "Web-Windows-Auth", "Web-App-Dev", "Web-Net-Ext", "Web-Net-Ext45", 
                                "Web-Asp-Net45", "Web-ISAPI-Ext", "Web-ISAPI-Filter", "Web-Mgmt-Tools", 
                                "Web-Mgmt-Console", "Web-Mgmt-Compat", "Web-Metabase", 
                                "Web-Lgcy-Mgmt-Console", "Web-Lgcy-Scripting", "Web-WMI", 
                                "Web-Scripting-Tools", "NET-Framework-Features", "NET-Framework-Core", 
                                "NET-HTTP-Activation", "NET-Non-HTTP-Activ", "NET-Framework-45-ASPNET", 
                                "NET-WCF-HTTP-Activation45", "Windows-Identity-Foundation", 
                                "PowerShell-V2", "WAS", "WAS-Process-Model", "WAS-NET-Environment", 
                                "WAS-Config-APIs")


function Get-TargetResource
{
    [CmdletBinding()]
    [OutputType([System.Collections.Hashtable])]
    param
    (
        [parameter(Mandatory = $true)]  
        [System.String]  
        $InstallerPath,

        [parameter(Mandatory = $true)]  
        [System.Boolean] 
        $OnlineMode,
        
        [parameter(Mandatory = $false)] 
        [System.String] 
        $SXSpath,
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $SQLNCli,        
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $PowerShell,        
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $NETFX,        
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $IDFX,        
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $Sync,        
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $AppFabric,        
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $IDFX11,        
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $MSIPCClient,        
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $WCFDataServices,        
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $KB2671763,        
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $WCFDataServices56,
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $MSVCRT11,
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $MSVCRT14,
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $KB3092423,
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $ODBC,
        
        [parameter(Mandatory = $false)] 
        [System.String]  
        $DotNetFx,
        
        [parameter(Mandatory = $false)] 
        [ValidateSet("Present","Absent")] 
        [System.String] 
        $Ensure = "Present"
    )
    
    Write-Verbose -Message "Detecting SharePoint version from binaries"
    $majorVersion = (Get-SPDSCAssemblyVersion -PathToAssembly $InstallerPath)
    if ($majorVersion -eq 15) 
    {
        Write-Verbose -Message "Version: SharePoint 2013"
    }
    if ($majorVersion -eq 16) 
    {
        Write-Verbose -Message "Version: SharePoint 2016"
    }

    Write-Verbose -Message "Getting installed windows features"
        
    if ($majorVersion -eq 15) 
    {
        $WindowsFeatures = Get-WindowsFeature -Name $Script:SP2013Features
    }
    if ($majorVersion -eq 16) 
    {
        $osVersion = [System.Environment]::OSVersion.Version.Major
        if ($osVersion -eq 10) 
        {
            # Server 2016
            $WindowsFeatures = Get-WindowsFeature -Name $Script:SP2016Win16Features
        } 
        else 
        {
            # Server 2012 R2
            $WindowsFeatures = Get-WindowsFeature -Name $Script:SP2016Win12r2Features  
        }
    }
    
    $windowsFeaturesInstalled = $true
    foreach ($feature in $WindowsFeatures) 
    {
        if ($feature.Installed -eq $false) 
        {
            $windowsFeaturesInstalled = $false
            Write-Verbose -Message "Windows feature $($feature.Name) is not installed"
        }
    }

    Write-Verbose -Message "Checking windows packages from the registry"

    $x86Path = "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
    $installedItemsX86 = Get-ItemProperty -Path $x86Path | Select-Object -Property DisplayName
    
    $x64Path = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*"
    $installedItemsX64 = Get-ItemProperty -Path $x64Path | Select-Object -Property DisplayName

    $installedItems = $installedItemsX86 + $installedItemsX64

    # Common prereqs
    $prereqsToTest = @(
        [PSObject]@{
            Name = "AppFabric 1.1 for Windows Server"
            SearchType = "Equals"
            SearchValue = "AppFabric 1.1 for Windows Server"
        },
        [PSObject]@{
            Name = "Microsoft CCR and DSS Runtime 2008 R3"
{'fraction_non_alphanumeric': 0.13740801078591092, 'fraction_numerical': 0.015954159878658503, 'mean_word_length': 1.550429799426934, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 1, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4336424', 'n_tokens_mistral': 5662, 'n_tokens_neox': 5175, 'n_words': 788}