From the course: PowerShell 5 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Creating your first script

Creating your first script - PowerShell Tutorial

From the course: PowerShell 5 Essential Training

Start my 1-month free trial

Creating your first script

- Using all of the information and knowledge that we've accomplished together in this course, it's time to build our first script together. And this is one of the interesting things, is why we always start in the console. This is where I solve my problem and then I start to turn it into a script. So let's do something really straightforward. I want to get some event log information, so I'll use Get-eventlog and LogName, I want to get it from the system and I want just the Newest 5, and an EntryType of error, believe there'll be some of those and I like to check as I'm going along to see what kind of information I'm getting. You know, this is great, I like this, but I really only want a certain amount of information. I want the Index, Source, and the Message. Now, if I'm not sure of the exact property names and I need to warn you, these column names may not be the exact property names. Always pipe to Get-Member to take a look. In this case I believe they are, so let's go ahead. And…

Contents