-1
コンピュータのリストのコンピュータ情報を取得してテーブルに追加しようとしています。どのように私はハッシュテーブルからデータを取得し、1つのテーブルに追加することができます混乱の種類。以下は私がこれまで持っていたコードです。どんな援助も感謝します!複数のハッシュテーブルの値をPowershellのテーブルでフォーマットする必要があります
$name = Get-Content .\computers.txt
foreach($c in $Name){
$test = Test-Connection -ComputerName $c -Count 1 -Quiet
if($test -eq $true)
{
$os = Get-WmiObject -Class win32_operatingsystem -ComputerName $c -ErrorAction SilentlyContinue
$cs = Get-WmiObject -Class win32_computersystem -ComputerName $c -ErrorAction SilentlyContinue
$pr = Get-WmiObject -Class win32_processor -ComputerName $c -ErrorAction SilentlyContinue
$bs = Get-WmiObject -Class win32_bios -ComputerName $c -ErrorAction SilentlyContinue
$ps = Get-WmiObject -Class win32_processor -ComputerName $c -ErrorAction SilentlyContinue
$us = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $c -ErrorAction SilentlyContinue
[hashtable]$osProperties = @{
‘Model’=$cs.model;
‘Manufacturer’=$cs.manufacturer;
‘RAM’=$cs.totalphysicalmemory/1GB -as [int] ;
‘Cores’=$cs.numberoflogicalprocessors;
‘SystemType’=$cs.SystemType
‘CPU’=$pr.name;
‘Serial’=$bs.serialnumber
‘OSVersion’=$os.caption;
'User'=$us.username;
}
#$obj = New-Object -TypeName PSCustomObject -Property $osProperties | select Manufacturer, Model, Serial, OSVersion, CPU, Cores, @{name="Ram (GB)";expression={$($_.Ram)}}, User | ft
}
else{
$c=$Null
}
}