Title: How input a file data for command in windows powershell/cmd
Tags: windows;powershell;command-line-interface;bcp
Question: I am trying to run a BCP command in windows machine powershell and unable to give input from a sql file.
Below command works fine in my MAC and I am looking for the same for Windows machine.
bcp &quot;$(< /Users/mahendra.hegde/Desktop/input.sql)&quot; queryout /Users/mahendra.hegde/dataout.json -c -T -S sample.env.compxyz.com
input.sql file scripts should be passed as input to bcp command when it runs.
I tried many ways in Windows but did not work, any help would be appreciated
Thanks
Comment: Are you just reading the content of a file? please be clear on what you want to achieve

Comment: What did you search for? ['bcp powershell'](https://duckduckgo.com/?q=%27bcp+powershell%27&t=h_&ia=web) --- What have you tried? What happened? [• PowerShell: Running Executables](https://social.technet.microsoft.com/wiki/contents/articles/7703.powershell-running-executables.aspx). There are modules to work wiht SQL via teh MS powershellgallery.com. `Find-Module -Name '*sql*' | Format-Table -AutoSize`

Comment: SO does have rules we are told to follow: [Provide MRE](https://stackoverflow.com/help/minimal-reproducible-example) --- [How to ask](https://stackoverflow.com/help/how-to-ask) --- [Don't ask](https://stackoverflow.com/help/dont-ask) --- [Proper Topic](https://stackoverflow.com/help/on-topic) --- [Why not upload images of code/errors?](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question) --- [format your post properly](https://stackoverflow.com/help/formatting):

Comment: This is in bash on the Mac? If so, please provide a breakdown and explanation of what it's doing.


Here is another answer: The equivalent of this bash command:
bcp &quot;$(< /Users/mahendra.hegde/Desktop/input.sql)&quot; queryout
is this PowerShell command:
bcp (Get-Content -Raw C:/Users/mahendra.hegde/Desktop/input.sql) queryout
Both commands pass the content of the specified file as a single, multiline string to the bcp utility; see the Get-Content cmdlet's documentation.
However, as of PowerShell 7.1, due to broken passing of arguments with embedded &quot; characters - see this answer - more work is needed if the .sql file contains &quot; characters; in the simplest case:
bcp ((Get-Content -Raw C:/Users/mahendra.hegde/Desktop/input.sql) -replace '&quot;', '\&quot;') queryout

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 4, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2021:00:03/08/21', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<windows><powershell><command-line-interface><bcp>', 'Title': 'How input a file data for command in windows powershell/cmd', 'ViewCount': 145, 'id': 66534938, 'user_AboutMe': '', 'user_AccountId': 2146093.0, 'user_DisplayName': 'MHegde', 'user_Reputation': 175.0, 'user_Views': 42.0, 'user_id': 1903691.0}}