forked from anwather/My-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNested-Objects.ps1
More file actions
84 lines (76 loc) · 1.74 KB
/
Nested-Objects.ps1
File metadata and controls
84 lines (76 loc) · 1.74 KB
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
#Install the OutTabulatorView module for PSGallery
$object = [pscustomobject]@{
ComputerName = "MyServer01"
Disks = @(
@{
Name = "C"
FreeSpace = "70%"
},
@{
Name = "D"
FreeSpace = "70%"
}
)
NetworkInterface = @(
@{
Name = "Ethernet"
State = "Up"
},
@{
Name = "Wifi"
State = "Down"
}
)
}
$object2 = [pscustomobject]@{
ComputerName = "MyServer02"
Disks = @(
@{
Name = "C"
FreeSpace = "60%"
},
@{
Name = "D"
FreeSpace = "50%"
}
)
NetworkInterface = @(
@{
Name = "Ethernet"
State = "Up"
},
@{
Name = "Wifi"
State = "Down"
}
)
}
$all = @()
$all += $object
$all += $object2
$formatArray = @()
foreach ($obj in $all) {
#Multione
foreach ($d in $obj.Disks) {
$formatArray += [pscustomobject]@{
ComputerName = $obj.ComputerName
DriveLetter = $d.Name
FreeSpace = $d.FreeSpace
InterfaceName = $null
State = $null
}
}
foreach ($d in $obj.NetworkInterface) {
$formatArray += [pscustomobject]@{
ComputerName = $obj.ComputerName
DriveLetter = $null
FreeSpace = $null
InterfaceName = $d.Name
State = $d.State
}
}
}
$columnOptions = @()
$columnOptions += New-ColumnOption -ColumnName FreeSpace -title "Free Space" -formatter progress
$formatArray | otv -columnOptions $columnOptions -groupBy ComputerName
$formatArray | otv -groupBy ComputerName