In bash, I am using the following bcp command to create an XML format:
bcp DATABASE.[UserData] format nul -c -x -f F:\UsageExports\UserData.xml -t, -T
However, when I run the same command in Powershell, I get the error: Missing argument in parameter list
I also tried executing the command without in Powershell:
bcp DATABASE.[UserData] format nul -c -x -f F:\UsageExports\UserData.xml -t -T
However, the -t tag does not work and the terminator is not included in the XML.
PowerShell can be rather picky when it comes to passing arguments to an external command. Usually the best way of dealing with such a situation is to define an array with the arguments and then splat that array on the command:
$params = 'DATABASE.[UserData]', 'format', 'nul', '-c', '-x',
'-f', 'F:\UsageExports\UserData.xml', '-t,', '-T'
& bcp @params
In your case the issue is probably caused by the argument ,
for the parameter -t
. A comma in PowerShell is used for constructing arrays. I would guess that -t, -T
is interpreted as @('-t', '-T')
and then mangled to '-t -T'
when the external command is invoked.