troubleshooting Question

PowerShell command to replace value before creating CSV file

Avatar of Christian Palacios
Christian PalaciosFlag for Canada asked on
Microsoft SQL ServerPowershellSQL* string
6 Comments1 Solution17 ViewsLast Modified:
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

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros