This is a section of a function I’m using for a software inventory I’m running against remote machines. As it stands, the output adds unnecessary spaces between each value returned in these variables, and throwing the following error:
New-Item : Could not find a part of the path 'filepath \ prod-adcweb1 _ 20180209 .csv'.
At filepath\GetInstalledApplication.ps1:181 char:1
+ New-Item -ItemType file $outfile -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (C:\users\username_ 20180209 .csv:String) [New-Item], DirectoryNotFoundException
+ FullyQualifiedErrorId : NewItemIOError,Microsoft.PowerShell.Commands.NewItemCommand
export-csv : Could not find a part of the path 'filepath \ prod-adcweb1 _ 20180209 .csv'.
At filepath\GetInstalledApplication.ps1:182 char:11
+ $object | export-csv -path $outfile
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (:) [Export-Csv], DirectoryNotFoundException
+ FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.ExportCsvCommand
I’ve been staring at this too long, wondering if someone else has an answer as to how I can remove these spaces. Thank you in advance.