Skip to content

Commit 0282c64

Browse files
committed
Misc enhacements
1 parent 35df533 commit 0282c64

File tree

3 files changed

+119
-119
lines changed

3 files changed

+119
-119
lines changed

Src/Private/Get-AbrHRZLocalEntitlement.ps1

Lines changed: 112 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function Get-AbrHRZLocalEntitlement {
2828
}
2929

3030
process {
31-
if ($InfoLevel.UsersAndGroups.Entitlements -ge 1) {
31+
if ($InfoLevel.UsersAndGroups.Entitlements -ge 1 -and $EntitledUserOrGroupLocalMachines) {
3232
try {
3333
Section -Style Heading3 'Local Entitlements' {
3434
Paragraph "The following section provide a summary of local user & groups entitlements."
@@ -57,137 +57,137 @@ function Get-AbrHRZLocalEntitlement {
5757
Write-PScriboMessage -IsWarning $_.Exception.Message
5858
}
5959
}
60-
}
61-
62-
$TableParams = @{
63-
Name = "Local Entitlements - $($HVEnvironment.toUpper())"
64-
List = $false
65-
ColumnWidths = 55, 15, 15, 15
66-
}
60+
61+
$TableParams = @{
62+
Name = "Local Entitlements - $($HVEnvironment.toUpper())"
63+
List = $false
64+
ColumnWidths = 55, 15, 15, 15
65+
}
6766

68-
if ($Report.ShowTableCaptions) {
69-
$TableParams['Caption'] = "- $($TableParams.Name)"
70-
}
71-
$OutObj | Sort-Object -Property 'User Principal Name' | Table @TableParams
67+
if ($Report.ShowTableCaptions) {
68+
$TableParams['Caption'] = "- $($TableParams.Name)"
69+
}
70+
$OutObj | Sort-Object -Property 'User Principal Name' | Table @TableParams
7271

73-
if ($InfoLevel.UsersAndGroups.Entitlements -ge 2) {
74-
Section -Style Heading4 "Local Entitlements Details" {
75-
Paragraph "The following section detail per user or group local entitlements."
76-
BlankLine
77-
try {
78-
$PoolIDNameResults = ''
79-
$AppIDNameResults = ''
80-
foreach ($EntitledUserOrGroupLocalMachine in $EntitledUserOrGroupLocalMachines) {
81-
try {
82-
# Find Machine ID Name
83-
$MachineIDName = ''
84-
$Entitledlocalmachines = $EntitledUserOrGroupLocalMachine.LocalData.Machines.id
85-
foreach ($Entitledlocalmachine in $Entitledlocalmachines) {
86-
foreach ($Machine in $Machines) {
87-
if ($Machine.Id.id -eq $Entitledlocalmachine) {
88-
$MachineIDName = $Machine.base.Name
89-
break
72+
if ($InfoLevel.UsersAndGroups.Entitlements -ge 2) {
73+
Section -Style Heading4 "Local Entitlements Details" {
74+
Paragraph "The following section detail per user or group local entitlements."
75+
BlankLine
76+
try {
77+
$PoolIDNameResults = ''
78+
$AppIDNameResults = ''
79+
foreach ($EntitledUserOrGroupLocalMachine in $EntitledUserOrGroupLocalMachines) {
80+
try {
81+
# Find Machine ID Name
82+
$MachineIDName = ''
83+
$Entitledlocalmachines = $EntitledUserOrGroupLocalMachine.LocalData.Machines.id
84+
foreach ($Entitledlocalmachine in $Entitledlocalmachines) {
85+
foreach ($Machine in $Machines) {
86+
if ($Machine.Id.id -eq $Entitledlocalmachine) {
87+
$MachineIDName = $Machine.base.Name
88+
break
89+
}
90+
}
91+
if ($Entitledlocalmachines.count -gt 1) {
92+
$MachineIDNameResults += "$MachineIDName, "
93+
$MachineIDName = $MachineIDNameResults.TrimEnd(', ')
9094
}
9195
}
92-
if ($Entitledlocalmachines.count -gt 1) {
93-
$MachineIDNameResults += "$MachineIDName, "
94-
$MachineIDName = $MachineIDNameResults.TrimEnd(', ')
96+
Switch ($MachineIDName) {
97+
'' { $MachineIDName = 'N/A' }
98+
' ' { $MachineIDName = 'N/A' }
9599
}
96-
}
97-
Switch ($MachineIDName) {
98-
'' { $MachineIDName = 'N/A' }
99-
' ' { $MachineIDName = 'N/A' }
100-
}
101100

102-
# Find Desktop ID Name
103-
$PoolIDName = ''
104-
$Entitledlocalmachines = $EntitledUserOrGrouplocalMachine.localData.Desktops.id
105-
foreach ($Entitledlocalmachine in $Entitledlocalmachines) {
106-
foreach ($Pool in $Pools) {
107-
if ($Pool.Id.id -eq $Entitledlocalmachine) {
108-
$PoolIDName = $pool.base.Name
109-
break
101+
# Find Desktop ID Name
102+
$PoolIDName = ''
103+
$Entitledlocalmachines = $EntitledUserOrGrouplocalMachine.localData.Desktops.id
104+
foreach ($Entitledlocalmachine in $Entitledlocalmachines) {
105+
foreach ($Pool in $Pools) {
106+
if ($Pool.Id.id -eq $Entitledlocalmachine) {
107+
$PoolIDName = $pool.base.Name
108+
break
109+
}
110+
}
111+
if ($Entitledlocalmachines.count -gt 1) {
112+
$PoolIDNameResults += "$PoolIDName, "
113+
$PoolIDName = $PoolIDNameResults.TrimEnd(', ')
110114
}
111115
}
112-
if ($Entitledlocalmachines.count -gt 1) {
113-
$PoolIDNameResults += "$PoolIDName, "
114-
$PoolIDName = $PoolIDNameResults.TrimEnd(', ')
115-
}
116-
}
117116

118-
# Find App ID Name
119-
$AppIDName = ''
120-
$Entitledlocalmachines = $EntitledUserOrGroupLocalMachine.LocalData.Applications.id
121-
foreach ( $Entitledlocalmachine in $Entitledlocalmachines) {
122-
foreach ($App in $Apps) {
123-
if ($App.Id.id -eq $Entitledlocalmachine) {
124-
$AppIDName = $app.data.DisplayName
125-
break
126-
}
117+
# Find App ID Name
118+
$AppIDName = ''
119+
$Entitledlocalmachines = $EntitledUserOrGroupLocalMachine.LocalData.Applications.id
120+
foreach ( $Entitledlocalmachine in $Entitledlocalmachines) {
121+
foreach ($App in $Apps) {
122+
if ($App.Id.id -eq $Entitledlocalmachine) {
123+
$AppIDName = $app.data.DisplayName
124+
break
125+
}
127126

127+
}
128+
if ($Entitledlocalmachines.count -gt 1) {
129+
$AppIDNameResults += "$AppIDName, "
130+
$AppIDName = $AppIDNameResults.TrimEnd(', ')
131+
}
128132
}
129-
if ($Entitledlocalmachines.count -gt 1) {
130-
$AppIDNameResults += "$AppIDName, "
131-
$AppIDName = $AppIDNameResults.TrimEnd(', ')
133+
Switch ($AppIDName) {
134+
'' { $AppIDName = 'N/A' }
135+
' ' { $AppIDName = 'N/A' }
132136
}
133-
}
134-
Switch ($AppIDName) {
135-
'' { $AppIDName = 'N/A' }
136-
' ' { $AppIDName = 'N/A' }
137-
}
138137

139-
Switch ($EntitledUserOrGroupLocalMachine.base.Group) {
140-
'True' { $EntitledUserOrGroupLocalMachinegroup = 'Group' }
141-
'False' { $EntitledUserOrGroupLocalMachinegroup = 'User' }
142-
}
143-
Section -ExcludeFromTOC -Style NOTOCHeading5 "Local Entitlement Details - $($EntitledUserOrGroupLocalMachine.base.Name)" {
144-
$OutObj = @()
145-
try {
146-
Write-PScriboMessage "Local Entitlements Details for $($EntitledUserOrGroupLocalMachine.base.Name)."
147-
$inObj = [ordered] @{
148-
'Name' = $EntitledUserOrGroupLocalMachine.base.Name
149-
'Group or User' = $EntitledUserOrGroupLocalMachinegroup
150-
'Domain' = $EntitledUserOrGroupLocalMachine.base.Domain
151-
'Ad Distinguished Name' = $EntitledUserOrGroupLocalMachine.base.AdDistinguishedName
152-
'First Name' = $EntitledUserOrGroupLocalMachine.base.FirstName
153-
'Last Name' = $EntitledUserOrGroupLocalMachine.base.LastName
154-
'Login Name' = $EntitledUserOrGroupLocalMachine.base.LoginName
155-
'Display Name' = $EntitledUserOrGroupLocalMachine.base.DisplayName
156-
'Long Display Name' = $EntitledUserOrGroupLocalMachine.base.LongDisplayName
157-
'Email' = $EntitledUserOrGroupLocalMachine.base.Email
158-
'Kiosk User' = $EntitledUserOrGroupLocalMachine.base.KioskUser
159-
'Phone' = $EntitledUserOrGroupLocalMachine.base.Phone
160-
'Description' = $EntitledUserOrGroupLocalMachine.base.Description
161-
'In Folder' = $EntitledUserOrGroupLocalMachine.base.InFolder
162-
'User Principal Name' = $EntitledUserOrGroupLocalMachine.base.UserPrincipalName
163-
'Local Machines' = $MachineIDName
164-
'Local User Persistent Disks' = $EntitledUserOrGroupLocalMachine.LocalData.PersistentDisks
165-
'Local Desktops' = $PoolIDName
166-
'User Applications' = $AppIDName
167-
}
168-
$OutObj += [pscustomobject](ConvertTo-HashToYN $inObj)
138+
Switch ($EntitledUserOrGroupLocalMachine.base.Group) {
139+
'True' { $EntitledUserOrGroupLocalMachinegroup = 'Group' }
140+
'False' { $EntitledUserOrGroupLocalMachinegroup = 'User' }
141+
}
142+
Section -ExcludeFromTOC -Style NOTOCHeading5 "Local Entitlement Details - $($EntitledUserOrGroupLocalMachine.base.Name)" {
143+
$OutObj = @()
144+
try {
145+
Write-PScriboMessage "Local Entitlements Details for $($EntitledUserOrGroupLocalMachine.base.Name)."
146+
$inObj = [ordered] @{
147+
'Name' = $EntitledUserOrGroupLocalMachine.base.Name
148+
'Group or User' = $EntitledUserOrGroupLocalMachinegroup
149+
'Domain' = $EntitledUserOrGroupLocalMachine.base.Domain
150+
'Ad Distinguished Name' = $EntitledUserOrGroupLocalMachine.base.AdDistinguishedName
151+
'First Name' = $EntitledUserOrGroupLocalMachine.base.FirstName
152+
'Last Name' = $EntitledUserOrGroupLocalMachine.base.LastName
153+
'Login Name' = $EntitledUserOrGroupLocalMachine.base.LoginName
154+
'Display Name' = $EntitledUserOrGroupLocalMachine.base.DisplayName
155+
'Long Display Name' = $EntitledUserOrGroupLocalMachine.base.LongDisplayName
156+
'Email' = $EntitledUserOrGroupLocalMachine.base.Email
157+
'Kiosk User' = $EntitledUserOrGroupLocalMachine.base.KioskUser
158+
'Phone' = $EntitledUserOrGroupLocalMachine.base.Phone
159+
'Description' = $EntitledUserOrGroupLocalMachine.base.Description
160+
'In Folder' = $EntitledUserOrGroupLocalMachine.base.InFolder
161+
'User Principal Name' = $EntitledUserOrGroupLocalMachine.base.UserPrincipalName
162+
'Local Machines' = $MachineIDName
163+
'Local User Persistent Disks' = $EntitledUserOrGroupLocalMachine.LocalData.PersistentDisks
164+
'Local Desktops' = $PoolIDName
165+
'User Applications' = $AppIDName
166+
}
167+
$OutObj += [pscustomobject](ConvertTo-HashToYN $inObj)
169168

170-
$TableParams = @{
171-
Name = "Local Entitlements Details - $($EntitledUserOrGroupLocalMachine.base.Name)"
172-
List = $True
173-
ColumnWidths = 50, 50
174-
}
169+
$TableParams = @{
170+
Name = "Local Entitlements Details - $($EntitledUserOrGroupLocalMachine.base.Name)"
171+
List = $True
172+
ColumnWidths = 50, 50
173+
}
175174

176-
if ($Report.ShowTableCaptions) {
177-
$TableParams['Caption'] = "- $($TableParams.Name)"
178-
}
175+
if ($Report.ShowTableCaptions) {
176+
$TableParams['Caption'] = "- $($TableParams.Name)"
177+
}
179178

180-
$OutObj | Table @TableParams
181-
} catch {
182-
Write-PScriboMessage -IsWarning $_.Exception.Message
179+
$OutObj | Table @TableParams
180+
} catch {
181+
Write-PScriboMessage -IsWarning $_.Exception.Message
182+
}
183183
}
184+
} catch {
185+
Write-PScriboMessage -IsWarning $_.Exception.Message
184186
}
185-
} catch {
186-
Write-PScriboMessage -IsWarning $_.Exception.Message
187187
}
188+
} catch {
189+
Write-PScriboMessage -IsWarning $_.Exception.Message
188190
}
189-
} catch {
190-
Write-PScriboMessage -IsWarning $_.Exception.Message
191191
}
192192
}
193193
}

Src/Private/SharedUtilsFunctions.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ function ConvertTo-HashToYN {
123123
.DESCRIPTION
124124
125125
.NOTES
126-
Version: 0.1.0
126+
Version: 0.2.0
127127
Author: Jonathan Colon
128128
129129
.EXAMPLE
@@ -132,15 +132,15 @@ function ConvertTo-HashToYN {
132132
133133
#>
134134
[CmdletBinding()]
135-
[OutputType([Hashtable])]
135+
[OutputType([System.Collections.Specialized.OrderedDictionary])]
136136
Param (
137137
[Parameter (Position = 0, Mandatory)]
138138
[AllowEmptyString()]
139-
[Hashtable] $TEXT
139+
[System.Collections.Specialized.OrderedDictionary] $TEXT
140140
)
141141

142142
$result = [ordered] @{}
143-
foreach ($i in $inObj.GetEnumerator()) {
143+
foreach ($i in $TEXT.GetEnumerator()) {
144144
try {
145145
$result.add($i.Key, (ConvertTo-TextYN $i.Value))
146146
} catch {

0 commit comments

Comments
 (0)