0

I am new to PowerShell and I wanna try out a "Hello, (name)." program. Problem is I can't find an input function nor an output one.

Is there a PowerShell function I can use to get input like input in Python and output like cout in C++?

5
  • 2
    have you read the Tour page for this site? [grin] you are in violation of the rules by not posting code that "doesn't work as expected". Commented Sep 18, 2020 at 9:35
  • 2
    as for output ... anything not assigned to something will be sent to the success/output stream. there is no dedicated output method. however, there are several Write-* cmdlets. i recommend you read the Get-Help info on them. Commented Sep 18, 2020 at 9:37
  • 2
    input also lacks a dedicated method. there are, however, the Read-* cmdlets ... [grin] Commented Sep 18, 2020 at 9:38
  • 1
    @Lee_Dailey First, I did read the tour page. Secondly, I don't know how PowerShell works yet and I can't find a way to get the input and output, but I guess cmdlets will help. Third and lastly, I actually did the same thing as this question: Getting input from the user in Lua which I think that I probably didn't violate the rules. Commented Sep 19, 2020 at 12:45
  • 1
    [1] reading all the way thru the tour page normally gives you 100 reputation points. you only show 5 ... so something went wrong. [grin] ///// [2] i showed you a clear hint about Read-*. i recommend you ReadTheFriendlyManual ... Get-Command *read* and Get-Help Read-Host. ///// [3] i also pointed out how to get the equivalent of print via the various Write-* cmdlets. again, take a look at the help system for more info. Commented Sep 19, 2020 at 14:15

2 Answers 2

1

Try:

$User = Read-Host -Prompt "Name"
echo "Hello $User"

Powershell support many languages.

Sign up to request clarification or add additional context in comments.

3 Comments

please, DO NOT post images of code. why? lookee ... Why not upload images of code/errors when asking a question? - Meta Stack Overflow — meta.stackoverflow.com/questions/285551/…
you are very welcome! glad to have helped a bit ... and to see your actual code. [grin]
Also "gal echo" and "gal gal".
1

There is another way, Write-Host.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.