Why is “<” input redirect not implemented in PowerShell?










28















Why is input redirection not implemented in PowerShell?



To do something like this:



mysql -u root < create.sql


I had to switch to "cmd.exe".



Is there an alternative way of doing this in PowerShell?



Please note that the output redirection ">" is implemented in PowerShell. Please consider this before giving an answer.










share|improve this question



















  • 2





    Since you gave piping a script to mysql as your example, I thought I should point you to this in case you try to use Powershell to pipe a backup.

    – Joel B Fant
    Jul 20 '11 at 14:34











  • That is exactly what I was looking for. Granted, not the best solution, but a nice hack, without having to switch back to dos-prompt.

    – drozzy
    Jul 20 '11 at 19:19











  • A year and a half later, I still don't have an answer to this specific question of why input redirect was not implemented.

    – Joel B Fant
    Feb 14 '13 at 4:08
















28















Why is input redirection not implemented in PowerShell?



To do something like this:



mysql -u root < create.sql


I had to switch to "cmd.exe".



Is there an alternative way of doing this in PowerShell?



Please note that the output redirection ">" is implemented in PowerShell. Please consider this before giving an answer.










share|improve this question



















  • 2





    Since you gave piping a script to mysql as your example, I thought I should point you to this in case you try to use Powershell to pipe a backup.

    – Joel B Fant
    Jul 20 '11 at 14:34











  • That is exactly what I was looking for. Granted, not the best solution, but a nice hack, without having to switch back to dos-prompt.

    – drozzy
    Jul 20 '11 at 19:19











  • A year and a half later, I still don't have an answer to this specific question of why input redirect was not implemented.

    – Joel B Fant
    Feb 14 '13 at 4:08














28












28








28


4






Why is input redirection not implemented in PowerShell?



To do something like this:



mysql -u root < create.sql


I had to switch to "cmd.exe".



Is there an alternative way of doing this in PowerShell?



Please note that the output redirection ">" is implemented in PowerShell. Please consider this before giving an answer.










share|improve this question
















Why is input redirection not implemented in PowerShell?



To do something like this:



mysql -u root < create.sql


I had to switch to "cmd.exe".



Is there an alternative way of doing this in PowerShell?



Please note that the output redirection ">" is implemented in PowerShell. Please consider this before giving an answer.







powershell






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 16 '17 at 21:09









Peter Mortensen

13.6k1986111




13.6k1986111










asked Jul 20 '11 at 13:53









drozzydrozzy

21.6k38135235




21.6k38135235







  • 2





    Since you gave piping a script to mysql as your example, I thought I should point you to this in case you try to use Powershell to pipe a backup.

    – Joel B Fant
    Jul 20 '11 at 14:34











  • That is exactly what I was looking for. Granted, not the best solution, but a nice hack, without having to switch back to dos-prompt.

    – drozzy
    Jul 20 '11 at 19:19











  • A year and a half later, I still don't have an answer to this specific question of why input redirect was not implemented.

    – Joel B Fant
    Feb 14 '13 at 4:08













  • 2





    Since you gave piping a script to mysql as your example, I thought I should point you to this in case you try to use Powershell to pipe a backup.

    – Joel B Fant
    Jul 20 '11 at 14:34











  • That is exactly what I was looking for. Granted, not the best solution, but a nice hack, without having to switch back to dos-prompt.

    – drozzy
    Jul 20 '11 at 19:19











  • A year and a half later, I still don't have an answer to this specific question of why input redirect was not implemented.

    – Joel B Fant
    Feb 14 '13 at 4:08








2




2





Since you gave piping a script to mysql as your example, I thought I should point you to this in case you try to use Powershell to pipe a backup.

– Joel B Fant
Jul 20 '11 at 14:34





Since you gave piping a script to mysql as your example, I thought I should point you to this in case you try to use Powershell to pipe a backup.

– Joel B Fant
Jul 20 '11 at 14:34













That is exactly what I was looking for. Granted, not the best solution, but a nice hack, without having to switch back to dos-prompt.

