Parsers/GPO/UserRightsAssignment.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

Function Write-GPOPrivilegeINFData
{
    [CmdletBinding()]
    [OutputType([String])]
    param
    (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [string]$Privilege,

        [Parameter(Mandatory = $true)]
        [AllowEmptyString()]
        [string]$PrivilegeData
    )

    $privilegeHash = @{}
    $privilegeHash.Policy = ""
    $privilegeHash.Identity = ""
    $privilegeHash.Force = $true

    # These are UserRights
    if ($UserRightsHash.ContainsKey($Privilege))
    {                        
        $privilegeHash.Policy = $UserRightsHash[$Privilege]
    }
    else
    {
        Write-Error "Cannot find $Privilege"
        Add-ProcessingHistory -Type UserRightsAssignment -Name "UserRightsAssignment(INF): $Privilege" -ParsingError
        return ""
    }

    $privilegeHash.Identity = $PrivilegeData -split ","
    
    Write-DSCString -Resource -Name "UserRightsAssignment(INF): $($privilegeHash.Policy)" -Type UserRightsAssignment -Parameters  $privilegeHash
}