I have a list of machine names and I need to export to CSV the computer name, OS version and IP address.
$pc = Get-Content "c:\temp\tmp\machines.txt" foreach ($machines in $pc) {Get-WmiObject -Class Win32_OperatingSystem -ComputerName $machines | Select version; Get-WMIObject -class Win32_ComputerSystem -computername $machines | Select name | Export-CSV c:\temp\tmp\Output.csv}
Each get-wmiobject command works fine when I run them one at at time. But since I'm using to 2 different Select statements how to I join them?
I've tried this: $pc = Get-Content "c:\temp\tmp\machines.txt"
foreach ($machines in $pc) {(Get-WmiObject -Class Win32_OperatingSystem -ComputerName $machines).version ; (Get-WMIObject -class Win32_ComputerSystem -computername $machines).name | Export-CSV c:\temp\tmp\Output.csv}
and in PowerShell ISE the output is just the OS version. The data in my exported file is junk.
Once I get this working I need to get the systems IP address.
the problem I'm trying to solve is we are doing a Windows 7 upgrade and the PM said we are down to under 100 XP systems left. I looked in SCCM 2007 and it says we have over 360 XP systems. so I have the list of 360 machines and I want to export out the machine name, OS version and IP. With that we can track them down based on IP address.