Monday Morning Formatting - PSCustomobject

Hi All

i have the below going out and poking a list of servers to see what OS is installed, all working fine however when i push out to a csv it is not in columns but all held as text in a single column

###############
##Get Servers##
###############

$servers = Get-Content "\\eurorchestrator\c$\servers2.csv"

###########
##Command##
###########

$output = foreach ($server in $servers)
{
    $operating = (Get-WmiObject -class Win32_OperatingSystem -computername $server).name
    

[pscustomobject]@{

'Computername' = "$Server"
'OSVersion' = "$operating"

} 

}

#################
##Build Results##
#################

$output |ft computername, osversion -AutoSize | Out-File "\\eurorchestrator\c$\serversResults.csv" 

Im After column A “Compuetername” Column B “OSVersion”

Thanks

Hi Mark,

Substitute line 29 with this and you should get what you’re after.

$output | Export-Csv -Path \\path\to\file.csv -NoTypeInformation -UseCulture

Many thanks Christian, worked great