一般信息
$ComputerSystem = Get-WmiObject -Class Win32_ComputerSystem | Select -Property Model , Manufacturer , Description , PrimaryOwnerName , SystemType
启动配置
$BootConfiguration = Get-WmiObject -Class Win32_BootConfiguration | Select -Property Name , ConfigurationPath
BIOS信息
$BIOS = Get-WmiObject -Class Win32_BIOS | Select -Property PSComputerName , Manufacturer , Version #| Export-Csv -InputObject
操作系统信息
$OS = Get-WmiObject -Class Win32_OperatingSystem | Select -Property Caption , CSDVersion , OSArchitecture , OSLanguage
我想将所有这些变量导出到带有标题的csv文件,但我无法。
答案 0 :(得分:0)
以下将get-wmiobject命令单独创建的每个对象的noteproperties组合到$ report变量中。从那里你可以导出到csv。
通过循环遍历gwmi调用创建的每个变量并将noteproperties添加到报表变量中,可以更好地简化这一过程。
$ComputerSystem = Get-WmiObject -Class Win32_ComputerSystem | Select -Property Model , Description , PrimaryOwnerName , SystemType
$BootConfiguration = Get-WmiObject -Class Win32_BootConfiguration | Select -Property Name , ConfigurationPath
$BIOS = Get-WmiObject -Class Win32_BIOS | Select -Property PSComputerName , Manufacturer , Version
$OperatingSystem = Get-WmiObject -Class Win32_OperatingSystem | Select -Property Caption , CSDVersion , OSArchitecture , OSLanguage
$report = New-Object psobject
$report | Add-Member -MemberType NoteProperty -name Model -Value $ComputerSystem.Model
$report | Add-Member -MemberType NoteProperty -name Description -Value $ComputerSystem.Description
$report | Add-Member -MemberType NoteProperty -name PrimaryOwnerName -Value $ComputerSystem.PrimaryOwnerName
$report | Add-Member -MemberType NoteProperty -name SystemType -Value $ComputerSystem.SystemType
$report | Add-Member -MemberType NoteProperty -name Name -Value $BootConfiguration.Name
$report | Add-Member -MemberType NoteProperty -name ConfigurationPath -Value $BootConfiguration.ConfigurationPath
$report | Add-Member -MemberType NoteProperty -name PSComputerName -Value $BIOS.PSComputerName
$report | Add-Member -MemberType NoteProperty -name Manufacturer -Value $BIOS.Manufacturer
$report | Add-Member -MemberType NoteProperty -name Version -Value $BIOS.Version
$report | Add-Member -MemberType NoteProperty -name Caption -Value $OS.Caption
$report | Add-Member -MemberType NoteProperty -name CSDVersion -Value $OS.CSDVersion
$report | Add-Member -MemberType NoteProperty -name OSArchitecture -Value $OS.OSArchitecture
$report | Add-Member -MemberType NoteProperty -name OSLanguage -Value $OS.OSLanguage
$report | export-csv .\file.csv -NoTypeInformation