Writing the Get-GreetingMessage Function
You can expand the box below to see the full source code for this lesson:
Get-GreetingMessage.ps1 Full Source Code
In this lesson, we're going to be writing the get dash greeting message function inside of our PowerShell module. So to get started, let's explain what this function does.
It's going to take a user's name, so it's going to take a set of parameters, and I'll just kind of comment this here, so, get parameters, and this is going to be the user's name, and then we're going to get the initial greeting, which we'll use the message, you know, we'll write like a string, like hello, and then whatever the user's name then we'll get a random message from the new greeting function over here, so get a random message, and then we'll output that to the user, so output the messages to the user.
Alright, so to get started, we will start by defining some parameters. So, I'm going to say param; this is how you declare parameters for a function in PowerShell. And we're going to do an opening and closing brace. And this will, we'll spell out the word parameter, and then in parentheses, we're going to say mandatory equals and then dollar sign true.
This means you cannot…
No comments yet. Add the first comment to start the discussion.