I have this code which works (mostly written by Bob McCoy
)
$pc=Get-Content C:\temp\IE11Fail.txt
$results= @()
$results=foreach ($machinein$pc) {
$computerName= (Get-WMIObject-class Win32_ComputerSystem -computername$machine).name
$osInfo=Get-WMIObject-Class Win32_Operatingsystem -ComputerName$machine
$getip= ([version](Test-Connection$machine-Count 1).IPV4Address.IPAddressToString).Build
$desc= (Get-ADComputer$machine-Properties Description).description
$ie= (Get-Command"\\$machine\c$\Program Files\Internet Explorer\iexplore.exe").Version
[PSCustomObject]@{
PCName =$computerName
'OS Version'=$osInfo.Version
'OS Type'=$osInfo.Caption
'AD Description'=$desc
'IP vLan'=$getip
'IE Version'=$ie
}}
# $results | export-csv "c:\temp\IEFail.csv" -NoTypeInformation
$results | Out-GridView
When I run this with the out-gridview my data is correct. I have a column for each thing I'm seeking. PCName contains each PC name that was in the .TXT file.
But when I use the export-csv the PCName column does not display the computer name. Instead it displays System.String[] Why?
Thanks.