ratmin193
Goto Top

Ergebnis von foreach-schleife in .csv Datei exportieren

Hallo,

habe folgendes Problem..kenne mich noch recht wenig mit Powershell aus, habe aber zumindest schonmal eine Konsolenausgabe hinbekommen, die mir CPU ID, Anzahl Kerne etc. anzeigt.

$strComputer = "."

$colItems = Get-WmiObject -class "Win32_Processor" -namespace "root/CIMV2" -computername $strComputer

foreach ($objItem in $colItems)
{
write-host "CPU ID: " -foregroundcolor yellow -NoNewLine
write-host $objItem.DeviceID -foregroundcolor white
write-host "CPU Model: " -foregroundcolor yellow -NoNewLine
write-host $objItem.Name -foregroundcolor white
write-host "CPU Cores: " -foregroundcolor yellow -NoNewLine
write-host $objItem.NumberOfCores -foregroundcolor white
write-host "CPU Max Speed: " -foregroundcolor yellow -NoNewLine
write-host $objItem.MaxClockSpeed
write-host "CPU Status: " -foregroundcolor yellow -NoNewLine
write-host $objItem.Status
}

Nun will ich dieses Ergebnis aber als CSV exportieren und weiß nicht wie.

Danke für eure Hilfe,
Ratmin193

Content-Key: 202063

Url: https://administrator.de/contentid/202063

Printed on: April 26, 2024 at 04:04 o'clock

Member: B4DschK4Pp
B4DschK4Pp Feb 21, 2013 at 12:34:11 (UTC)
Goto Top
Hi,

ich kenne mich auch kaum bis gar nicht mit Powershell aus, aber ich habe schon mal vom Befehl Export-CSV gehört.
http://technet.microsoft.com/de-de/library/ee176825.aspx

Bringt dir das was?

Gruß
Member: B4DschK4Pp
B4DschK4Pp Feb 21, 2013 updated at 13:27:59 (UTC)
Goto Top
Hallo nochmal,

hab's grad mal ausprobiert. Füg mal noch die Zeile

$colItems | Select-Object DeviceID,Name,NumberOfCores,MaxClockSpeed,Status | Export-Csv "C:\temp\testcsv2.csv"

an dein Script an. Langt dir das?

Gruß
Member: Ratmin193
Ratmin193 Feb 25, 2013 at 13:04:44 (UTC)
Goto Top
Danke, das funktioniert.

Gruß