0

Not sure what's going on. I have a PS script file called dothis.ps1 with the following code:

Function dothis($in) 
{
  Write-Host "Check $in"
}

Now, I call this in the regular powershell window (not ISE):

.\dothis.ps1 test

However, nothing is being printed to the screen. What noob mistake am I making?

1 Answer 1

3

It looks like you are forgetting to call the function:

Function dothis($in) 
{
  Write-Host "Check $in"
}

dothis          # Call function dothis
dothis 'hello'  # Call function dothis with an argument

Note too that PoweShell is not like a lot of programming languages which call functions like this:

# This is how languages such as C, Java, Python, etc. call functions
dothis()
dothis('hello')

For more information on PowerShell functions, see here.

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

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.