function displayHello
{
Write-Host "Hello World"
}
displayHello
# Pass a parameter
function displaySomething
{
Write-Host $args
}
displaySomething 'Hello Again'
# Working with multiple parameters
function addNumbers
{
Write-Host ($args[0] + $args[1])
}
# Displays 7
addNumbers 3 4
# Fancier way to work with multiple parameters
function AddNumbersAgain
{
param( [int]$num1, [int]$num2 )
write-host ($num1 + $num2)
}
# Displays 9
AddNumbersAgain 4 5
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.