Private/Functions.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
function Get-GpoCommentFile {
    <#
    .SYNOPSIS
    Get Gpo Comment File
     
    .DESCRIPTION
    Get GPO comment file path
     
    .PARAMETER Gpo
    Group Policy Object reference
 
    .PARAMETER ConfigType
    Configuration Type: Machine or User
     
    .EXAMPLE
    $filepath = Get-GpoCommentFile -Gpo $GPO
     
    .NOTES
     
    .INPUTS
        Group Policy Object reference
    .OUTPUTS
        Path and Name of Comment CMTX file
    #>

    param (
        [parameter(Mandatory=$True, HelpMessage="Group Policy ID")]
            [ValidateNotNullOrEmpty()]
            $Gpo,
        [parameter(Mandatory=$True, HelpMessage="Configuration Type: Machine or User")]
            [ValidateNotNullOrEmpty()]
            [string] $ConfigType
    )
    $result = "\\$($gpo.DomainName)\SYSVOL\$($gpo.DomainName)\Policies\{$($gpo.ID)}\$ConfigType\comment.cmtx"
    if (Test-Path $result) {
        Write-Output $result
    }
    else {
        Write-Output ""
    }
}

function Get-GppCommentPath {
    <#
    .SYNOPSIS
    Get Group Policy Preferences Comment file path
     
    .DESCRIPTION
    Get Group Policy Preferences Comment file path
     
    .PARAMETER Gpo
    Group Policy Object reference
     
    .PARAMETER ConfigType
    Configuration Type: Machine or User
 
    .EXAMPLE
    $gppPath = Get-GppCommentPath -Gpo $gpo -ConfigType 'Machine'
     
    .NOTES
    General notes
    #>

    param (
        [parameter(Mandatory=$True, HelpMessage="Group Policy Object")]
            [ValidateNotNullOrEmpty()]
            $Gpo,
        [parameter(Mandatory=$True, HelpMessage="Machine or User")]
            [ValidateNotNullOrEmpty()]
            [string] $ConfigType
    )
    $result = "\\$($gpo.DomainName)\SYSVOL\$($gpo.DomainName)\Policies\{$($gpo.Id)}\$ConfigType\Preferences"
    if (Test-Path $result) {
        Write-Output $result
    }
    else {
        Write-Output ""
    }
}