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++?

  • 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". – Lee_Dailey Sep 18 '20 at 09: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. – Lee_Dailey Sep 18 '20 at 09:37
  • 2
    `input` also lacks a dedicated method. there are, however, the `Read-*` cmdlets ... [*grin*] – Lee_Dailey Sep 18 '20 at 09: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](https://stackoverflow.com/questions/12069109/getting-input-from-the-user-in-lua) which I think that I probably didn't violate the rules. –  Sep 19 '20 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. – Lee_Dailey Sep 19 '20 at 14:15

2 Answers2

1

Try:

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

Powershell support many languages.

boxdog
  • 7,894
  • 2
  • 18
  • 27
MR Mark II
  • 433
  • 3
  • 13
  • 2
    please, DO NOT post images of code. why? lookee ... Why not upload images of code/errors when asking a question? - Meta Stack Overflow — https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question – Lee_Dailey Sep 18 '20 at 09:39
  • you are very welcome! glad to have helped a bit ... and to see your actual code. [*grin*] – Lee_Dailey Sep 18 '20 at 10:00
  • 2
    Also "gal echo" and "gal gal". – Walter Mitty Sep 18 '20 at 10:51
1

There is another way, Write-Host.