ハッシュに同じキーで各種値を設定した情報を配列で持っている変数を表形式で表示する方法を以下に記します。
以下の通り、実際にハッシュ変数の配列変数作成し、表形式で表示させてみます。
$hls = ( @{Distribution="Ubuntu"; ostype="Linux"; base="Debian"}, @{Distribution="Debian"; ostype="Linux"; base="Independent"}, @{Distribution="Red Hat Enterprise Linux"; ostype="Linux"; base="Fedora"}, @{Distribution="FreeBSD"; ostype="BSD"; base="Independent"}, @{Distribution="TrueOS"; ostype="BSD"; base="FreeBSD"}, @{Distribution="OpenBSD"; ostype="BSD"; base="Independent"} )
PS C:\> $hls = ( >> @{Distribution="Ubuntu"; ostype="Linux"; base="Debian"}, >> @{Distribution="Debian"; ostype="Linux"; base="Independent"}, >> @{Distribution="Red Hat Enterprise Linux"; ostype="Linux"; base="Fedora"}, >> @{Distribution="FreeBSD"; ostype="BSD"; base="Independent"}, >> @{Distribution="TrueOS"; ostype="BSD"; base="FreeBSD"}, >> @{Distribution="OpenBSD"; ostype="BSD"; base="Independent"} >> ) PS C:\> $hls Name Value ---- ----- Distribution Ubuntu ostype Linux base Debian Distribution Debian ostype Linux base Independent Distribution Red Hat Enterprise Linux ostype Linux base Fedora Distribution FreeBSD ostype BSD base Independent Distribution TrueOS ostype BSD base FreeBSD Distribution OpenBSD ostype BSD base Independent
$fls = $hls | % { New-Object PSCustomObject -Property $_ }
PS C:\> $fls = $hls | % { New-Object PSCustomObject -Property $_ } PS C:\> $fls Distribution ostype base ------------ ------ ---- Ubuntu Linux Debian Debian Linux Independent Red Hat Enterprise Linux Linux Fedora FreeBSD BSD Independent TrueOS BSD FreeBSD OpenBSD BSD Independent
PS C:\> $fls | Format-Table -Property Distribution, base Distribution base ------------ ---- Ubuntu Debian Debian Independent Red Hat Enterprise Linux Fedora FreeBSD Independent TrueOS FreeBSD OpenBSD Independent
以上、ハッシュの配列を表形式で表示する方法でした。