Parsers/GPO/InternetSettings.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#region GPO Parsers
Function Write-GPOInternetSettingsXMLData
{
    [CmdletBinding()]
    [OutputType([String])]
    param
    (
        [Parameter(Mandatory = $true)]
        [System.Xml.XmlElement]$XML    
    )

    # DSC does not allow for Internet Explorer version filtering, so we have to comment all of these out.
    $CommentOut = $false

    $regHash = @{}
    $Name = "InternetSettings(XML): $($XML.Id) ($($($XML.ParentNode.ParentNode.Name)))"
    $Min = $XML.ParentNode.ParentNode.Filter.FilerFile.Min
    $Max = $XML.ParentNode.ParentNode.Filter.FilerFile.Max

    if ($Min -ne $null -and $Max -ne $null)
    {
        $Condition = {$InternetExplorerVersion -gt $Min -and $InternetExplorerVersion -lt $Max}
    }
    else
    {
        $Condition = [scriptblock]"`$InternetExplorerVersion -eq $($XML.ParentNode.ParentNode.Name)"
    }

    $regHash.ValueName = $XML.name
    switch ($XML.hive)
    {
        "HKEY_LOCAL_MACHINE" { $regHash.Key = Join-Path -Path "HKLM:" -ChildPath $XML.Key}
        "HKEY_CURRENT_USER" 
        { 
            $regHash.Key = Join-Path -Path "HKCU:" -ChildPath $XML.Key
            Write-Warning "Write-GPOInternetSettingsXMLData: CurrentUser settings are not currently supported"
            $CommentOut = $true
        }
    }

    if ($XML.defaultValue)
    {
        Write-Warning "Write-GPOInternetSettingsXMLData: Registry Default Values and User BitField masks are not yet supported"
        $CommentOUT = $true
    }

    $regHash.ValueData = $ValueData
    $regHash.ValueType = $XML.type
    
    Update-RegistryHashtable -Hashtable $regHash
    Write-DSCString -Resource -Type Registry -Name $Name -CommentOut:$CommentOut -Parameters $regHash -Condition $Condition
}
#endregion