PSCerts.format.ps1xml

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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
    <Controls>
        <Control>
            <Name>CertSummaryItem-Header</Name>
            <CustomControl>
                <CustomEntries>
                    <CustomEntry>
                        <CustomItem>
                            <Frame>
                                <LeftIndent>0</LeftIndent>
                                <CustomItem>
                                    <ExpressionBinding>
                                        <ScriptBlock>
                                            "$($PSStyle.Formatting.TableHeader)$($PSStyle.Reverse)$($PSStyle.Bold)Store Location: $($_.Location)$($PSStyle.ReverseOff)$($PSStyle.Reset)"
                                        </ScriptBlock>
                                    </ExpressionBinding>
                                    <NewLine/>
                                </CustomItem>
                            </Frame>
                        </CustomItem>
                    </CustomEntry>
                </CustomEntries>
            </CustomControl>
        </Control>
    </Controls>
    <ViewDefinitions>
        <View>
            <Name>CertAccessRule</Name>
            <ViewSelectedBy>
                <TypeName>PSCerts.CertAccessRule</TypeName>
            </ViewSelectedBy>
            <TableControl>
                <TableHeaders>
                    <TableColumnHeader>
                        <Label>AccessType</Label>
                        <Alignment>Center</Alignment>
                    </TableColumnHeader>
                    <TableColumnHeader>
                        <Label>Rights</Label>
                        <Alignment>Left</Alignment>
                    </TableColumnHeader>
                    <TableColumnHeader>
                        <Label>Identity</Label>
                    </TableColumnHeader>
                </TableHeaders>
                <TableRowEntries>
                    <TableRowEntry>
                        <Wrap/>
                        <TableColumnItems>
                            <TableColumnItem>
                                <ScriptBlock>
                                    if ($_.IsAllow) { "$($PSStyle.Foreground.Green)$($_.AccessType)" }
                                    else { "$($PSStyle.Foreground.Red)$($_.AccessType)" }
                                </ScriptBlock>
                            </TableColumnItem>
                            <TableColumnItem>
                                <ScriptBlock>
                                    if ($_.IsAllow) { $color = $PSStyle.Foreground.Green }
                                    else { $color = $PSStyle.Foreground.Red }
 
                                    "$color$($_.FileSystemRights.ToString("F").Replace(", ", "`n"))$($PSStyle.Reset)"
                                </ScriptBlock>
                            </TableColumnItem>
                            <TableColumnItem>
                                <PropertyName>Identity</PropertyName>
                            </TableColumnItem>
                        </TableColumnItems>
                    </TableRowEntry>
                </TableRowEntries>
            </TableControl>
        </View>
        <View>
            <Name>CertSummaryItem</Name>
            <ViewSelectedBy>
                <TypeName>PSCerts.Summary.CertSummaryItem</TypeName>
            </ViewSelectedBy>
            <GroupBy>
                <PropertyName>Location</PropertyName>
                <CustomControlName>CertSummaryItem-Header</CustomControlName>
            </GroupBy>
            <TableControl>
                <TableHeaders>
                    <TableColumnHeader>
                        <Label>Store</Label>
                        <Width>30</Width>
                    </TableColumnHeader>
                    <TableColumnHeader>
                        <Label>Cert</Label>
                        <Width>41</Width>
                    </TableColumnHeader>
                    <TableColumnHeader>
                        <Label>Key</Label>
                        <Alignment>Center</Alignment>
                        <Width>3</Width>
                    </TableColumnHeader>
                    <TableColumnHeader>
                        <Label>Permissions</Label>
                    </TableColumnHeader>
                </TableHeaders>
                <TableRowEntries>
                    <TableRowEntry>
                        <Wrap/>
                        <TableColumnItems>
                            <TableColumnItem>
                                <ScriptBlock>"$($PSStyle.Foreground.BrightCyan)$($_.Location)$($PSStyle.Reset)\$($PSStyle.Foreground.BrightBlue)$($_.Store)$($PSStyle.Reset)"</ScriptBlock>
                            </TableColumnItem>
                            <TableColumnItem>
                                <ScriptBlock>
                                    $output = "$($PSStyle.Foreground.White)"
                                    if ($_.DisplayName.Length -ge 41) {
                                        $output += "$($_.DisplayName.Substring(0, 37))$($PSStyle.Foreground.BrightBlack)..."
                                    }
                                    else {
                                        $output += "$($_.DisplayName)"
                                    }
                                    $output += "`n$($PSStyle.Foreground.BrightMagenta)$($_.Thumbprint)$($PSStyle.Reset)"
                                    $output
                                </ScriptBlock>
                            </TableColumnItem>
                            <TableColumnItem>
                                <ScriptBlock>
                                    if ($_.HasPrivateKey) { "$($PSStyle.Foreground.Green)Y$($PSStyle.Reset)" }
                                    else { " " }
                                </ScriptBlock>
                            </TableColumnItem>
                            <TableColumnItem>
                                <ScriptBlock>
                                    $output = @()
                                    $maxLength = $_.Permissions `
                                        | select @{N='Length';E={$_.FileSystemRightsString.Length}} `
                                        | sort -Property Length -Descending `
                                        | select -First 1 -ExpandProperty Length
 
                                    $maxLength = [Math]::Max($maxLength, 3)
 
                                    foreach ($perm in $_.Permissions)
                                    {
                                        if ($perm.IsAllow) {
                                            $access = "$($PSStyle.Bold)$($PSStyle.Foreground.BrightGreen)+$($PSStyle.BoldOff) "
                                        }
                                        else {
                                            $access = "$($PSStyle.Bold)$($PSStyle.Foreground.BrightRed)-$($PSStyle.BoldOff) "
                                        }
                                        $output += "$access$($perm.FileSystemRightsString.PadRight($maxLength)) $($PSStyle.Reset) $($perm.IdentityDisplayString)"
                                    }
                                    [string]::Join("`n", $output)
                                </ScriptBlock>
                            </TableColumnItem>
                        </TableColumnItems>
                    </TableRowEntry>
                </TableRowEntries>
            </TableControl>
        </View>
    </ViewDefinitions>
</Configuration>