Skip to content

Commit 2d8d15a

Browse files
committed
Fix Error "Cannot bind argument to parameter 'Name' because it is an empty string"
1 parent 6425ece commit 2d8d15a

File tree

3 files changed

+47
-43
lines changed

3 files changed

+47
-43
lines changed

Src/Private/Get-AbrHRZAccessGroup.ps1

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function Get-AbrHRZAccessGroup {
55
.DESCRIPTION
66
Documents the configuration of VMware Horizon in Word/HTML/XML/Text formats using PScribo.
77
.NOTES
8-
Version: 1.1.5
8+
Version: 1.1.7
99
Author: Chris Hildebrandt, Karl Newick
1010
Twitter: @childebrandt42, @karlnewick
1111
Editor: Jonathan Colon, @jcolonfzenpr
@@ -37,7 +37,7 @@ function Get-AbrHRZAccessGroup {
3737
$OutObj = @()
3838
$AccessGroupJoined = @()
3939
$AccessGroupJoined += $AccessGroups
40-
$AccessGroupJoined += $AccessGroups.Children
40+
if ($AccessGroups.Children) { $AccessGroupJoined += $AccessGroups.Children }
4141
foreach ($AccessGroup in $AccessGroupJoined) {
4242
Write-PScriboMessage "Discovered $($AccessGroup.base.Name) Access Groups Information."
4343
$inObj = [ordered] @{
@@ -63,56 +63,60 @@ function Get-AbrHRZAccessGroup {
6363
Section -Style Heading4 "Access Groups Details" {
6464
$AccessGroupJoined = @()
6565
$AccessGroupJoined += $AccessGroups
66-
$AccessGroupJoined += $AccessGroups.Children
66+
if ($AccessGroups.Children) { $AccessGroupJoined += $AccessGroups.Children }
6767
foreach ($AccessGroup in $AccessGroupJoined) {
68-
Write-PScriboMessage "Discovered $($AccessGroup.base.Name) Access Groups Detailed Information."
69-
$AdministratorIDNameResults = @()
70-
# Find Administrator ID Name
71-
foreach ($AccessGroupID in $AccessGroup.data.Permissions.id) {
72-
foreach ($Permission in $Permissions) {
73-
if ($AccessGroupID -eq $Permission.id.id) {
74-
foreach ($PermissionGroup in $Permission.base.UserOrGroup.id) {
75-
foreach ($Administrator in $Administrators) {
76-
if ($Administrator.Id.id -eq $PermissionGroup) {
77-
$AdministratorIDNameResults += $Administrator.base.name
78-
break
68+
try {
69+
Write-PScriboMessage "Discovered $($AccessGroup.base.Name) Access Groups Detailed Information."
70+
$AdministratorIDNameResults = @()
71+
# Find Administrator ID Name
72+
foreach ($AccessGroupID in $AccessGroup.data.Permissions.id) {
73+
foreach ($Permission in $Permissions) {
74+
if ($AccessGroupID -eq $Permission.id.id) {
75+
foreach ($PermissionGroup in $Permission.base.UserOrGroup.id) {
76+
foreach ($Administrator in $Administrators) {
77+
if ($Administrator.Id.id -eq $PermissionGroup) {
78+
$AdministratorIDNameResults += $Administrator.base.name
79+
break
80+
}
7981
}
82+
$AdministratorIDName = $AdministratorIDNameResults
8083
}
81-
$AdministratorIDName = $AdministratorIDNameResults
8284
}
8385
}
8486
}
85-
}
86-
if ($AdministratorIDName) {
87-
Section -ExcludeFromTOC -Style NOTOCHeading5 $AccessGroup.base.Name {
88-
$OutObj = @()
89-
foreach ($Principal in ($AdministratorIDName | Select-Object -Unique)) {
90-
$PrincipalPermissionsName = @()
91-
$PrincipalID = ($Administrators | Where-Object { $_.Base.Name -eq $Principal }).Id.Id
92-
$PrincipalPermissions = ($Permissions.Base | Where-Object { $_.UserOrGroup.Id -eq $PrincipalID }).Role.Id
93-
foreach ($PrincipalPermission in $PrincipalPermissions) {
94-
$PrincipalPermissionsName += $(($Roles | Where-Object { $_.Id.id -eq $PrincipalPermission }).Base.Name)
95-
}
87+
if ($AdministratorIDName) {
88+
Section -ExcludeFromTOC -Style NOTOCHeading5 $AccessGroup.base.Name {
89+
$OutObj = @()
90+
foreach ($Principal in ($AdministratorIDName | Select-Object -Unique)) {
91+
$PrincipalPermissionsName = @()
92+
$PrincipalID = ($Administrators | Where-Object { $_.Base.Name -eq $Principal }).Id.Id
93+
$PrincipalPermissions = ($Permissions.Base | Where-Object { $_.UserOrGroup.Id -eq $PrincipalID }).Role.Id
94+
foreach ($PrincipalPermission in $PrincipalPermissions) {
95+
$PrincipalPermissionsName += $(($Roles | Where-Object { $_.Id.id -eq $PrincipalPermission }).Base.Name)
96+
}
9697

97-
$inObj = [ordered] @{
98-
'Name' = $Principal
99-
'Permissions' = [string](($PrincipalPermissionsName | Select-Object -Unique) -join ', ')
100-
}
98+
$inObj = [ordered] @{
99+
'Name' = $Principal
100+
'Permissions' = [string](($PrincipalPermissionsName | Select-Object -Unique) -join ', ')
101+
}
101102

102-
$OutObj += [pscustomobject](ConvertTo-HashToYN $inObj)
103-
}
103+
$OutObj += [pscustomobject](ConvertTo-HashToYN $inObj)
104+
}
104105

105-
$TableParams = @{
106-
Name = "Access Groups - $($AccessGroup.base.Name)"
107-
List = $false
108-
ColumnWidths = 35, 65
109-
}
106+
$TableParams = @{
107+
Name = "Access Groups - $($AccessGroup.base.Name)"
108+
List = $false
109+
ColumnWidths = 35, 65
110+
}
110111

111-
if ($Report.ShowTableCaptions) {
112-
$TableParams['Caption'] = "- $($TableParams.Name)"
112+
if ($Report.ShowTableCaptions) {
113+
$TableParams['Caption'] = "- $($TableParams.Name)"
114+
}
115+
$OutObj | Sort-Object -Property 'Name' | Table @TableParams
113116
}
114-
$OutObj | Sort-Object -Property 'Name' | Table @TableParams
115117
}
118+
} catch {
119+
Write-PScriboMessage -IsWarning $_.Exception.Message
116120
}
117121
}
118122
}

Src/Private/Get-AbrHRZFarm.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function Get-AbrHRZFarm {
6969
$AccessgroupMatch = $false
7070
$AccessgroupJoined = @()
7171
$AccessgroupJoined += $Accessgroups
72-
$AccessgroupJoined += $Accessgroups.Children
72+
if ($Accessgroups.Children) { $AccessgroupJoined += $Accessgroups.Children }
7373
foreach ($Accessgroup in $AccessgroupJoined) {
7474
if ($Accessgroup.Id.id -eq $Farm.data.accessgroup.id) {
7575
$AccessGroupName = $Accessgroup.base.name

Src/Private/Get-AbrHRZGlobalEntitlement.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function Get-AbrHRZGlobalEntitlement {
55
.DESCRIPTION
66
Documents the configuration of VMware Horizon in Word/HTML/XML/Text formats using PScribo.
77
.NOTES
8-
Version: 1.1.5
8+
Version: 1.1.7
99
Author: Chris Hildebrandt, Karl Newick
1010
Twitter: @childebrandt42, @karlnewick
1111
Editor: Jonathan Colon, @jcolonfzenpr
@@ -40,7 +40,7 @@ function Get-AbrHRZGlobalEntitlement {
4040
$GlobalApplicationEntitlementGroups | ForEach-Object { $_ | Add-Member -MemberType NoteProperty -Name "GE_Type" -Value "Application" }
4141
$GlobalEntitlementJoined = @()
4242
$GlobalEntitlementJoined += $GlobalEntitlements
43-
$GlobalEntitlementJoined += $GlobalApplicationEntitlementGroups
43+
if ($GlobalApplicationEntitlementGroups) { $GlobalEntitlementJoined += $GlobalApplicationEntitlementGroups }
4444

4545
$OutObj = @()
4646
foreach ($GlobalEntitlement in $GlobalEntitlementJoined) {

0 commit comments

Comments
 (0)