Skip to content

Commit

Permalink
Migrate lenght and count to measure-object
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelinux committed Feb 21, 2024
1 parent d5ba808 commit 35734a8
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 30 deletions.
16 changes: 8 additions & 8 deletions Src/Private/Get-DiagBackupToProtectedGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function Get-DiagBackupToProtectedGroup {
SubGraph ADContainer -Attributes @{Label = (Get-HTMLLabel -Label 'Active Directory Computers' -IconType "VBR_AGENT_AD_Logo" -SubgraphLabel); fontsize = 18; penwidth = 1.5; labelloc = 't'; style = 'dashed,rounded' } {
# Node used for subgraph centering
Node DummyADContainer @{Label = 'DummyADC'; style = $SubGraphDebug.style; color = $SubGraphDebug.color; shape = 'plain' }
if ($ADContainer.count -le 2) {
if (($ADContainer | Measure-Object).count -le 2) {
foreach ($PGOBJ in ($ADContainer | Sort-Object -Property Name)) {
$PGHASHTABLE = @{}
$PGOBJ.psobject.properties | ForEach-Object { $PGHASHTABLE[$_.Name] = $_.Value }
Expand All @@ -135,7 +135,7 @@ function Get-DiagBackupToProtectedGroup {
Edge -From DummyADContainer -To $PGOBJ.Name @{minlen = 1; style = $EdgeDebug.style; color = $EdgeDebug.color }
}
} else {
$Group = Split-Array -inArray ($ADContainer | Sort-Object -Property Name) -size 2
$Group = Split-array -inArray ($ADContainer | Sort-Object -Property Name) -size 2
$Number = 0
while ($Number -ne $Group.Length) {
$Random = Get-Random
Expand Down Expand Up @@ -182,7 +182,7 @@ function Get-DiagBackupToProtectedGroup {
SubGraph MCContainer -Attributes @{Label = (Get-HTMLLabel -Label 'Manual Computers' -IconType "VBR_AGENT_MC" -SubgraphLabel); fontsize = 18; penwidth = 1.5; labelloc = 't'; style = 'dashed,rounded' } {
# Node used for subgraph centering
Node DummyMCContainer @{Label = 'DummyMC'; style = $SubGraphDebug.style; color = $SubGraphDebug.color; shape = 'plain' }
if ($ManualContainer.count -le 2) {
if (($ManualContainer | Measure-Object).count -le 2) {
foreach ($PGOBJ in ($ManualContainer | Sort-Object -Property Name)) {
$PGHASHTABLE = @{}
$PGOBJ.psobject.properties | ForEach-Object { $PGHASHTABLE[$_.Name] = $_.Value }
Expand All @@ -203,7 +203,7 @@ function Get-DiagBackupToProtectedGroup {
}

} else {
$Group = Split-Array -inArray ($ManualContainer | Sort-Object -Property Name) -size 2
$Group = Split-array -inArray ($ManualContainer | Sort-Object -Property Name) -size 2
$Number = 0
while ($Number -ne $Group.Length) {
$Random = Get-Random
Expand Down Expand Up @@ -244,7 +244,7 @@ function Get-DiagBackupToProtectedGroup {
SubGraph ICContainer -Attributes @{Label = (Get-HTMLLabel -Label 'Individual Computers' -IconType "VBR_AGENT_IC" -SubgraphLabel); fontsize = 18; penwidth = 1.5; labelloc = 't'; style = 'dashed,rounded' } {
# Node used for subgraph centering
Node DummyICContainer @{Label = 'DummyIC'; style = $SubGraphDebug.style; color = $SubGraphDebug.color; shape = 'plain' }
if ($IndividualContainer.count -le 2) {
if (($IndividualContainer | Measure-Object).count -le 2) {
foreach ($PGOBJ in ($IndividualContainer | Sort-Object -Property Name)) {
$PGHASHTABLE = @{}
$PGOBJ.psobject.properties | ForEach-Object { $PGHASHTABLE[$_.Name] = $_.Value }
Expand Down Expand Up @@ -272,7 +272,7 @@ function Get-DiagBackupToProtectedGroup {
Edge -From DummyICContainer -To $PGOBJ.Name @{minlen = 1; style = $EdgeDebug.style; color = $EdgeDebug.color }
}
} else {
$Group = Split-Array -inArray ($IndividualContainer | Sort-Object -Property Name) -size 2
$Group = Split-array -inArray ($IndividualContainer | Sort-Object -Property Name) -size 2
$Number = 0
while ($Number -ne $Group.Length) {
$Random = Get-Random
Expand Down Expand Up @@ -321,7 +321,7 @@ function Get-DiagBackupToProtectedGroup {
SubGraph CSVContainer -Attributes @{Label = (Get-HTMLLabel -Label 'CSV Computers' -IconType "VBR_AGENT_CSV_Logo" -SubgraphLabel); fontsize = 18; penwidth = 1.5; labelloc = 't'; style = 'dashed,rounded' } {
# Node used for subgraph centering
Node DummyCSVContainer @{Label = 'DummyCSVC'; style = $SubGraphDebug.style; color = $SubGraphDebug.color; shape = 'plain' }
if ($CSVContainer.count -le 2) {
if (($CSVContainer | Measure-Object).count -le 2) {
foreach ($PGOBJ in ($CSVContainer | Sort-Object -Property Name)) {
$PGHASHTABLE = @{}
$PGOBJ.psobject.properties | ForEach-Object { $PGHASHTABLE[$_.Name] = $_.Value }
Expand All @@ -338,7 +338,7 @@ function Get-DiagBackupToProtectedGroup {
}

} else {
$Group = Split-Array -inArray ($CSVContainer | Sort-Object -Property Name) -size 2
$Group = Split-array -inArray ($CSVContainer | Sort-Object -Property Name) -size 2
$Number = 0
while ($Number -ne $Group.Length) {
$Random = Get-Random
Expand Down
8 changes: 4 additions & 4 deletions Src/Private/Get-DiagBackupToRepo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function Get-DiagBackupToRepo {
SubGraph LocalRepos -Attributes @{Label = 'Local Repository'; fontsize = 18; penwidth = 1.5; labelloc = 't'; style = 'dashed,rounded' } {
# Node used for subgraph centering
Node LocalReposDummy @{Label = 'LocalReposDummy'; style = $SubGraphDebug.style; color = $SubGraphDebug.color; shape = 'plain' }
if ($LocalBackupRepo.count -le 3) {
if (($LocalBackupRepo | Measure-Object).count -le 3) {
foreach ($REPOOBJ in ($LocalBackupRepo | Sort-Object -Property Name)) {
$REPOHASHTABLE = @{}
$REPOOBJ.psobject.properties | ForEach-Object { $REPOHASHTABLE[$_.Name] = $_.Value }
Expand Down Expand Up @@ -94,7 +94,7 @@ function Get-DiagBackupToRepo {
if ($RemoteBackupRepo) {
SubGraph RemoteRepos -Attributes @{Label = 'Deduplicating Storage Appliances'; fontsize = 18; penwidth = 1.5; labelloc = 't'; style = 'dashed,rounded' } {
Node RemoteReposDummy @{Label = 'RemoteReposDummy'; style = $EdgeDebug.style; color = $EdgeDebug.color; shape = 'plain' }
if ($RemoteBackupRepo.count -le 3) {
if (($RemoteBackupRepo | Measure-Object).count -le 3) {
foreach ($REPOOBJ in ($RemoteBackupRepo | Sort-Object -Property Name)) {
$REPOHASHTABLE = @{}
$REPOOBJ.psobject.properties | ForEach-Object { $REPOHASHTABLE[$_.Name] = $_.Value }
Expand Down Expand Up @@ -133,7 +133,7 @@ function Get-DiagBackupToRepo {
if ($ObjStorage) {
SubGraph ObjectStorage -Attributes @{Label = 'Object Repository'; fontsize = 18; penwidth = 1.5; labelloc = 't'; style = 'dashed,rounded' } {
Node ObjectStorageDummy @{Label = 'ObjectStorageDummy'; style = $SubGraphDebug.style; color = $SubGraphDebug.color; shape = 'plain' }
if ($ObjStorage.count -le 3) {
if (($ObjStorage | Measure-Object).count -le 3) {
foreach ($STORAGEOBJ in ($ObjStorage | Sort-Object -Property Name)) {
$OBJHASHTABLE = @{}
$STORAGEOBJ.psobject.properties | ForEach-Object { $OBJHASHTABLE[$_.Name] = $_.Value }
Expand Down Expand Up @@ -171,7 +171,7 @@ function Get-DiagBackupToRepo {
if ($ArchiveObjStorage) {
SubGraph ArchiveObjectStorage -Attributes @{Label = 'Archive Object Repository'; fontsize = 18; penwidth = 1.5; labelloc = 't'; style = 'dashed,rounded' } {
Node ArchiveObjectStorageDummy @{Label = 'ArchiveObjectStorageDummy'; style = $EdgeDebug.style; color = $EdgeDebug.color; shape = 'plain' }
if ($ArchiveObjStorage.count -le 3) {
if (($ArchiveObjStorage | Measure-Object).count -le 3) {
foreach ($STORAGEArchiveOBJ in ($ArchiveObjStorage | Sort-Object -Property Name)) {
$ARCHOBJHASHTABLE = @{}
$STORAGEArchiveOBJ.psobject.properties | ForEach-Object { $ARCHOBJHASHTABLE[$_.Name] = $_.Value }
Expand Down
2 changes: 1 addition & 1 deletion Src/Private/Get-DiagBackupToTape.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function Get-DiagBackupToTape {
Node $TSLibraryOBJ -NodeScript { $_.Id } @{Label = $TSLHASHTABLE.Label; fontname = "Segoe Ui" }
if ($BackupTapeDrives) {
$TapeLibraryDrives = ($BackupTapeDrives | Where-Object { $_.LibraryId -eq $TSLibraryOBJ.Id } | Sort-Object -Property Name)
if ($TapeLibraryDrives.count -le 3) {
if (($TapeLibraryDrives | Measure-Object).count -le 3) {
foreach ($TSDriveOBJ in $TapeLibraryDrives) {
$TSDHASHTABLE = @{}
$TSDriveOBJ.psobject.properties | ForEach-Object { $TSDHASHTABLE[$_.Name] = $_.Value }
Expand Down
2 changes: 1 addition & 1 deletion Src/Private/Get-DiagBackupToViProxy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function Get-DiagBackupToViProxy {
# SubGraph ESXiMAIN -Attributes @{Label='Standalone Servers'; style='dashed,rounded'; color=$SubGraphDebug.color; fontsize=18; penwidth=1} {
# # Dummy Node used for subgraph centering
# node ESXiBackupProxy @{Label='ESXiBackupProxy'; style=$EdgeDebug.style; color=$EdgeDebug.color; shape='plain'}
# if ($EsxiObjs.count -le 4) {
# if (($EsxiObjs | Measure-Object).count -le 4) {
# foreach ($ESxiHost in $EsxiObjs) {
# $ESXiInfo = @{
# Version = $ESxiHost.Info.ViVersion.ToString()
Expand Down
6 changes: 3 additions & 3 deletions Src/Private/Get-HtmlTable.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,17 @@ Function Get-HTMLTable {
)

if ($MultiColunms) {
if ($Rows.Count -le 1) {
if (($Rows | Measure-Object).Count -le 1) {
$Group = $Rows
} else {
$Group = Split-Array -inArray $Rows -size $ColumnSize
$Group = Split-array -inArray $Rows -size $ColumnSize
}

$Number = 0

$TD = ''
$TR = ''
while ($Number -ne $Group.Count) {
while ($Number -ne ($Group | Measure-Object).Count) {
foreach ($Element in $Group[$Number]) {
$TD += '<TD align="{0}" colspan="1"><FONT POINT-SIZE="{1}">{2}</FONT></TD>' -f $Align, $FontSize, $Element
}
Expand Down
4 changes: 2 additions & 2 deletions Src/Private/Get-VbrBackupArchObjRepoInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function Get-VbrBackupArchObjRepoInfo {
if (-Not $ArchObjStorage.UseGatewayServer) {
Switch ($ArchObjStorage.GatewayMode) {
'Gateway' {
switch ($ArchObjStorage.GatewayServer.count) {
switch (($ArchObjStorage.GatewayServer | Measure-Object).count) {
0 { "Disable" }
1 { $ArchObjStorage.GatewayServer.Name.Split('.')[0] }
Default { 'Automatic' }
Expand All @@ -51,7 +51,7 @@ function Get-VbrBackupArchObjRepoInfo {
default { 'Unknown' }
}
} else {
switch ($ArchObjStorage.GatewayServer.count) {
switch (($ArchObjStorage.GatewayServer | Measure-Object).count) {
0 { "Disable" }
1 { $ArchObjStorage.GatewayServer.Name.Split('.')[0] }
Default { 'Automatic' }
Expand Down
4 changes: 2 additions & 2 deletions Src/Private/Get-VbrBackupObjectRepoInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function Get-VbrBackupObjectRepoInfo {
if (-Not $ObjStorage.UseGatewayServer) {
Switch ($ObjStorage.ConnectionType) {
'Gateway' {
switch ($ObjStorage.GatewayServer.count) {
switch (($ObjStorage.GatewayServer | Measure-Object).count) {
0 { "Disable" }
1 { $ObjStorage.GatewayServer.Name.Split('.')[0] }
Default { 'Automatic' }
Expand All @@ -50,7 +50,7 @@ function Get-VbrBackupObjectRepoInfo {
default { 'Unknown' }
}
} else {
switch ($ObjStorage.GatewayServer.count) {
switch (($ObjStorage.GatewayServer | Measure-Object).count) {
0 { "Disable" }
1 { $ObjStorage.GatewayServer.Name.Split('.')[0] }
Default { 'Automatic' }
Expand Down
8 changes: 4 additions & 4 deletions Src/Private/Get-VbrBackupSobrInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function Get-VbrBackupSobrInfo {
if (-Not $Sobr.CapacityExtent.Repository.UseGatewayServer) {
Switch ($Sobr.CapacityExtent.Repository.ConnectionType) {
'Gateway' {
switch ($Sobr.CapacityExtent.Repository.GatewayServer.count) {
switch (($Sobr.CapacityExtent.Repository.GatewayServer | Measure-Object).count) {
0 { "Disable" }
1 { $Sobr.CapacityExtent.Repository.GatewayServer.Name.Split('.')[0] }
Default { 'Automatic' }
Expand All @@ -73,7 +73,7 @@ function Get-VbrBackupSobrInfo {
default { 'Unknown' }
}
} else {
switch ($Sobr.CapacityExtent.Repository.GatewayServer.count) {
switch (($Sobr.CapacityExtent.Repository.GatewayServer | Measure-Object).count) {
0 { "Disable" }
1 { $Sobr.CapacityExtent.Repository.GatewayServer.Name.Split('.')[0] }
Default { 'Automatic' }
Expand All @@ -88,7 +88,7 @@ function Get-VbrBackupSobrInfo {
if (-Not $Sobr.ArchiveExtent.Repository.UseGatewayServer) {
Switch ($Sobr.ArchiveExtent.Repository.GatewayMode) {
'Gateway' {
switch ($Sobr.ArchiveExtent.Repository.GatewayServer.count) {
switch (($Sobr.ArchiveExtent.Repository.GatewayServer | Measure-Object).count) {
0 { "Disable" }
1 { $Sobr.ArchiveExtent.Repository.GatewayServer.Name.Split('.')[0] }
Default { 'Automatic' }
Expand All @@ -98,7 +98,7 @@ function Get-VbrBackupSobrInfo {
default { 'Unknown' }
}
} else {
switch ($Sobr.ArchiveExtent.Repository.GatewayServer.count) {
switch (($Sobr.ArchiveExtent.Repository.GatewayServer | Measure-Object).count) {
0 { "Disable" }
1 { $Sobr.ArchiveExtent.Repository.GatewayServer.Name.Split('.')[0] }
Default { 'Automatic' }
Expand Down
8 changes: 4 additions & 4 deletions Src/Private/SharedUtilsFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -220,19 +220,19 @@ function Split-array {
[int]$size)

if ($parts) {
$PartSize = [Math]::Ceiling($inArray.count / $parts)
$PartSize = [Math]::Ceiling(($inArray | Measure-Object).count / $parts)
}
if ($size) {
$PartSize = $size
$parts = [Math]::Ceiling($inArray.count / $size)
$parts = [Math]::Ceiling(($inArray | Measure-Object).count / $size)
}

$outArray = @()
for ($i = 1; $i -le $parts; $i++) {
$start = (($i - 1) * $PartSize)
$end = (($i) * $PartSize) - 1
if ($end -ge $inArray.count) {
$end = $inArray.count
if ($end -ge ($inArray | Measure-Object).count) {
$end = ($inArray | Measure-Object).count
}
$outArray += , @($inArray[$start..$end])
}
Expand Down
2 changes: 1 addition & 1 deletion Src/Public/New-VeeamDiagram.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function New-VeeamDiagram {
)]
[ValidateNotNullOrEmpty()]
[ValidateScript({
if ($Format.count -lt 2) {
if (($Format | Measure-Object).count -lt 2) {
$true
} else {
throw "Format value must be unique if Filename is especified."
Expand Down

0 comments on commit 35734a8

Please sign in to comment.