Exporting to CSV contains truncated results

Hello all,

I am new to using PS and am experiencing a small issue. Below is the script that I am currently using to pull workstation information from AD but when it gets exported to CSV the part of carLicense, in that attribute we have populating the Make/Model of the laptop, is truncated and the cell doesn’t contain all the information (posted below). I am open to any and all ideas for this. *Note that I have replaced information in the OU structure but you get the idea.

Get-ADComputer -SearchBase “OU=Work,OU=Workstations,OU=Location,OU=Organization,DC=Domain,DC=Domain,DC=Domain,DC=Domainl” -filter * -Properties * | FT name,CanonicalName, enabled, carLicense, serialNumber, OperatingSystem, operatingsystemversion, IPv4Address, lastlogon >“C:\Users\me\Documents\WKSTN-AD.csv”"

carLicense results show {HP EliteBook x3… or {Latitude 7330 R…

Change ft to Select-Object. Then read up:

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/export-csv?view=powershell-7.4

1 Like

Thank you very much. That does fix the issue but now it exports the info into one column (figure 1) vice being able to do a Text-to-Column function so that the spreadsheet can be filterable (figure 2, the pipes between attributes are different columns).

Figure 1.
name:
CanonicalName:
enabled:
carLicense:
serialNumber:
OperatingSystem:
operatingsystemversion:
IPv4Address:
lastlogon:

Figure 2.
name | CanonicalName | enabled | carLicense | serialNumber | OperatingSystem | operatingsystemversion | IPv4Address | lastlogon

Hi reesetj and welcome to the forums!

Before I answer, please be sure that your code adheres to the coding standards on the forums by following:

Instead of using a Select-Object, why not try returning a New-Object with those properties and values?

1 Like

This will get AD properties and export to csv.

Get-ADComputer -SearchBase “OU=Work,OU=Workstations,OU=Location,OU=Organization,DC=Domain,DC=Domain,
DC=Domain,DC=Domainl” -Filter * -Properties name,CanonicalName,enabled,carLicense,
serialNumber,OperatingSystem,operatingsystemversion,IPv4Address,lastlogon | 
Export-Csv -Path C:\Users\me\Documents\WKSTN-AD.csv

Please run the script and give us the output you are seeing and what you want it to look at. Also show us what commands you are running now.