– drozzy
Jul 20 '11 at 19:19





That is exactly what I was looking for. Granted, not the best solution, but a nice hack, without having to switch back to dos-prompt.

– drozzy
Jul 20 '11 at 19:19













A year and a half later, I still don't have an answer to this specific question of why input redirect was not implemented.

– Joel B Fant
Feb 14 '13 at 4:08






A year and a half later, I still don't have an answer to this specific question of why input redirect was not implemented.

– Joel B Fant
Feb 14 '13 at 4:08













2 Answers
2






active

oldest

votes


















11














Although I'm not entirely sure that this question belongs on Stack Overflow, have you looked at the PS Cmdlet for Get-Content? Look how it's used in the examples on TechNet in Using the Get-Content Cmdlet.



Example:



Get-Content c:scriptstest.txt | Foreach-Object Get-Wmiobject -computername $_ win32_bios


Update: Above link to TechNet is broken, but mentioned in comment by Chad Miller Scripting Guy's post Working Around Legacy Redirection Issues with PowerShell gives three options: -use CMD /c, Echo, and Get-Content.






share|improve this answer




















  • 2





    That looks backwards :-(

    – drozzy
    Jul 20 '11 at 14:11






  • 7





    Redirection was covered in a Scripting Guys post using Get-Content blogs.technet.com/b/heyscriptingguy/archive/2011/07/16/…

    – Chad Miller
    Jul 20 '11 at 15:11






  • 2





    @Chad Miller, Oh, of course - that would be the obvious place for a user of powershell to look! /end-sarcasm. Thanks.

    – drozzy
    Jul 20 '11 at 19:16











  • ss64.com is also an obvious place to look period; though granted, the answer at ss64.com/ps/syntax-redirection.html is only implicit

    – nik.shornikov
    Apr 29 '15 at 18:51






  • 1





    The TechNet worked fine when I tried it.

    – Peter Mortensen
    Oct 16 '17 at 21:14


















1














I don't think MySQL will accept PowerShell objects piped to it - as Stephan says though, you could use Get-Content and pipe it to the next command.



Check out Stack Overflow question Is PowerShell ready to replace my Cygwin shell on Windows? for reasons on why they haven't copied Unix shells.






share|improve this answer

























  • Sorry, but where are there reasons? It's just comparisons it seems...

    – drozzy
    Jul 20 '11 at 19:17











  • Did you read Jeffery Snover's comment? He talks about the reasons.

    – Matt
    Jul 20 '11 at 20:07












  • I see no reasons on input redirects in particular, and I am really not interested in Unix vs Windows tools. I was only curious about the one particular tool. After all, the output redirection ">" is implemented!

    – drozzy
    Jul 22 '11 at 16:59











  • I was considering the question more generically in why certain aspects of powershell do not implement the same functions as other shells. I didn't say it answered why < wasn't implemented though it provides insight into the design process,

    – Matt
    Jul 24 '11 at 10:50











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f6763086%2fwhy-is-input-redirect-not-implemented-in-powershell%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









11














Although I'm not entirely sure that this question belongs on Stack Overflow, have you looked at the PS Cmdlet for Get-Content? Look how it's used in the examples on TechNet in Using the Get-Content Cmdlet.



Example:



Get-Content c:scriptstest.txt | Foreach-Object Get-Wmiobject -computername $_ win32_bios


Update: Above link to TechNet is broken, but mentioned in comment by Chad Miller Scripting Guy's post Working Around Legacy Redirection Issues with PowerShell gives three options: -use CMD /c, Echo, and Get-Content.






share|improve this answer




















  • 2





    That looks backwards :-(

    – drozzy
    Jul 20 '11 at 14:11






  • 7





    Redirection was covered in a Scripting Guys post using Get-Content blogs.technet.com/b/heyscriptingguy/archive/2011/07/16/…

    – Chad Miller
    Jul 20 '11 at 15:11






  • 2





    @Chad Miller, Oh, of course - that would be the obvious place for a user of powershell to look! /end-sarcasm. Thanks.

    – drozzy
    Jul 20 '11 at 19:16











  • ss64.com is also an obvious place to look period; though granted, the answer at ss64.com/ps/syntax-redirection.html is only implicit

    – nik.shornikov
    Apr 29 '15 at 18:51






  • 1





    The TechNet worked fine when I tried it.

    – Peter Mortensen
    Oct 16 '17 at 21:14















11














Although I'm not entirely sure that this question belongs on Stack Overflow, have you looked at the PS Cmdlet for Get-Content? Look how it's used in the examples on TechNet in Using the Get-Content Cmdlet.



Example:



Get-Content c:scriptstest.txt | Foreach-Object Get-Wmiobject -computername $_ win32_bios


Update: Above link to TechNet is broken, but mentioned in comment by Chad Miller Scripting Guy's post Working Around Legacy Redirection Issues with PowerShell gives three options: -use CMD /c, Echo, and Get-Content.






share|improve this answer




















  • 2





    That looks backwards :-(

    – drozzy
    Jul 20 '11 at 14:11






  • 7





    Redirection was covered in a Scripting Guys post using Get-Content blogs.technet.com/b/heyscriptingguy/archive/2011/07/16/…

    – Chad Miller
    Jul 20 '11 at 15:11






  • 2





    @Chad Miller, Oh, of course - that would be the obvious place for a user of powershell to look! /end-sarcasm. Thanks.

    – drozzy
    Jul 20 '11 at 19:16











  • ss64.com is also an obvious place to look period; though granted, the answer at ss64.com/ps/syntax-redirection.html is only implicit

    – nik.shornikov
    Apr 29 '15 at 18:51






  • 1





    The TechNet worked fine when I tried it.

    – Peter Mortensen
    Oct 16 '17 at 21:14













11












11








11







Although I'm not entirely sure that this question belongs on Stack Overflow, have you looked at the PS Cmdlet for Get-Content? Look how it's used in the examples on TechNet in Using the Get-Content Cmdlet.



Example:



Get-Content c:scriptstest.txt | Foreach-Object Get-Wmiobject -computername $_ win32_bios


Update: Above link to TechNet is broken, but mentioned in comment by Chad Miller Scripting Guy's post Working Around Legacy Redirection Issues with PowerShell gives three options: -use CMD /c, Echo, and Get-Content.






share|improve this answer















Although I'm not entirely sure that this question belongs on Stack Overflow, have you looked at the PS Cmdlet for Get-Content? Look how it's used in the examples on TechNet in Using the Get-Content Cmdlet.



Example:



Get-Content c:scriptstest.txt | Foreach-Object Get-Wmiobject -computername $_ win32_bios


Update: Above link to TechNet is broken, but mentioned in comment by Chad Miller Scripting Guy's post Working Around Legacy Redirection Issues with PowerShell gives three options: -use CMD /c, Echo, and Get-Content.







share|improve this answer














share|improve this answer



share|improve this answer








edited Oct 16 '17 at 21:12









Peter Mortensen

13.6k1986111




13.6k1986111










answered Jul 20 '11 at 13:57









Stephen KininghamStephen Kiningham

444617




444617







  • 2





    That looks backwards :-(

    – drozzy
    Jul 20 '11 at 14:11






  • 7





    Redirection was covered in a Scripting Guys post using Get-Content blogs.technet.com/b/heyscriptingguy/archive/2011/07/16/…

    – Chad Miller
    Jul 20 '11 at 15:11






  • 2





    @Chad Miller, Oh, of course - that would be the obvious place for a user of powershell to look! /end-sarcasm. Thanks.

    – drozzy
    Jul 20 '11 at 19:16











  • ss64.com is also an obvious place to look period; though granted, the answer at ss64.com/ps/syntax-redirection.html is only implicit

    – nik.shornikov
    Apr 29 '15 at 18:51






  • 1





    The TechNet worked fine when I tried it.

    – Peter Mortensen
    Oct 16 '17 at 21:14












  • 2





    That looks backwards :-(

    – drozzy
    Jul 20 '11 at 14:11






  • 7





    Redirection was covered in a Scripting Guys post using Get-Content blogs.technet.com/b/heyscriptingguy/archive/2011/07/16/…

    – Chad Miller
    Jul 20 '11 at 15:11






  • 2





    @Chad Miller, Oh, of course - that would be the obvious place for a user of powershell to look! /end-sarcasm. Thanks.

    – drozzy
    Jul 20 '11 at 19:16











  • ss64.com is also an obvious place to look period; though granted, the answer at ss64.com/ps/syntax-redirection.html is only implicit

    – nik.shornikov
    Apr 29 '15 at 18:51






  • 1





    The TechNet worked fine when I tried it.

    – Peter Mortensen
    Oct 16 '17 at 21:14







2




2





That looks backwards :-(

– drozzy
Jul 20 '11 at 14:11





That looks backwards :-(

– drozzy
Jul 20 '11 at 14:11




7




7





Redirection was covered in a Scripting Guys post using Get-Content blogs.technet.com/b/heyscriptingguy/archive/2011/07/16/…

– Chad Miller
Jul 20 '11 at 15:11





Redirection was covered in a Scripting Guys post using Get-Content blogs.technet.com/b/heyscriptingguy/archive/2011/07/16/…

– Chad Miller
Jul 20 '11 at 15:11




2




2





@Chad Miller, Oh, of course - that would be the obvious place for a user of powershell to look! /end-sarcasm. Thanks.

– drozzy
Jul 20 '11 at 19:16





@Chad Miller, Oh, of course - that would be the obvious place for a user of powershell to look! /end-sarcasm. Thanks.

– drozzy
Jul 20 '11 at 19:16













ss64.com is also an obvious place to look period; though granted, the answer at ss64.com/ps/syntax-redirection.html is only implicit

– nik.shornikov
Apr 29 '15 at 18:51





ss64.com is also an obvious place to look period; though granted, the answer at ss64.com/ps/syntax-redirection.html is only implicit

– nik.shornikov
Apr 29 '15 at 18:51




1




1





The TechNet worked fine when I tried it.

– Peter Mortensen
Oct 16 '17 at 21:14





The TechNet worked fine when I tried it.

– Peter Mortensen
Oct 16 '17 at 21:14













1














I don't think MySQL will accept PowerShell objects piped to it - as Stephan says though, you could use Get-Content and pipe it to the next command.



Check out Stack Overflow question Is PowerShell ready to replace my Cygwin shell on Windows? for reasons on why they haven't copied Unix shells.






share|improve this answer

























  • Sorry, but where are there reasons? It's just comparisons it seems...

    – drozzy
    Jul 20 '11 at 19:17











  • Did you read Jeffery Snover's comment? He talks about the reasons.

    – Matt
    Jul 20 '11 at 20:07












  • I see no reasons on input redirects in particular, and I am really not interested in Unix vs Windows tools. I was only curious about the one particular tool. After all, the output redirection ">" is implemented!

    – drozzy
    Jul 22 '11 at 16:59











  • I was considering the question more generically in why certain aspects of powershell do not implement the same functions as other shells. I didn't say it answered why < wasn't implemented though it provides insight into the design process,

    – Matt
    Jul 24 '11 at 10:50
















1














I don't think MySQL will accept PowerShell objects piped to it - as Stephan says though, you could use Get-Content and pipe it to the next command.



Check out Stack Overflow question Is PowerShell ready to replace my Cygwin shell on Windows? for reasons on why they haven't copied Unix shells.






share|improve this answer

























  • Sorry, but where are there reasons? It's just comparisons it seems...

    – drozzy
    Jul 20 '11 at 19:17











  • Did you read Jeffery Snover's comment? He talks about the reasons.

    – Matt
    Jul 20 '11 at 20:07












  • I see no reasons on input redirects in particular, and I am really not interested in Unix vs Windows tools. I was only curious about the one particular tool. After all, the output redirection ">" is implemented!

    – drozzy
    Jul 22 '11 at 16:59











  • I was considering the question more generically in why certain aspects of powershell do not implement the same functions as other shells. I didn't say it answered why < wasn't implemented though it provides insight into the design process,

    – Matt
    Jul 24 '11 at 10:50














1












1








1







I don't think MySQL will accept PowerShell objects piped to it - as Stephan says though, you could use Get-Content and pipe it to the next command.



Check out Stack Overflow question Is PowerShell ready to replace my Cygwin shell on Windows? for reasons on why they haven't copied Unix shells.






share|improve this answer















I don't think MySQL will accept PowerShell objects piped to it - as Stephan says though, you could use Get-Content and pipe it to the next command.



Check out Stack Overflow question Is PowerShell ready to replace my Cygwin shell on Windows? for reasons on why they haven't copied Unix shells.







share|improve this answer














share|improve this answer



share|improve this answer








edited Oct 16 '17 at 21:15









Peter Mortensen

13.6k1986111




13.6k1986111










answered Jul 20 '11 at 14:37









MattMatt

1,619919




1,619919












  • Sorry, but where are there reasons? It's just comparisons it seems...

    – drozzy
    Jul 20 '11 at 19:17











  • Did you read Jeffery Snover's comment? He talks about the reasons.

    – Matt
    Jul 20 '11 at 20:07












  • I see no reasons on input redirects in particular, and I am really not interested in Unix vs Windows tools. I was only curious about the one particular tool. After all, the output redirection ">" is implemented!

    – drozzy
    Jul 22 '11 at 16:59











  • I was considering the question more generically in why certain aspects of powershell do not implement the same functions as other shells. I didn't say it answered why < wasn't implemented though it provides insight into the design process,

    – Matt
    Jul 24 '11 at 10:50


















  • Sorry, but where are there reasons? It's just comparisons it seems...

    – drozzy
    Jul 20 '11 at 19:17











  • Did you read Jeffery Snover's comment? He talks about the reasons.

    – Matt
    Jul 20 '11 at 20:07












  • I see no reasons on input redirects in particular, and I am really not interested in Unix vs Windows tools. I was only curious about the one particular tool. After all, the output redirection ">" is implemented!

    – drozzy
    Jul 22 '11 at 16:59











  • I was considering the question more generically in why certain aspects of powershell do not implement the same functions as other shells. I didn't say it answered why < wasn't implemented though it provides insight into the design process,

    – Matt
    Jul 24 '11 at 10:50

















Sorry, but where are there reasons? It's just comparisons it seems...

– drozzy
Jul 20 '11 at 19:17





Sorry, but where are there reasons? It's just comparisons it seems...

– drozzy
Jul 20 '11 at 19:17













Did you read Jeffery Snover's comment? He talks about the reasons.

– Matt
Jul 20 '11 at 20:07






Did you read Jeffery Snover's comment? He talks about the reasons.

– Matt
Jul 20 '11 at 20:07














I see no reasons on input redirects in particular, and I am really not interested in Unix vs Windows tools. I was only curious about the one particular tool. After all, the output redirection ">" is implemented!

– drozzy
Jul 22 '11 at 16:59





I see no reasons on input redirects in particular, and I am really not interested in Unix vs Windows tools. I was only curious about the one particular tool. After all, the output redirection ">" is implemented!

– drozzy
Jul 22 '11 at 16:59













I was considering the question more generically in why certain aspects of powershell do not implement the same functions as other shells. I didn't say it answered why < wasn't implemented though it provides insight into the design process,

– Matt
Jul 24 '11 at 10:50






I was considering the question more generically in why certain aspects of powershell do not implement the same functions as other shells. I didn't say it answered why < wasn't implemented though it provides insight into the design process,

– Matt
Jul 24 '11 at 10:50


















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f6763086%2fwhy-is-input-redirect-not-implemented-in-powershell%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

政党

天津地下鉄3号線