Get-GphGpExtensions.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
#requires -Version 1.0
function Get-GphGpExtensions {
  <#
      .SYNOPSIS
      Gets all installed Group Policy Extensions from the Registry
 
      .DESCRIPTION
      All Group Policy Extensions must be registered in the Registry. Get-GPExtension retrieves them from
      HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\GPExtensions and shows them in their
      processing-order. It can also show the Configuration-Settings of the Extensions by using the Parameter
      -Showregkeys.
 
      .EXAMPLE
      Get-GPExtensions -ShowRegKeys
      Gets all Extension and their Settings
  #>



  [CmdletBinding()]
  param(
    # Get all Registry-Settings for the Extension
    [switch]$ShowRegKeys
  )
    
  # Unnamed Extension have no name set in the registry.
  $UnnamedExtensions = @{
    '{35378EAC-683F-11D2-A89A-00C04FBBCFA2}' = 'Registry Settings'
    '{4D2F9B6F-1E52-4711-A382-6A8B1A003DE6}' = 'TS Workspace'
    '{F312195E-3D9D-447A-A3F5-08DFFA24735E}' = 'Device Guard'
    '{FC491EF1-C4AA-4CE1-B329-414B101DB823}' = 'Device Guard'
  }

    $gpExtensionsPath = 'Registry::Hkey_local_machine\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\GPExtensions'
    $SpalteDefault = @{ Name='Extension Name'
                        expression= { if ( $_.'(Default)' ) { $_.'(Default)'} Else { $UnnamedExtensions.($_.PSChildName) } } }
    $SpalteGUID = @{ Name='GUID'
                     expression = { $_.PSChildName }}
    $SelectParam = @{ Property=$SpalteGUID,$SpalteDefault,'ProcessGroupPolicy','DllName' }
    $Extensions = 'Guid',
             'Extension Name',
             'DllName',
             'ProcessGroupPolicy',
             'ProcessGroupPolicyEx',
             'GenerateGroupPolicy',
             'EnableAsynchronousProcessing',
             'ExtensionEventSource',
             'MaxNoGPOListChangesInterval',
             'NoBackgroundPolicy',
             'NoGPOListChanges',
             'NoMachinePolicy',
             'NoSlowLink',
             'NotifyLinkTransition',
             'NoUserPolicy',
             'PerUserLocalSettings',
             'RequiresSuccessfulRegistry'

    If ( $ShowRegKeys ) { 1 | Select-Object -Property $Extensions }
    Get-ChildItem -Path $gpExtensionsPath | ForEach-Object { 
       $Regkeys = $_ | Get-ItemProperty  
       If ( $ShowRegKeys )
       {
            $RegKeys | Select-Object -Property $SpalteGuid,$SpalteDefault,*
       }
       Else 
       {
         if ( $regkeys )
                { $RegKeys | Select-Object @SelectParam }
         Else {$_ | Select-Object @SelectParam }
       }
    }
}