Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Export-Csv has different results compared to Out-Gridview

$
0
0

I have this code which works (mostly written by Bob McCoy Cool)

$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.  


Viewing all articles
Browse latest Browse all 6937

Trending Articles