Replace NULL value in powershell output

Question:

I’m really struggling with what seems to be a simple thing. Any help is appreciated…

tldr; i’m trying to find and replace blank or NULL values from powershell
output to “No Data”

I am using the following powershell script to obtain installed application information

Below is sample output of the above script (filtered to my liking). I am taking this data, exporting it to CSV, in order to import into another application for analysis at a later time.

the CSV export puts the data in the correct format, but where items have no data for version, publisher, etc…, it represents it as “,,” (see below)

When importing the CSV, the blank values are re-interpreted as NULL, which throws the program for a loop, as it is expecting a string. I am attempting to change those to the string “No Data” but am having lots of trouble…

What would be the best way to handle this?

Answer:

Using Select-Object would be your best bet. Just pipe the data to Select-Object, but customize each desired property as follows:

Source:

Replace NULL value in powershell output by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply