Dead_Eyes
asked on
Format-Table Missing results
Hi fairly new to powershell but have run into a problem I hope is easy to solve
I am trying to get BIOS versions from machines and am running the following script
(Query.txt contains the following info:
Select * from win32_bios
Select * from Win32_Computersystem
and Clients.txt is a list of computers), I am running windows 7 x64 (and the clients) Powershell V3, clients V2
The Script:
$aryquery = Get-Content -path C:\Scripts\BIOSID\Query.tx t
$computer = Get-Content -path C:\Scripts\BIOSID\Clients. txt
Foreach ($query in $aryQuery)
{
Get-WmiObject -Query $query -computername $computer | Format-Table name, SMBIOSBIOSVersion, Model | Out-File -FilePath C:\BIOSID\Results.txt
}
When I run this script I get the following result
Name SMBIOSBIOSVersion Model
---- ----------------- -----
Comp-01 DG41RQ__
Comp-02 DG41RQ__
The SMBIOSBIOSVersion information is blank!
But when I Run
Get-WmiObject -Computername comp-02 -Class win32_bios | Format-Table Name, SMBIOSBIOSVersion, Model | Out-File -FilePath C:\BIOSID\Results.txt
The Model Colum is blank!
What am I doing wrong and why is my data missing?
I am trying to get BIOS versions from machines and am running the following script
(Query.txt contains the following info:
Select * from win32_bios
Select * from Win32_Computersystem
and Clients.txt is a list of computers), I am running windows 7 x64 (and the clients) Powershell V3, clients V2
The Script:
$aryquery = Get-Content -path C:\Scripts\BIOSID\Query.tx
$computer = Get-Content -path C:\Scripts\BIOSID\Clients.
Foreach ($query in $aryQuery)
{
Get-WmiObject -Query $query -computername $computer | Format-Table name, SMBIOSBIOSVersion, Model | Out-File -FilePath C:\BIOSID\Results.txt
}
When I run this script I get the following result
Name SMBIOSBIOSVersion Model
---- ----------------- -----
Comp-01 DG41RQ__
Comp-02 DG41RQ__
The SMBIOSBIOSVersion information is blank!
But when I Run
Get-WmiObject -Computername comp-02 -Class win32_bios | Format-Table Name, SMBIOSBIOSVersion, Model | Out-File -FilePath C:\BIOSID\Results.txt
The Model Colum is blank!
What am I doing wrong and why is my data missing?
You can also save the result to a csv file if required..
Get-Content -path C:\Scripts\BIOSID\Clients.txt | % {
$computer = $_
Get-WmiObject Win32_Computersystem -computername $computer | `
Select name,@{n="SMBIOSBIOSVersion";e={(Get-WmiObject win32_bios -ComputerName $computer).SMBIOSBIOSVersion}},Model
} | Export-Csv C:\BIOSID\Results.csv -NoTypeInformation
ASKER
Thanks for that I will try it asap (looks like syntax way out of my league at the moment lol). Do you have any idea why my way did not work?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Open in new window