Sorry got as cold today. But we can still chat right?
Today we’re going to learn about Variables in Powershell. Ok don’t run away. I’m not going to get all Developer on you and starting speaking in Tongues and spout Functions and code.
We’re going to use Variables for the moment the same way we did in Dos. Dos was easy
And if we wanted to see that we did
Looks familiar right?
In Windows Powershell we don’t have to use SET and the Variable name always starts with “$” (That’s to remind you of all the money you’re going to save with Windows Powershell )
In actual fact, I think they stole it from Python (no not Monty Python) but I could be wrong. So here is the same Variable we did in Dos in Powershell
You’ll see another difference. I put quotes around the text. Powershell is Smart enough to know the difference between Text and numbers. But it has to be told that. To identify TEXT from a Number you put either a Single quote around either side or Double quotes. There is a difference but don’t worry about that now. Text is still text. Double quotes just give us “extra Powers” later on.
Now if want to Echo that back to the screen I can just type in
Here’s the neat part with Powershell variables. They do all the hard work. I can tell a Powershell variable that it’s a Number, Text or even the Date and IT will figure it out. Like this
$ABunchOfSillyWords=’Hi Diddly Dee, an IT Pro Life for me’
I can see a few eyes popping open. “What do you mean you ran a Cmdlet and stored it’s output away?”
That’s because we’re working with Objects. We’ll talk about that next time, Right now I have to go sneeze