Avatar of Christian Palacios
Christian Palacios
Flag for Canada

asked on 

PowerShell command to replace value before creating CSV file

Hi there,

I am creating multiple CSV files with PowerShell based on data from an SQL Server.  I am creating a blank column at first with the SQL Select command and putting this in the command, [DEALERSHIP ADDRESS]='', that way it has the right name I want, which is DEALERSHIP ADDRESS.  When I try to replace this value with a specific address from an array, I am getting this error below.  I'm thinking it's because the column name has two words.  How can I fix this replace command so that it recognizes the correct column and I am then able to update it before I create the CSV file?  Please ask any questions you might have, thanks!

At line:23 char:19
+     $_.[DEALERSHIP ADDRESS] = $cityaddresses[$i]
+                   ~
Missing ] at end of attribute or type literal.
At line:23 char:20
+     $_.[DEALERSHIP ADDRESS] = $cityaddresses[$i]
+                    ~~~~~~~~
Unexpected token 'ADDRESS]' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : EndSquareBracketExpectedAtEndOfAttribute



Thanks,
-Christian
Microsoft SQL ServerPowershellSQL* string

Avatar of undefined
Last Comment
Christian Palacios

8/22/2022 - Mon