The Advanced PowerShell Scripting Crash Course 2019 - Learn PowerShell in less than 3 hours | Dolwin Fernandes | Skillshare

Playback Speed

  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

The Advanced PowerShell Scripting Crash Course 2019 - Learn PowerShell in less than 3 hours

teacher avatar Dolwin Fernandes

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

23 Lessons (2h 43m)
    • 1. Main Introduction

    • 2. 1 Introduction and PowerShell ISE

    • 3. 2 Variables in Powershell Edited

    • 4. 3 Arrays and Hashtables Edited

    • 5. 4 CMDLETS

    • 6. 5 Operators

    • 7. 6 Set Operations

    • 8. 7 Conditional Control Flow

    • 9. 8 Loops

    • 10. 9 Functions and Advanced parameters

    • 11. 10 Advanced functions and parameter validation

    • 12. 11 Let s create our own PowerShell CMDLET

    • 13. 12 Parameter Splatting and Sending Emails via PowerShell

    • 14. 13 Writing Event Logs

    • 15. 14 PowerShell Remoting and the Invoke command

    • 16. 15 REST methods and downloading files with PowerShell

    • 17. 16 WMI classes

    • 18. 17 Working with CSV and XML files

    • 19. 18 Error Handling

    • 20. 19 Active Directory Module

    • 21. 20 Archive Module

    • 22. 21 AWS module for offsite backup

    • 23. Final note

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class

Hello Everyone, and welcome to the Advanced PowerShell course. My name is Dolwin Fernandes and I’ll be your instructor for the course. I have close to 10 years’ experience in Systems administration and operations and currently work for a Gaming Studio in Sydney, Australia. I’ve been using powershell for automating various tasks at my work and also find it to be one the most full featured and powerful scripting tools when it comes to automation. What makes powershell even better, is it’s ability to run on Linux and Mac as well.


In this course, I will take you through from the very basics to the most advanced powershell features and cmdlets. This course is perfect either if you’re new to powershell, a seasoned system admin looking to automate tasks or even if you need to brush up powershell for an interview. This course is very straightforward and practical. This is the course I wish I had when I started to learn PowerShell.  In under 3 hours, we’ll cover a broad range of topics from CMDLETS to Control Flow, String Manipulation, Advanced functions, different operations, conditional logic, loops, parameter splatting, parameter sets, writing event logs, sending an email with powershell, WMI classes, Powershell remoting, Error handling and a bunch of modules like the Active Directory module, Archiving module as well as the AWS module. 

 My goal is to help you become a powershell scripting expert in less than 3 hours.

That’s right, all of the things I’ve just mentioned will be thoroughly taught in less than 3 hours. This course is very handson and to the point.  Throughout the course as we learn, we’ll be creating a bunch of useful scripts that you can use at your work place and even our very own powershell CMDLET


Ready to show off your powershell skills? Let’s get right to it.

Meet Your Teacher

Hello, I'm Dolwin.

I have close to 10 years’ experience in Systems administration and operations and currently work for a Gaming Studio in Sydney, Australia. I’ve been using powershell for automating various tasks at my work and also find it to be one the most full featured and powerful scripting tools when it comes to automation. What makes powershell even better, is it’s ability to run on Linux and Mac as well.

See full profile

Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.


1. Main Introduction: Hello, everyone, and welcome to the advance partial crash course. My name is Donovan Fernandez, and I'll be your instructor for the course. I have close to 10 years experience in systems administrations and operations on currently work for a gaming studio in Sydney, Australia. In this course, I will take you through from the very basics to the most advanced power shall features and command lets. This course is perfect, either. If you're new to power, show a season systems admin looking to automate tasks or even if you need to brush up your partial skills will cover a broad range of topics from command. Let's to control floor string manipulation, advanced functions, set operations, conditional logic, sending emails with power shell W on my classes, power show promoting and a bunch of models like the active directory model of the archiving model as well, etc. I'd appear smarter. You will also be creating our very own power shall command that using advanced functions. My goal is to help you master power show in less than three hours. This course is concise and to the point and very hands on. Throughout the course, as we learn, will be creating a bunch of useful scripts that you can use all your work to automate tasks ready to go from beginning to expert in power shall in less than three hours. Let's get right to it. 2. 1 Introduction and PowerShell ISE: Hello guys and milk into the first lecture on Palm Show. Before I get started, you can see my email here at the bottom. Right corner. Police feel free to email me. Should you have any questions? Should you have any doubts on the topics that I teach you? Email is the best way to reach me. I check my emails every day, so please feel free to email me and I'll get back to you as soon as I can. So let's get started. What is Windows Power Shell and why do we need it? So Windows Powershell is developed and maintained by Microsoft. Its main purpose is for writing scripts for task automation. It's based on the dot net framework, and it's basically a come online show and a scripting language. The first version of Powers Shoulders, released in November 2000 and 64 Windows XP, Windows Server 2000 and three and Windows Vista. The latest version of Power Shell is Windows Power Show 5.1 as office recording and it shipped by default with the latest versions or windows. You may already have power show, but if you want to upgrade to the latest version head over to this link over here, and it will get give you the dominant page where you can download the file, and it's pretty simple just the next next and finish installation. But that's for Windows. However, if you are keen to try out Power Shell on Linux, we can head over to this link, and it will give you instructions on how to download and install power shell for clinics. And that's one of the great things about Power. Shell is that you can win it on Windows Mac and on politics as well. One thing to note, though, if you're running power, show on Olynyk, so make sure you type in the keyword P. W s hey H and then the name of your script for your strip to execute in Windows. You did not have to append any keyword. Just type the name of the script and it will execute. But for clinics you would have to type in P. W S H and then the name off your script for the script to execute. These links have bean pasted at the end of the video in a note. So once you've done with the video. You can just go ahead and copy and paste these links into your browser if you need to download the latest version of our show. Now let's talk about an interesting tool that comes with power Show. It's called the Power Shell I s E. So I C. Stands for integrating scripting environment basically allows you to create scripts, save your scripts, basically type in multiple lines of court and then save it as a file seven as a module or save it as a script gives you boiler plates for things like advanced functions and a lot more. So let's ripping up power, shall I and see and see what it looks like. So if you hit the start button and if you type in power show, you can see power shell I s key. Make sure your right click and run as administrator else. Some commands will not run. So there you go. This is Thea integrated scripting in a wire mint so you can basically type in your long scripts over here. If you're using things like if you're using things like condition ALS or creating your own command lit, basically type in your code. Here and then you can save in your You can just save your script by hitting file and savers , whereas if you want to run just one line command, it's you can simply type in a command over here in the terminal. So let's take a look at execution policies. Let me open up my slide. Great. So execution policies for security purposes Power Shell comes with different execution policies. These execution policies basically controlled the execution off scripts on your computer. Power shell is a really powerful scripting language, and if malicious scripts are run, it could cost serious damage to your infrastructure. That's reason why we have execution policies in place. Let's go through these execution policies. Let's go through some of the options that we have to set our execution policies. So the 1st 1 as the name says it's restricted restricted means no scripts can run on your computer. Only command. Let's can be run. I wouldn't really use this on my test environment, but yes, definitely in production. If I'm working for a critical and why made, like, maybe say, financial services or a bank about probably, said a group policy to ensure that power shortstop stone run on client computers. Remote sign So we have all sign and then we've got promote signed. These are quite similar. It just means that you can run scripts if they are signed so you can sign your scripts. And signing your script means that it has been verified by a trusted publisher. And then these trips are safe to run. Unpredicted and bypass are similar as well. The only difference is that in if he used bypass, you get no prompts at all before running any script unrestricted. It's similar, and for demonstration purposes. For this course, I will be setting my execution policy to unrestricted. Andi. Finally, there's another one called us. Undefined. Undefined. This basically used to remove any existing execution policy that has been set on your computer. Let's open up power, shall I? And see and C let's run a few off these. Ah, commence. So the first command is going to be get dash execution policy. Now, before I complete the entire world, I'm gonna hit on the tab key on my keyboard and you can see partial does a great job by or accompanying it for me so I don't have to type in the entire world. And this also make sure that I don't have any spelling mistakes in my command. Let's so these are basically command. It's that you can run on power show and the first Commander that we're going to run, that we're going to learn is get execution policy, and this will give you the execution policies that is currently applied on your system. So if I hit the green play button over here, it is going to execute. And it's going to say that my execution policy has been set to unrestricted. Now, if I want to set my execution policy to any one of those options that we just discussed, I will type in the command, let set execution policy and the option. So in this case, I will say, for example, typing restricted and I'm gonna hit enter. It's gonna come up with a prompt simply say yes to all. And there you go. So right now, no scripts can run on my computer because I've changed it to restricted. Let's change it back again to unrestricted. So yesterday, all and again, for the purposes of this course, I will be setting my execution policy to unrestricted, and I would recommend that you try out the same feel free to go out and try the other options that we've just discussed. One of the best things about Power show is its naming convention the way they named their Come on, Let's it is so simple and straightforward and easy to understand and give, and it just gives you a fair idea of what the command is going to do. Get is a read only command it. It means it's just gonna fetch the execution policy and tell you what it is. And if you set execution policy, it is going to change. Ah, setting. And it's going to set your execution policy to either restricted or unrestricted. That's one of the best things I like about Power show. Most of their come on. Let's are pretty straightforward to understand, and that will help you remember command. It's easier. OK, guys, and that's all for this lecture. So just to recap, we have learned about the Power shall Iasi that gives you the ability to type in your scripts and save these scripts as either PS one files or PS and one files, which is again for when you create your own modules and we have learned to come on, let's which is get execution policy and set execution policy. Hope this lecture has been informative for you. And once again, please feel free to email me on Donovan f at gmail dot com. Should you have any questions that we have any feedback? Thank you for watching. 3. 2 Variables in Powershell Edited: Hello, guys. And welcome back in this lecture, we're going to talk about variables. So what are variables? Variables in power shall are used for storing data in memory. We assign certain while used to variables. We store these values so that it can be later on. Referenced in our script, variable names and power show begin with a dollar symbol. Let's see how that works and let's see how we can define a variable. So that's open up power. Shall I A c in to declare a variable we type in dollar and then the name off the variables to, say name equals mark. And then I hit the play button. So what it's done is it's basically stored this value to this variable. And if you want to view its value, you can simply type in dollar name hit, enter and it'll say mark. Similarly, we can create something we can quit. Another wearable. Let's say dollar age equals, say, 25 for example, and I hit enter an idea dollar age. Now the value 25 is a reference in this variable. So the difference between these two variables, as you can see, is I've got double quotes around over here, so threat to threat threats several types off. We're able to sort of data types we'll be talking about in teachers and strings for now. So if you want to declare a variable as a string, you simply enclose them in double coats. What is a string? It's just a character or a set of characters or sentences, or just any text that you like distorting the variable that stood in the form of a string to make sure that it's actually a string you've got again ensure that it's enclosed your values and close in double quotes. Now, on the other hand, if you want to store a ah value so you want to store in teacher to a variable, we can simply type in age equals 25 that will store other value. 25 as an in teacher type out of the variable dollar H. Um, let's see what I mean by that. So if I do dollar name dot so I got dismissed it. It's called get type and I closed these pregnancies and I hit Enter. It will say it is type string because I've sort of string over here Let's have a look at what the type is for age. So I do dollar age dot get type and I enter. It tells me it is type in teacher. So the get type my thoughts will basically tell you what now. Another cool thing you can do is you can also reference variable in another variable. Let's see what I mean by that. So see if I say dollar name equals Mark, which is obviously becomes a string and I say enter. And now I'll say dollar say, for example, sentence equals again double quotes. I'll say hi dollar name. Welcome to power show What's gonna happen here if I now call the sentence variable? It's going to say hi, Mark. Welcome to power Shell is er cool ladies. So that's what I meant when I said you can reference variable in another variable Now what if I do not want to process this variable? Mentor stood as high dollar name. Welcome to power Shall what do I do in that case? Pretty simple. In that case, all you do is simply, Instead of double quotes, you simply enclose it in single quotes. And by doing that power shoulder not process that variable. So if he could enter now and then we do again type in dollars sentence again. It will say high dollar name. Welcome to power show. So I hope you get what I'm trying to say here again to set a recap. Um, if you want to store variable another variable, make sure your, um, value is enclosed with two double quotes. A started in the end. And if you did not want this variable to be processed, we can simply enclose it in single quotes. Okay, so we've looked at the get type method. Now let's see how we can enforce a variable to be off a particular type. So let's go back to my slide, and you can see here if you type in, um square brackets int and in the name of the variable, that will ensure that this variable can only accept an in teacher type. If you try to store anything else in this variable, it will give you an error. Similarly, if you want Teoh enforce a variable to be off type string, you can simply used to syntax. So opening open up and close these brackets and type in string in there. A another. Interesting. Ah, that type is thedailybeast. I'm so it'll basically give you, um ah, the current date and time in a user friendly and readable manner. Let's have a look at a few examples, So open up our show. I see again. Now, if I want to, uh, make this say a string, all I'll do is I'll typing string over here, and I'll say, um, string name equals Mark and I enter. So but that what's happened is now name can only contain a a string variable. Let's do it for anti Jew, and I'll show you an example with an error. So say, in teacher age, um, equals 25. I guess that's processed variable. Now, um, for this example, I will teach you. Um, I'm gonna talk about a common that collars read host. So what does Reid host do is it simply takes in an input from the user. And now this input could be anything. Um, and that's reason why we also we have these, um, these data types assigned to variable so that we can ensure that we get the correct up off value what we're expecting from the user. So if I say read host, for example, let's let's tap it down here So I'll say, Let me say that's credibly will call dollar. Let's say, for example, um, and Allah sentence okay. And I say equals read host. Okay? And we'll say, What is your age? Okay. And if I enforce this to be an in teacher type, let's see what happens now again, read, host this. Come on, let allows you to take in an input from the user. So if I enter in, if I press enter, it's going to prompt me. What is your age now? If I type in a string, it's gonna get me with it's gonna come up with this error message over here, and that doesn't look good at all. And it clearly tells you that we cannot come with this Ah, to a to an anti Asia. So that's an example as to where you would want to set where we want to use its called typecasting. So when you basically said they were able to be of a particular data type that's known as typecasting. So in this example, we have seen why we would use typecasting now one important thing to remember is that everything in power shell is an object. Let's go the slide again. Everything in our power show is an object, and every object has certain methods associated with it. Here are a few examples that I've put down on the power slide on the PowerPoint presentation. Let's have a look. Let's have a look at what is actually I mean, so I can declare a very bowl. Say, for example, food equals and let's say it is some string. Let's execute that now. This is basically an object of variable. Everything in power shoulders, an object So even this variable becomes an object. And as I mentioned earlier, every object as a has a bunch off methods associated with it. Now, how do we get those methods? All we do is type in the name of the variable type in the pipeline. Symbol will talk about what the pipeline is in the future with you. For now, we'll just follow along. We pipeline it to another command, let callers get member. Let's see what that does. Wow. It gives us a bunch of methods that we can use, um, on this variable on this object. So let's have a look at an example. So let's say Well, let's say dollar food dot Let's use the contains method and that's a dollar food dot contains there, and he enter. It's going to say false. Why? Because the variable food does not contain the string fair. Correct. It contains some string. Now, let's say dollar food that contains some and, as you could tell, it, is going to return. True, because other variable contains some. Um, let's have a look at another method. So let's say Let's look at the equals method. So let's define a a variable and say age again and say said it to 25. Hit. Enter. Now you dio dollar age Piper to get hyphen member, and you can see the list off methods had associated with it. Now you'll notice that there are a few methods, Um, as compared to the previous one. The reason being is because sent in teacher type. So, um, different optics have different sets off methods on them on because this is an in teacher we have. We have a few minutes that's compared Teoh, a string variable. So, um, let's see. Let's use the equals method and see what it does. So I can say dollar age, Dot equals. And then, let's say 12. What do you think it is going to return? Faults? Why? Because eight is not 12 but age is 25 in this case it is going to return. True. So that's what the equals method does for us. It'll check if, um the value that you supply actually equals to the value off the variable. What money Favorite methods on string is the replacement. Let's have a look at that. So let's see. Let's say, for example, dollar text equals that quick, um, Brown Fox jumps over the lazy dog and I say ente. And let's use the replace Smith head on it. Let's see what that does dot replace and we can type in. Look, replace and we can say sorry. It's actually dollar text, not dollar test. That's reason why the order company didn't kick in. So if you type in dollar text starting place, um, So what do you want to replace? And with what? So I'll say, want to replace all intent is off there with a and I hit Enter there you go. So every instance off there is replaced by a. And now it's read as a quick brown fox jumps over the lazy dog. And as you can see, it doesn't only for the 1st 1st instance that it fines over here. And why does it do it for only the first instance as again gets because it is case sensitive, so it only replaced. So you've got to keep that in mind. Um, it's really important that it will only replace the, um, replace the exact match. It looks for an exact match to replace. All right, guys, thanks for watching this video. I hope this has been informative, and in the next lecture will be talking about a raise and hash tables. 4. 3 Arrays and Hashtables Edited: Hello, guys. And welcome back in this lecture, we're going to talk about a raise and hash tables. So what are they? Raise and area is basically a collection off elements under a single variable name. And these elements can be off different data types to say if I declare an IRA, I can have one element as a strength and one element as an anti Asia and an area again eyes an object. And if we pipe it toothy, get member method that we've seen previously. Um, we'll get a list of methods that can be used on it, um, to create an every reuse. Ah, the following syntax. So you declare a variable and then you say, new dash object system dot collection start aerialist. Now I know that's a mouthful, but this is just the plain syntax that we used Teoh create an area. Let's take a look at a few examples. So let's open up my power show I s e. And now let's create an airy let's say dollar food equals That's a new hyphen object and say system dot collections that very list. And there you go and you hit Enter. Now if you do dollar food dot get type, it will show. You hear that? It's an aerialist. Cool. Now since this is an object, as I mentioned earlier, we can just $2 fruit and again we can pipe it to get member method. Let's see what we get and then you go, Ah, we can't actually get anything right now for this because it's it's empty. But say if I add some items to the area, let's say if I do dot Fu, um don't add. And if I type in hello and enter now it adds, Hello, toothy array. So what's this? Syria. So now let's get back to my power. My power point slight over here? No, in an array. Ah, we have to keep in mind that it always an index often area always starts with here. So if you add elements to an array So, for example, dollar cream eagles high ice 34 So there are four elements in an area over here. So the index was off. These would be a 01234 which means high is at the syrup position off the area. Ice is one. Three is too four years three on someone, so it's basically the index. What we're talking about over here so again high will be at the Zurich position. Ice will be at the first position and so on. Let's take a look at some of the few methods that we can work on with an array. So open up my power show. I see council again, and since it added dollar food at you can see that it has by default automatically added to the sewage pollution off the array. And if you add any other item, say, dollar food, let's say I add one. There you go. It'll added to the first position of the area to index. It's known as Index off one. We also have the index off method, sir, Before we go there, let's add a few more elements to the area. So you get an understanding off what in actually is. Let's say let's not say three. Let's say purple. Okay. It has added the value purple to the index off to and say we add another value. Savy do dollar food on add brown enter It'll editor index off. Three. Quit. And now if you do dollar food, you'll see that it has four elements once Heller and then the teacher, one. Purple and brown. Now let's see. So this is how you basically add elements to an array to remove an element from an area you can simply do dollar food that removes, so you have to command. You have removed any half. Remove at, so if you're doing a removed, you'll have to actually specify the value off. What do you want to remove? But if you use remove at, you can basically just specify the index. So, um, let's say we'll use to remove command fist and also remove. Hello. Sorry I got, I forgot Teoh. Enclose that in double quotes. And there you go. Now, if you look at Dollar Fu, it's gone. Hello has gone from the array, so the index off method will basically tell you what the index off a particular value is. So if I do say dollar food dot index off and I type in peple, it will say it's at index off one because it's the second element in the area. So again, it's be counted at 01 and two, and if we do index off brown, we will get index off to. So that's what the index off function does. Let's again remove an element from an area so we can use dollar food. Don't remove. Um, let's say, um Brown. And they got. So now we've left only two elements in the array. So this is basically how you can add and remove elements from an array in future. Videos will have a look at it's actual practical use cases and how areas actually helpers. Okay, now let's take a look at has tables, so hash tables are similar to raise, except that you, as the programmer allowed to define not only its value but the key as well. So if you remember, we spoke about an area using the index as two key in a hash table, you define the key as well. Let's take a look at the syntax and a few examples. So over here, as you can see to create an array, all I do is I define a variable, and then I used the at symbol open and close colleague braces. The first item here is the key equals and in the value said name becomes Nicole. And just to compare this with an area, um in an area felt have added an element saying cold the key. The key would be its index. That would be zero, and then the value would be in the coal. But in hash tables again, you ask the program on a lot of defined the key, as were Leicester value. To define a hash table with multiple key value pairs, you have to separate them with a semi colon. And this is how you can add multiple a key value pairs in an array in a hash table. Let's take a look at a few practical examples and a few minutes that we can run on. These has stables, so open up my I S E. And I'll start with saying all the final variable called table. And then again, the at symbol opening and closing Cody braces. The first item here will be the key. So let's say the key is name and name equals. Let's say in the coal now, once I process this variable, and if I do dot, get type and hit, enter, There you go. It says it's a hash table. So let's look at how we can add and remove data from a house stable up. First of all, let's add more items. Teoh. This has stable to say semi Colon and I'll say, um, education equals, say, uh, bachelors of science. Semi colon and I can say age equals. Uh, let's say the coal is 21 years old and that's processes. Now. If I type in dollar table, you can see I get a neatly arranged table of key and value passer educations. B A C names Nicole and age is 21. Okay, let's have a look at a few methods that we can run on this hash table so we can dio something like, Let's just have a look at a few minutes first. So let's do dollar table and then we'll Piper to get, remember? Okay, and we see that we have um, ad. Contains contains key country inns. Value equals remove, so these are a few minutes that we can use on a stable. So let's start with ah contains method so we can say, as you can guess what it already does we can do table dot Contains on Let's say, Does it contain Nicole? It's going to say false and Why is that? So let's take a look at some of the other few methods that we can run on a stable. So if you do dollar table dot sorry, pipe it to get hyphen member. Let's see what we get that you know. We get a few methods that we can run on the hash table, which is add to add more key value pairs. Remove to remove key value pays. Contains contains key contents value except tre Ah, Let's have a look at how we can add and remove key and value pays to and from a hash table . So, um, it's typing. Ah, this type of the name off our hash table, which is table in this case, and then we'll do ad. And let's add the key. Let's call the key. Um SE In this case, let's call the key sex and the value will be female. Not one thing to remember is when you're adding, uh, key value past you and airy, you have to you separate the key and the value with a comma, as opposed to the equal sign when you're actually defining the house stable. So make sure you keep that in mind. Let's press enter and they go to 90. Did dollar table. You'll see that A another key and value Per has been at it over here now to remove, um ah kee In a while, you pair all you gotta do is, as you might have already guessed ID don't remove and then specify. All you got to do here is specify the key and the value will be automatically deleted. So if you do remove sex and then you go to dollar table, have a Yugo um, the key and value pair have bean removed. Okay, Now let's take a look at the contains key and contains value method so as you can, as you might have already guessed dot contains cable check. If there's a particular key in the hash table, let's say I'm looking for education. Doesn't have a key call education. Yes, it does. Does it have a key cold? So, for example, holiday. No, it doesn't. That's gonna return your faults. So that's how you can find whether a key actually exist in a hash table are not. And similarly, if you want to find, um, if value exists in the hash table, you can do contains the value you say holiday. Um, sorry, syntax. Over there, you say holiday. It will say faults. But if you say, does it contain B A C? What's it gonna say? True because there's a value called BSC in ah ha stable. So things are the basic methods that you can use on the hash table, and mainly when you are writing scripts when you're creating areas, you're either adding or removing elements from an area or a hash table. So these two methods are really important to alone and understand. Okay, guys, thanks for watching the video. And again, if you have any questions or if you have any feedback, please to email me at baldwin f at gmail dot com on I will get back to you as soon as I can . Enough off the basic stuff right now. In the next lecture, we're gonna talk about some awesome, cool and useful partial commandments. Thanks for watching guys 5. 4 CMDLETS: Hello, everyone. And welcome back in this lecture, we're going to talk about some useful power shell command. It's that we can use for our day to day system administration tasks. Let's get straight into it and see some examples. So the first and most useful command that we're gonna look at is to get help command. It basically gives you information about a particular come on. Let and can even see a few examples. Let's directly go ahead and take a look at what I mean. So I will open up my power show. I s a consul. I see. Run as administrator. Okay, so the 1st 1 we're going to look at is to get help command, not say for example, if I want you know what get child item does so I can do get help, and then I can say, get child item, okay. And if I execute this command, it's gonna give me a description off what the commanders and a few examples to view an actual example. What he could do is you could type in Let's do get help again, then get child item and say example, the feet enter that you go It'll give you examples as well. Let's try it with another commander. Let's say get help, get Alias. So imagine I don't know what get aliases. All I can do is to get help, get Alias. And when I hit enter. It gives me a description. What they get Alias Command, that is. And if I want to see a few more examples, I can just add the flag examples and hit enter and it gives me examples and great. Now let's take a look at another command it So get child item. What does get child Adam do? Let's try and run this command it and see what it does. So get child item And if I hit Enter There you go. It's gonna give me a nonstop the list off all the contents off the folder. So my present working and directory, as you can see is C Windows System 32 the get child item a command. Let will list all the contents off that particular working and directory. That is all the files, all the folders, ex cetera. Let's take a look at get location. Now get location. We're basically just print the part that you currently on. So if you hit enter, you can see that it'll give you an output saying or part of system 32. If I were to go up a few directories, say silly dot dot c, I go onto the C drive and then I go to see the uses. Ah, Golden. And if I do get location you want in this directory now let's take a look at the get Alias commands one of my favorite commands. Get Alias. So what, this is do it's gonna print out a list off aliases. So what is an alias? It's basically a It's basically another name to call a different command lit or to call a different function. So, as you can see is that we can use set location will basically change your directory to another part. And one of the reasons why it's alias to CD is because that's what the command prompt commanders to move to another directory. So it's easier for us to understand. I'm especially people coming from ah, UNIX background can see that it's change Directory is also Alia still be here to the same set location. Similar things such as touch to create a file and then you've got man over here for help. Then you've got MD for make directory. So you get the point. So So for example, if I want to change if I find it hard to remember, get location, I can just change it to I can just give it a different name and I can just assign it to come out of it. So print PWD stands for print, working directory. And again, this is for users who come from a latex environment trying to understand power show. Similarly, you can basically take any camel attorney Ken set an alias for it. Okay, so let's take a look at how we can set an alias for a command. So? So, for example, if I want to change the name off, get a location just for my convenience, I can say set hyphen alias at the name that I want to give it. Say I can call this C and the value will be the actual name off the commanded. So in this case, I want to change the name off, get location, get location. And now, if I hit, enter. So now if I do get location. It will print the part environment, and I can also use see. And there you go. It's the same thing. So that's really helpful and useful for huge or really long named partial command. It's especially with after Azure coming out of you, Some off the Azure. Come on, listen, they're very big end. Hard to remember. So it's easier to set areas is when you're working with use partial. Come on, let's now let's take a look at what get local group does So get local group will basically print all the local groups off your computer and you can. As you can see, there are a bunch of local groups as sequel 70,005 administrators. And these are just all different groups on my computer. So this is helpful to fetch our the list off local groups on a particular computer. Now the Southern look at get local group members, sir. I'll get local group, remember, and I can say the name off the group to be Adminis trainers, and if I hit enter, it will give me both the users that are there on that belonged to the administrator groups that there's an administrator account and the design icon with the name of Baldwin as well . Let's check it for yes so we can do get local group member and safe for the group, I guess. And there's only one user are belonging to the group. Guess which is a guest local now you old seen. We've used to write host command in previous examples, but let's see what's different about this. So right Host will basically print text on the screen so I can see right host Hello either . So a little do is basically just print text on the screen. Now. The reason why I'm repeating this coming again, it's because I wanted to show you that we can also use to other flags with the right host. Can use two men flights like foreground color and background color that will give a different color to your outputs. I can say it right host. Hi and welcome to this to Victorio. And then I can say for grown color and I'll say, say so You just hit Tab and you get a list of options away. Also say also, the foreground color should be dark blue and will say the background color can be, ah, yellow in the u Go Now, if I hit enter, you can see that the background colors yellow and the foreground color deformed is dark blue, so that's a very useful thing to remember. And you can have a list off colors and examples again by just going to get help and write host, and you'll see a bunch of other colors that you can use for this command. So let's look at the next command, which is right output. Now what does right up to do Salty right? Output on and I'll say hi. Enter all the dozens exactly the same as right hosts, right, little print text to the screen. But what's the difference between right hosts and right part boot? So the only difference with Bean right text and right between right host and right out is that you can pipe right output to other command. Let's whereas he cannot pipe right host other. Come on, let's let's see what I mean. So if I can do something like right, Hurst's on. If I pipe it to get member, for example, that you go, I get an error. But if I do write output there you go. It's basically asking me for a parameter at this time because right output currently doesn't have anything stored in it. But you get the point that we can basically use right opportune pipeline to different to other. Come on, let's let's talk about the read host command. So we've discussed this before. The read host Command takes in an input from the user so you can type in something like read host. Hi, there are what city do you live in? And then if I hit and I was gonna ask me Hi there. What city do you live in? I'll say Sydney, and that's a little output. Sydney Ah similarly can also start a stroke variable. I can say city And then put this. Put the get the input from the user instruction a variable supplied Enter Then if I say it's Sydney and now if I type in ah Dollar City, if we'll offered Sydney so that's read host for you again. Let's go on to the next slide and see a few more command. Let's so right. Debug right rebels, right warning and right era. Now you can use these for commands in your scripts will have a look at a few of these when we create entrance functions in the future in one of the future videos. But all it does, it's it's basically the same thing as doing right host and then a foreground Kalanick background closer. These are basically just pre defined, and this is the actual syntax that you can use. I didn't create you to go ahead and try it out on your screen and see what you get. So if you say, for example, right morning, it's going to prompt you. It's gonna come up with this yellow text and say, Are you sure you want to proceed? If you use right era, it's going to give you a huge era, a blood message. So it's similar to write host in the sense that you can. It gives you pre defined colors, but it also comes with preloaded error messages as well. So give it a go. Try it out in your power shall come on. Let And if you have any doubts, just email me and I'll get back to you. Let's look at a few other partial commanded, so let's have a look at the set location command. So all the set location commanders is It takes you from one directory to another that you specify. It's similar to the seedy command that you use in command front. So let's take an example. It should be fairly simple, so you can do something like set location and then say, I want to go back One directory. I'll do dot dot and then we'll take me back to the D Drive. It's similar to CD, so if I say get shall item, for example, it will list all the folders in the D Drive so I can use ah, this CD command. Or I can use a set location command to navigate and go to a different folder. For example, let's say cash, and then it will take me to the case for less. So that's all set Location does. So let's take a look at the new item command. The new item command simply creates a file for you so you can do something like New Item, and we can say I'll just name the File se text one. Doc txt was the text foul and that you'll get an output saying that the file has been created. Then you can do something like text to let's create a bunch of files cause we're gonna use the other command list. Um, and he played these files later, so text three new item text for So now if I hop onto my Andy Dr, I should be able to see if I do an LS. I can see all these text files have been created away. Our A less is again for H on Alias Forget child item. So instead of typing the whole thing, I simply type in a less. So Now let's have a look at move item So move item and simply mover filed from one location to another so I can do something like Move, item and then I can say move, for example, text wonder txt to the current directory and then let's say, move it to audio and hit. Enter. So now if I hate ls again against the text, one has disappeared because it's more for the all your folder. And if I see the into the audio directory and I do an LS, it's been moved over there. That's what the move item commanded does and the alias for Move item is M V, so you can use envy instead of move item. Similarly copy item will copy the file it one cut and pasted a little copy and paste it to a different location that you ah specifying he can try it out for yourself if you want, But it's so it's really simple. One of my favorite. Come on, Let's again. Here is the get content command. So they get content command. We'll fetch Donna from a particular file. Say, for example, for a text file handled and store it in itself. Usually, we used to get content command with a variable. We assign it to a variable so I can say dollar data equals and get content and get content off. What? So let's specify apart so I can say see uses, indulge in okay. And let's see what I've got over here. Um, so I haven't got any text file yet, but what I can do is I'll just create a text file real quick. Okay, so I've created a text file in this from location. And now let's add in some content. Let's say several one server to server three. Hi. Hello. Welcome. And if I hit, save no closest foul and now I do. I call it I call the file over here on, Let's say, Power show and it enter knife. You processed the variable it's gonna give you all that content is gonna give you all the contents off the text file. So that's what I get. Content does, and it's very helpful will be creating a few scripts that do a specific task on a bunch of service, for example, so it's very useful when you have to run a particular command on a bunch of service. You can use the get content command, and then you can loop what we're this variable. So of your cat loops in the future video as well. Let's look at add content and said content so at content will append data to an existing file and said content will not a pen dollar. It will all right, the file with new content. So that's the only difference to see if I have a foul power shoulder. Txt with all this data in there, and if I use add content, it's going to add another line. Oh, it's gonna add another string or here, but If I use set content able over at the file, please feel free to go ahead and try these commands. The add content that said content, they're pretty straightforward. And if you need any help with any of these commands, you can email me. Or you could also use to come on that I thought you earlier let us get help and then add content, for example. And it'll give you a description and an example of how to use the command. And if you want an actual example, you can go ahead and type in the examples flag and you can see over here will tell you how do you actually use the entire command? Okay, guys. So that's all for this lecture. We've learned a lot of command. Let's. And I would highly recommend that you try these out yourself and again. If you have any issues or any doubts, please feel free to email me and I'll get back to you with an explanation. Or if you have any issues, send me a screenshot, sent me a code, and I will get back to you with an answer. Okay, guys, Thanks for watching. And I will see you in the next lecture. 6. 5 Operators: Hello, everyone and welcome for Section two. In this video, we'll talk about operators. So what's an operator? It's just a character that performs a particular action, have compelled a bunch of useful and frequently used operators and will quickly go through what each one does. Let's start with the arithmetic operator. So these are the following arithmetic operators and what are they? They're simple mathematical operations. That's up a look at a few examples, so I can do one plus five. It will give me six, cause I'm eating the plus operator. The addition operator similar. I can do five minus 10. It will give me minus five. I can also do one into five. It will give me five one Divide by 10. It'll give me is your 100.1, and similarly I can do one model this, too. So these are the five men operators that will usually have to using our scripts. Now let's have a look at the assignment operators, the most basic assignment operator, which have previously looked at it's the equals operator. But assigning a value to a variable using the equals operator, let's say of our equals 100 now the value off the variable var equals 100. We can use the plus equals operator to increment the value off war so I can do dollar what plus equals 150. And now for a look at the value of what it's to 50. Similarly, I can do far minus equals 1 50 and I get back the value of 100 again in the same way you can also use multiplication equals division. It cools and modernise equals. Let's have a look at comparison, operators compares, and operators simply compare value against another. For example, to dash equals to return. Truth we can use to not equals four. It will say truth because two is not equal to four. But if I say to what equals two, it'll give me false. Similarly, I can use the greater plan the greater than or equal sue the lesser than will a sedan equals. You're compressing operators. Let's quickly have a look at some of these so I can say 10 critter than equal to 10. It'll say True if I chances to 12 it gives me faults. Similarly, I can say five less than equal to 10 and it'll give me true. Let's have a look at some string compassion operators, so these are pretty simple and straightforward as well. It basically compares strings with one another. As you can see, if we're from these examples that have compelled my string like Asterix strength, let's see what it returns. So I'll say my string like string. What do you think it's going to return? It says, True, because string is contained in the string over here. Similarly, we can use the other example that I've already written my string not like other, and he guesses what this is going to return is gonna return. True. How easy is that? Similarly, I'd encourage you to go ahead and try these other operators Over here. I've put in descriptions to these operators over here. Study can come back and refer to them, but know what you need to. Let's talk about the collection comparison operators. It's pretty simple and straightforward as well. I have two strings separated by a comma, and I want to check if in d e. F is in the string so I can use the contains collection. Compares an operator A little return. True because Steph is in one of these two strings. Similarly, we have not contains in and not in let's focus on an important operator and honesty redirection. Operator reduction operators come in handy when you want to up with something toe a file. For example, if I use get hyphen process, that should give me a list of all processes started running on my system. However, if I want all of these processes to be placed in a text file, I can simply go ahead and do get process. I can't redirect it toe a file, and it can give the file any name. I can call this file processes dot txt And if I hit enter, you won't see any output. Why? Because all of this output has been stored in a file. Let me quickly open up the file for you. So I have opened up this foul. And as you can see, the entire output has bean redirected to this file. How cool is that? Great. Now let's have a look at the or Prater that we can use to append to a file. Now this file processes start. TXT already contains some data. What if I want to add or depend more data into this file. Let's see an example so I can use the Echo Command, which will simply display some text on the screen. So I couldn't say echo. Enter the Matrix and I can depend that too. Processes start txt. And if I enter, Enter the Matrix should have been upended due process to start. Txt. Let me quickly open up the file and show you what it's done. So I've opened up the file and if you scroll to the bottom, you should be able to see Enter The Matrix has been upended. So that's the difference between a single greater than sign and using both of them together . A single grid and sign will create a new foul will write the existing foul, whereas if you want to upend text to an existing filed with data, use a double great advance sign. Do you remember the sperm messages that pop up if you type in the wrong command or if a command is not receive unexpected input, you get this huge red error messages. What if I want to suppress those error messages? So, for example, I used to get content method and I say I want to get content from a file that doesn't exist . Say, for example, filed is not exist dot txt. What's going to happen? It's going to say, cannot find path. But if I want to suppress this error in my script against simply add to the greater than symbol and say era doc, txt just great in your file. And if I enter, the era has been suppressed. This is useful when you create lot scripts, which could be bound to errors due to wrong input by the user. Let's have a look at what it has saved in theory dot Txt Surf Open up the file. The entire message is in the aromatics like txt file. Great. Now what if I want to store all errors from my script into a single file and not have a separate file for each era I can simply use to and then to greater than symbols? Let's it enter Now Open up, the aeronautics defile again. And as you can see, the other error message has appeared over here as well. Let's have a look at how we can concoct innate and multiply strings. I look enough, my power shall console and in this case. As you know, since I've enclosed the value in double quotes, it now becomes a string. So if I say for blessed to and end up, it will give me 42. Similarly, if I do one to three plus welcome, it will give me 123 and welcome If I do three, which is a string multiplied by three. I get 33 times pretty straightforward and easy, isn't it? Let's have a look at logical operators. Let's Rick, you have a look at some examples, so I'll say variable. One equals. So I'll say variable one equals into the Matrix. I love it. Enter and I'll say variable, too. It's either the red are the blue pill. Okay, so with these two variables, let's see an example of the and logical operator I can use. Dollar, what one and dollar? Well, I can use something like contains in tow the Matrix. And if I had in tow, I'm going to get false. The reason why I get faults, it's because it's checking. If enter The Matrix is in one end of all. However, if I use valve in or var contains, enter the Matrix, I should get true, because if either of the condition is met, it will return true. Well, hold on to the last two operators for now, because thes operators are generally used in condition statements we'll go with with these two operators in the conditional statement lecture, which is just about two or three electors away from now. Okay, guys, thanks for watching. And we'll have a look at set operations in the next lecture. 7. 6 Set Operations: Hello, guys. And welcome back in this lecture will have a look at Power Shell set operations. Let's jump straight into it. So say, for example, if I have a list off processes, but I want to filter out just the name I'm looking for or say I want to display contents off a directory and want to list only a particular file or directory. In that case, I'll use. In that case, I'll used to select on the very operator. This is similar to using the group command in linen. Let's see how that's done. First, let's have a look at the output off. Get process as it can notice. It gives you a bunch of data with different feel names. Save you want to filter out some processes and perform some action on them like struck process. We can do that using the following syntax. Now we'll first talk about the pipeline, Then the dollar underscore symbol and then the set operator stuff we used. The pipeline is one of the great features and power show that allows us to run a command over a result off another command all in one line so you don't have to run them separately and then store the result off one command and place it in an output and then run another command on it. It's really handy. And look how clean and understandable this one line off syntax look like. As you can see in the example, we're using the select amount on the results off Get Process command. And then we're using the Vek Ament on the results off the select command. So that's what the pipeline does. Now let's take a look at the red symbol. The dollar underscore symbol. The dollar underscore symbol represents the current object on the pipeline, a very commonly asked interview question. Let's see an example. You not get process output. Each of these outputs as a single hole is represented by dollar underscore, and then we can access a certain property from it, which is in this case, the process named property makes sense. Great. So this example we've used to select on the very operator to filter out the results. Let's actually see the results sold. Scroll to the bottom, and I'm saying I need all processes and select the property with the field process name where each object thought the process. Name is like this expression. Let's a play And there you go. I can only those processes with the process name property that I had requested. How cool is that? So let's have a look at the sort operation. So in this case, I'm going to use sketch. I'll item to list all the contents of the current directory, and I'm going to select only the name, and then I'm going to solve it in a sending water. Let's see what it does. There you go. So what? It has done it as displayed the list off all the items in my current directory. It has selected only the name property, and it has sorted it out in ascending order. One last. An important thing I'd like to show you is how you can add your own property while filtering stuff. Say, if you want to create your own label that's not given by power show by default. In this case, you can create your own label. Let's see the syntax to do that. I've already got the command here, so I'm using get child item. I'm selecting the property name and this is my custom property that I've just created Take a close look at the syntax. It's the at symbol. Open curly braces of the name off. The label that is next to name will get another label named Date listed semi colon, and then the expression, which would be, in this case, get date. This expression can be any common lit or even an entire script within these set of curly braces. Let's see what it does and the ego. So it has created a name with label date listed, and then the expression would be get date. And this is how you can create your own labels. Great practicing and creating your own labels by changing the expression with different command. Let's and do not worry if this seems really daunting for now, we're now starting to look at some really advance power shell stuff, and it's just a matter of time and practice, and it will all eventually become second nature. And remember, you can always email me if you need any further clarification on a topic. OK, guys, thanks for watching on Let's will want to the next lecture when we talk about control floor and loops 8. 7 Conditional Control Flow: Hello, everyone. And welcome back in this lecture, we're going to talk about conditional logic. Conditional logic is simply deciding yes or no if or else if a condition is meant, do this else do that the two men conditional statements will be looking at is the if else statement and the sweet statement. Yes, the syntax if it let's really take a look at an example in our partial Iasi control. So I put up my publisher. I see console. Let's have a look at the script. It is a very simple script that performs in action based on a condition. In this example, they declared a variable food, but they string off test. So here's my if else block, I'm saying, If dollar food, I'm using the equals operator test. So if food is test, then write host. The condition has been met else. The condition has not been met. Let's play the script as, and as you can see, it says the condition has been met. Whereas if I changes to test one and play it, it's going to say the condition has not being met. This is the most basic form off the else statement now Let's take a look at a practical example. Descriptive. So I've got here is the one that I usually used to create folders and place some stuff in there and of the Fuller doesn't exist. Then I simply create one. Let me explain what's happening in the script. Remember the not operator I mentioned in a previous lecture that we would discuss later? Yeah, it is now. So I can say if that I'm going to use to, not operator. This is used to negate and if condition. So if test part does not exist here, we're looking at a new command lit. It's called Test part. All it does is it's going to check if this part exists on your system. So if this part does not exist on your system, then write Host Part does not exist, creating new folder and then immediately my next commanders to create a new folder. If depart already exists, it's going to say folder already exist. Let's go to my home directory and we'll try to create this folder. So I've navigated to my desktop, and I'm going to try and execute the script and the ego. So it says that the new folder has been created, it says, creating new folder because the part does not exist. Okay, and the new folder has been created. However, if I try to run this script again, what's going to happen? Because the path will now exist? It will not create a fuller, and it should give me for that already exists. And there you can see it says Folder already exists. So from this example of you have seen of the FL statement works and how we can negate a condition using the not operator. Now let's take a look at another example Now what if you have multiple conditions that need to be met in this case, you'll use if else it else's and then finally else you can have as many as else if commands as you want in your script. But the final block should always be an else, so let's see what's happening in this script. So I'm defending a variable, possible it, and it has a string into the Matrix. So not my if condition is if password contained were using the contains operator. So if the password contains just a letter, just a word enter, it's going to print not quite day it else If because this is my second condition, the password equals matrix. Then right hosts getting close, but I need another condition else. If password equals, enter the Matrix that it's going to say you've guessed it right and my final condition. If it's neither at this condition, only the disc condition or this condition, the final condition is going to be. You're not even close. Let's have a look at how this works. So I'm gonna execute the script and it says you've guessed it right. Why? Because right now the password is set to enter the Matrix. If I take off the Matrix and just leave, enter and hit the play button, it says you're not quite there. Similarly, if I just say matrix and hit play, it's going to say getting close. If I have a nothing where if I have something else like country, for example, a very bad example story. If I pressed the play button that says you're not even close the final condition. So in this way you can use multiple conditions with your if else statement. Now let's move one to the sweet statement. The sweet statement is similar to the if else statement. The only difference is its syntax. Let's have a look. So I have the script over here. Now the syntax is as follows as you can see Here it says switch the value first condition and in the first action, second condition. And in the second action, this means that if I supply our value to the switch condition and if this value matches any of these conditions, execute the task. So pay careful attention of the syntax Over here I have my condition specified in double quotes and then just a space open and close curly brackets. And then the action I want to perform. You can type in any command in here, or you can't even execute a script locked in here. Not, for example, if I say I need a list of folders cause that's what my variable is. It's gonna look at the first condition saying not met, and then it's gonna say, OK, the second tension has met. So what do I do? I need a list of folders. So the command to execute a sketch, I'll item and I hit play and it's gonna give me a list of all my folders. No se I change, sister something else. I need the date and time and I hit play. It's going to give me today state and time. Similarly, if I type in, I need to pin your machine and then the ping command, which will just send an echo requests, and I could reply to a host and then the name of the host. So if I select this last option, if I entered this last option over here, it's gonna pink my local computer. You would use a switch statement in some scripts where you need user input. So you do something like read host toe. Ask the user which operation they want to perform. Store that operation in a variable and based on that uses switch statement and perform in action. Great. One last thing I'd like to show you about the switch statement is that if none of these conditions are met, you can use the default block code so we can say default and say something like right, host invalid option. Just say, for example, So if any of these conditions are in meant for example, if I leave this blank or fight happened. Something else. Let's say look up. Something mean Google and I hit play. It's going to say invalid option. So that's where you can use the default block within the switch statement. Okay, everyone. Thanks for watching things. They're not getting interesting. And we'll talk about loops in the next lecture. 9. 8 Loops: Hello, everyone, and welcome back. Let's have a look at loops. So what is a loop? A loop is a sequence off instructions that is continually repeated until a certain condition is met. This means that you have the ability to make your script repeatedly execute a block of code and is one of the most basic and useful task in programming in power show. Mainly before each method is the one that strongly used for looping over objects. Let's take a look at an example, so we'll create an area with a few elements and then we'll try and loop over it. So in this case, let's say Fu Boo equals Mark, Dexter, Alice and Rick. So this variable has 123 and four elements. Now I can use the four eat statement and loop over this variable. Now, pay careful attention to the syntax. So what I'm trying to do here is I'm saying for each item in Fu Boo, this variable over here can be anything you could name it. Item you could name it. Name you get him in, whatever you like. This variable here is going to hold every object individually in this variable that's reason why I say for each item in food boo again this variable, they can be anything. It's just the partial syntax. So for each item, we're going to say, Right host and then we're going to print each of those items. What's the output going to be hit? Play? You can say it says Hello, Mark. Welcome to Australia. Hello, Dexter. Hello, Alice and Hillerich. Why? Because it has looped over all of these four elements with Indus Variable and then performed a particular action on each one of them. So that's what's so that's known as looping. Let's take a look at another practical example. So I've got my code. So I've got my coat over here and let's see what's happening over here. So I'm creating a variable that uses get content. We've looked at get content in a previous lecture again. What? Get content as it simply gets contents of a particular text file a little story in a variable. Now I'm going to loop over this text file, so I'm going to say, for each comb in path again, this can be anything. You can name this item again. Nameless, complicated. Anything in this case I have a list of computer names in this text fell, so I'm just using the variable comp. But again, it can be anything else. So I'm saying for each comp in pop, so it means for each item in pot right host comp that is right, host what the value is. Let's execute the script and see what we get. And there you go. You can see that my file serviced R txt content a list off all these servers that are entered in manually, so that's another example of how we can loop over a variable. Similarly, you can also loop over a hash table and get its keys and values. Let's see how that's done. So in this case, I'm simply creating an empty house stable. And then I'm adding in data into the house stable with key value pays. And finally, I am going to loop over. This has stable, so I'm going to use for each king in dot i dot case. Now, why am I saying that I don't kiss it from a room If you remember to access the key off a house table, you used the variable name dot The keys for each key in Donald or keys. Right host key is dollar key, and the value is dollar value. How did I get the value? The value is simply the data dot key. If you remember to view the value of how stable you can just use the name of the variable dot key. Let's execute this and see what we get. There you go. So what are standards? It has looked over every key value pair in the daughter variable in the data hash table. Therefore, you get KIIS occupation and values programmer and so on. An important thing to note is that venue. Actually, Looper were hash table. You're looping over each key in the K value pair, which means an example. I'm looping over the keys, name, age, sex and occupation, and the value automatically comes along. Why? Because that's how you access data in a hash table. On leading to do specify the name of the hash table dot key and then the values automatically displayed. We discussed this in the hospitals lecture previously. Now let's take a look at the Via Loop A while. Loop again simply loops over an object on delay. Condition is met. Let's see an example. So I have a variable called test and I've set the value off this variable to be and in teacher zero. So this is how I write the syntax. While test, it's less than 20 Test plus equals one. That means while the value off this test is less than 20 which in this case it is increment the number increments variable by one and then read it out. Let's see what we get. And there you go is gonna print out numbers one through to 20. Pretty simple, isn't it? Let me explain again. So we have the variable test, which is zero. So when it comes down, it look at the condition. First is zero less than 20 yes, increments by one and then print the value. So it'll print one. It goes back again. It checks. The condition, not test, is one. Then it will go back again and look at the condition and say these tests that sent 20 Yes, it is because the value of test is no. One that's going to then go down and in cremated by another one and then it's gonna become too. And then it's going to print too. And then you can see two was printed and so on until it reaches 20. By the way, just for fun sake, I'm going to show you some really cool trick. This has nothing to do with the topic that I'm teaching you right now. But it just popped up in my head. South Matters World shared with you. So say, in case I want to print numbers from one to whatever range in power show. All I have to do is type in the number, say, for example, 10 dot dot 20 and hit. Enter. And there you go again. A range from 10 11 12 all up to 20. I can say 100. And they got a print. All numbers from 1 200 Sorry for the distraction. It just popped up in my head. So I thought I might as well share a trick with you. Now let's take a look at another example, and as again see here, this court will print the number up to 20. But it was Skip seven. This is how the country a statement is used with while. So I have I equals zero and then while I is less than 20 I plus plus, which is similar to I plus equals one. It's gonna increments by one and then if the value equals seven. So if I iss seven, then continue the simply means it's going to skip seven. Let's play this, And if you can see over here that has skipped seven. Well, let's see how we can use break with while. So in this case, the code will print numbers one through to six and then break the operation once the condition is met. Which isn't this case break. If the condition is equal to seven, let's play this out and the ego. So break simply breaks the loop. Another statement that we can use with while it's a double loop. Let's see a simple example. I say I equals zero. Do I used to do keep it? Do this block of code, do this block off code while I is not equal to 10 so basically rattling power shell to do and execute our block of code over here until this condition is met. So if I execute the script that's going to say on but want to up to 10 Similarly we can also use do until under pretty much the same. This is the syntax. So I can say I equals zero. Do this on to this condition is met. Great. So they're real examples of for each wild. Do well and do until fantastic Pat yourself on the back because this is some really good stuff that you've learned and you'll be using loops a lot in your scripts. That's it for this lecture. Please practice the syntax or run over again and try changing the variables. And if you have any questions, just shoot me an email. Thanks for watching. 10. 9 Functions and Advanced parameters: Hello, everyone. And welcome to Section three, where all the exciting fun begins. Not that we have done with the 1st 2 sections. Let's talk about advance powerful features like Advanced functions, parameters, Parameters splitting our right Scripture. Send an email with Power Shell and getting your scripts to write even logs. Tubindo Siemen's. There's a lot of important stuff to cover. Let's get right to it. Let's start with functions. So what is the function? The function. It's just a block of code that contains specific instructions. When you call the function name, the script block within that function will execute. It's simply wrapping up multiple partial statements on the one name that can be called when required. By doing so, you can save a lot of time when tackling repetitive tasks. Partial functions have three parts. The key would function of the name and finally, the script block. As you can see here, you can also pass parameters to a function using the Parham Keyword parameters are basically dynamic data that's passed to your function. Let's have a look at an example. So in this example here, I've created a function and named it superhero. So I've used to function. Keep it the name of the function open and close colleague braces. And within that I've wrapped my coat. So what's happening in here? I've set the variable character to default to Batman. So again, I'm going to use the sweet statement and then perform certain tasks until the condition is met, which in this case, it's going to be right. Host Gotham is now a safer place. No, the interesting part here is this. Poor and block the prom block with this syntax is simply passing down data to your function . A simple is that Let's execute the strip and see what it does. And, as we knew it was going to say, caught them is now a safer place. If I chance this value too, Spider Man, that's going to say time to have my way through New York. And again, if I changed two Goku, it's gonna say, Come behind me here. I'm a super saying Great. Remember one thing at the end. Once you finish wrapping up your function, you have to always called your function by just specifying the name off the function and the dynamic data that you want to pass through it. This is very importance for a function to be executed and called upon. So again ID specify the name off the function. And then I want to pass data into my function to the Peron block. I pass it this parable Sweet. No, let's take a look at a function with advanced parameters. So for this example, I'm defending a function named Hello opening and closing curly braces. And then as the previous example, I'm going to type in Haram and then open and close these brackets over here. So what are advanced parameters? It's simply defining and enforcing certain restrictions on your parameter. In this case, I'm saying parameter mandatory, which means this variable has to be passed in. This data has to be passing into the function, and its position has to be zero. That means this has to always remain the first argument. And as we discussed before, String simply enforces this to be off type strength. And I'm doing the same thing with Second case. All I'm changing here. It's a position one, which means it's gonna be the second parameter, and again, it isn't mandatory to to find this parameter. If you don't define it. A function is going to air out and give us a big air a block. And then once I get these parameters, I'm gonna type in Hello. Name? You are eight years old. And do not forget at the end of your script. Look, you have to call the name off the function. You have to call the function by entering its name and then pass in the two parameters that I want. And again, we use parameters so that we can parson dynamic data instead of hard coding these variables . Let's execute the script and it's going to say Hello, Jack, you're 32 years old again. The reason why I'm using Prime ministers so that I can pass in dynamic data, which was second change in dollar as and when required. So I can not to say hello, Sean. And I can say Shawn's ages 40. And when I pressed the play button execute the script, it says, Hello, Sean, you're 40 years old. Let's take a look at another practical function. Example. So in this case, what I'm gonna do you is I'm going to define a program block outside the function, and then I'm going to say function, restart, computer The reason why I am defining this outside. It's because I want the user to give me an input. So I'm saying Program name and then under carrying a function named Restart Computer Opening and closing curly braces and then the if statement indicating it. So if test connection on this computer name fails so because I'm using Dash, not it's negating it. Test connection on this name files, then say System not found. The reason why I'm using this quite statement of a hill, this quite flag so that we did not get any error messages popping out. And while we are over here, let's talk about this test connection. Commanded the test connection, commanded simply sense echo request and approved an echo reply packets to a destination computer to check if the computer exists. If this test connection commander does not receive a reply, it's going to say system not found Els, it's going to say, shutting down the computer and then reset computer and name and then finally restart computer. In this case, I'm just gonna enter any wrong computer name. Now make sure to save your script. Let's call it restart computer save and then let me navigate to my strips directory and 17 here I have the script. So to execute a secret from the come online, I just type in the name of the script and hit the tab key, and it's going to come in automatically. And then I just hit space. And now that's reason why I declare this primary outside so that I can person my daughter to the script directly. So I'm going to say, Name just a random computer That's not on my networks. I can say laptop, for example. And if I had enter, it's gonna wait for a while and then say System not found. However, if I type the name of my computer, it's going to restart it. So make sure you don't type in local host as this primary name over here or the name of a computer. I just couldn't resell your computer. I have. This is this on my computer, and it works fine, so similarly, if you want to shut down multiple computers, you can use something like the get content commanded. So you get a bunch of server names and then reboot them in sequence by simply looping over them but the for each loop. OK, everyone, thanks for watching in the next lecture will talk about advance functions and parameter sets. 11. 10 Advanced functions and parameter validation: Hello, everyone. And welcome back. Before I move into commanded binding in advance functions. I want to show you one last example on the topic that we previously discussed. So I want to show you what the validates said option does and how you can add that to your and how you can enforce that to your parameter. So I simply create a function name, say hi. I used to Parang Block and I define the options I want to enforce on my variable on my parameter. Do not worry about this syntax. For now. Just try and understand what is happening in this line of code to get this syntax right. It's just a matter of practice and reputation, and over time it's gonna become second nature. So what's this doing here? Is it saying that this parameter has to be mandatory? You can either say manager equals true, or you can simply say mandatory. And then I'm saying, validate, Set. What does this mean is that I have a set off options of a hill and that this variable has to be one of these options? That's reason why venues validate set. Similarly, we use validate range to validate the range so the age must be between 18 and 46. If these conditions are not met, the function will era out. Let's execute this function now. I want to show you something else as well. So if I do not pass in parameters because military set to truth, it's going to prompt me for the parameter. So I'm going to say Name Schwinn. Enter H 34. Enter now. What happened to you is it says that it cannot validate primary name. Why is that? Because it has validated this set. So it is. I cannot validate this name because it doesn't exist here. But if I run the script again and say golden an age, let's say 31 that's going to say hide old men your age is study one great Similarly, if executed, stripped again and say Goldman. If I say age 56 it's going to air out, saying that cannot validate argument on perimeter age because it says 56 argument escalated in the maximum allowed range off 46. Great. Now let's move on to advance functions and the commanded by Nikki would. So to put it in simple terms, to make a function in advance function. We use the commanded binding keyword. What this allows you to do is save your function as a commanded. So if you've seen in the previous example I used, I called the name of the script like this. What if I want to call it as a commander like, say, for example, something like restart life in computer just like a common let like get content. For example. In that case, this commander binding lets me do exactly that. This is a basic structure, often advanced function. So you declare the function name you type in, commanded binding than the parameters. And then we have three blocks. We have begin process and the end block. Now any created advanced function, it is not compulsory at all. It is not mandatory at all to define these blocks. I do not use them that frequently, but we'll be mentioning here since power shall provide. That's the option to So what do these blocks do? It says begin. So in the big unblock, you can initialize your variables like, for example, against the I equals zero and then in the process, Look, you can type in your processing code. For example, what don't want to do with this variable I plus plus process it incriminated. And then finally, in the end, I can see it right Output on the name off the variable. Let's talk about another feature so we'll talk about value from pipeline value from pipeline. What is value from Pipeline? Let's have a look at an example straight away. So you, as my example, I'm saying the name of this variable should be the string Marvel Comics a creative function . I give it any random name. Let's say the scarce trade folder I using the parent blockers obviously need a parameter, and I'm going to say parameter. And this is another option that you can use over here that says value from pipeline equals true and in the name of the perimeter. So what is value from pipeline equals two? It simply means that I can take this parameter name from a pipeline and then pass it on to my function. So in this case I have the value, which is this is the value. So I have to value from a pipeline and then I pass it on the function. So that's what this allows us to do now. Let's execute the script and see what it does. It's going to say that the folder has Bean created. Great. This is what Valley from pipeline is. OK, guys, that's it for this lecture. Now the best part is that we're going to combine all of this and create a huge advance function and then convert that advanced function into a power shell. Command it in the next lecture. I'm very excited for the next lecture because we're going to use all of the things that we have learned up to now and make an actual power shall. Come on, let out off it. Thanks of watching again and I'll see you in the next lecture. 12. 11 Let s create our own PowerShell CMDLET: Hello, everyone, and welcome back. We're finally going to have a look at an example off entrance functions. So let's start by defining a function. So I'll tell you what this command that will actually do It's going to either take a single computer name and get a list of applications that I've been installed on the computer. Mm. It's going to take using get content a list off computers and then install applications on all of those computers. Now let's get started from the very top. So I first declare a function and I give it a name. Get hyphen list of applications. Now, do you see the syntax over here? This is basically that you describe your help information or information about the command . Remember the command that we used at the very beginning? Get hyphen help and then the name of the command. So if users use, get hyphen help on the name of your commander, it's going to display all of this information. Just take note of the syntax and the rest is pretty straightforward. Let's go on below, commanded. Binding. The single line of code over you is what actually makes this function. It commanded Now, how do you make your function a commandment? You have to make sure that when you save the script, you go to file savers end. The extension should be P S M one. Usually powershell scripts have an extension p s one. But to make it a more do you have to use the extension P s M one and then save it. I'll show you how we cannot import this model later on. So let's go on to the perhaps So I am setting a perimeter with the name computer name. Let's have a look at these options. The 1st 1 it is mandatory. That means I need the computer name, the position, that meat. It should be the first argument. And I look at this around me to set name. What does this mean? Why am I defining a parameters set name? This value can be anything off your choice. The reason we use parameters set names is because, as you can see, both this part, I mean, is that either need a name off a computer. Who I either need a list of computers from a file. Both, huh? Mandatory. But if I get either off these ones. I am okay and my function will work fine. In short, if I want to make a parameter mandatory but optional, I will just assign it a parameter set name. Let's go a bit off topic and I'll tell you, and I'll give you another example to safer. Have a function. The fact that function accepts a user name, a password and a display name. My function can run if a user only and test the display name. Just say, for example. But I want to ensure that if the users are entering the user name, they enter in the possible as well. Or if they intend the password parameter, they enter the user name as well, so I want I want them. I wanted to be mandatory, but optional. But in case one off that parameter is use likes a user name that I need the possible as well. And why Suissa. So in that case, what I'm going to do is I'm going to assign a parameters set name to boot up those variables user name and password, say, for example, primate, a set name log in. Therefore, both those variables will belong to the parameters set name log in stuff about those variables. Let's see an example. You have use the name as one parameter, and then you can say, like parameter set name Close Logan. And then when I'm defining the possible prime Eaton, I can say parameter set name equals log in as well. Now, these boat belonged to the same parameter set. That means I have. If I'm entering the user name, I have to enter de possible it as well. And if I'm entering the password, I said, perimeter, I have to enter the user name as well. So that's reason why I put in a private a set name. And in case you enter, only one of these power should it's going to prompt you for the other variable as well. And then I can do something like name and the same thing. For example, I can see name, and then I'll just give this into the parameters. That name you can call this anything save display. Now you get the point. So basically what's happening here is I use perimeter set names. When I went to group a bunch of parameters together by grouping them, I'm telling power show that if any one of these are put in, if any one of these are send down as a parameter by the user than the other one in the group has to be used as well, so prompt for it. If not these I use no worries. I could just using the name Pamela. That's fine. Okay, No, let's move on. So coming back, I'm defining two parameters again. I'm using a prime Minister name because I want to make my parameter mandatory, but optional so I can get either the computer name as a single name like, say, for example, local host of the name of my machine. Or I can get a computer file, part a text file with but just computer names in it. Let's go down Soviet seeing over here we're using the if logic. So I'm going to say, if the computer name that I received from the user and then before I do the else condition , this is what I'm going to do. So I'm going to reiterate, or what? Each computer name in the computer named Variable? No. The thing about this computer name Berry Brothers. So, for example, if I have just two or three computer names, right? I can say computer name. Now, why are you going to interrupt over this? Very Bolton's is just one name because say, for example, if I want to specify in multiple computer names, just say two or three in which I can type in manually. And I do want to use the computer list so I can say something like when I called the Commander. I can assign this variable something like, um, say sever one and then sever Oh, too, so you can assign as many as names as you want to this parameter. But obviously, if it's more than two or three and I'm gonna why did manually and you're gonna put it in the list. So if the user enters more than two computers more than 100 computers, I still want to trade over it and and make sure that Power show is taking in all the name of all the names off. The computers are all the elements in that variable, and this would make sure that the function doesn't air out as well. Great. So for each computer name and I'll say for each CN in computer names for each item in computer name. I'm going to first rent a ping test, so I'm going to create a new variable called Ping Result. And then the action of this variable is going to be test connection. And, as you know, test connection will send in a request reply to check if a computer is online. So I'm going to say desk connection, and this is just a power shell. Command it. As we have discussed on you. The name of the computer will be one of the items from the list off this variable if it's one than only one if it's multiple genital itri to each of them. And look at these two flags over here. So Count means I just want to send one occur, regress and one approach and one echo reply by default. It sense for but the same time I'm just gonna say one, and then I do not want the outputs of the echo to be displayed on my screen, so I'll use the quite flag. So now if we get a pink result, if you get a connection back then I want to execute dysfunction with this computer name and we'll talk about dysfunction that we have created bottom over here later on, when we get to this point. So if we have connectivity, then I want to pass down this computer name to this function and then let dysfunction do it's job with that particular computer name else. If there's no connectivity to say, warning, fail to connect to a computer, you can notice here that I'm using right morning because it's going to come up with a yellow blob and say Warning, it's just going to make sure that the air is sort of highlighted Next again. Now, if I get a computer file pot, what I'm gonna do is I'm going to put that in a variable and use, get content and then get content off this computer and in file part, which has Bean given by the user. Now, as we've seen before, I can eat rate over this variable, and I'm going to do for each computer name in computer name in the same thing. What we did above you're going to do a test, a ping test, and if we get a reply pass on this computer name, the function below else see, failed to connect to be computer? No. The main thing is, once we trade over are variable or once we trade over the list off company Just that we have we have to do something with it. What we're doing in this case is we're passing on this variable or a list of computers to this function and the system in function were all are logical izing Let's stroll down and see what this function does. So to find this function find installed application in for and then I'm going to passivity computer name in this case, computer name will come either from here or it will come from here based on what the user has put it. Okay, so it's gonna take in the cut in the name of the computer. Next, I am creating an empty IRA over here. This is how we declared empty area. Now look at this spot. So this is just a registry key on your computer, which contains t list off applications that I installed on your system you can use. You can open the registry editor and navigate to this registry key and you'll find out that under the unstow for another a bunch of applications that, uh, listed over there that I've been installed on your computer. So I want to get that information. So I'm going to store the contents off this registry t in this variable. No, What I'm going to do is, once I get this variable, I'm going to say I'm gonna create another variable called installed APS inflows equals get item property. And then the part is this Why? Because if I just paste this in over here and then I display the variable, it's just going to rent around this text. So I need to used to get item property to actually get the contents off this registry key. And I'm going to say I need the contents off this pot. I need the items off this part. Once I get all the list of applications over here, I'm going to do for each one with a traitor with this and say, for each item in this that we get create another variable, which is going to be a hash table. Notice that this is LBJ's, and this is just all be Jason. Don't get confused between these two. So in this case, I'm creating a hash table. And in that hash table I need I'm gonna set a key, and the value will be the computer name. But I'm going to set another key, and the value will be item don't display name. And so on. The display wasn't on the publisher. And then finally, if you can see over here we have this empty array. I'm going to use this. That empty area plus equals object. So for every iteration, what we get in this, the information that we get in this variable over here is going to be added to a objects are a And finally I'm going to print out the objects area. Now, let's see how we can run this as a commander. So I'm going to scroll down. I'm gonna go to file savers and remember, your script has to be saved us dot psm one. Now make sure you're in the part. So I'm currently in my part with my ps and one file exists. So I will go here and I'm going to say import module. What's the name off the model it was get apstar ps and one and I'm going to hit Enter now. It has been put this as a model and let's go up again. And now, because we have used us come under binding, we can use this name of a function as a model. That's what we have done over here. But remember one thing when you're using the import more deal, you're going to import the name off the script. But once this module has been imported, you're going to use the name off the function. So keep that in mind. So I'm going to say something like Get list off applications and then space. And then I can either pasan in computer name or a text file with multiple computer names. So I'm going to say local Hurst's and hit Enter. And now, as you can see, it just gives me a list of all the applications that have been installed on my computer with the computer name, the information and so on. Great. So that's how we can basically put whole the things that we've learned together and create an advance function. Okay, guys, that's it for now. And I know that this has bean a handful of information I've given you. But keep in mind that right now what you're doing is really advanced partial stuff. We have basically created our own command lit. So feel free to go over the video again, understand what's happening in each and every line of code. And again, if you have any issues, please do not hesitate to email me and I will get back to us. And as I can before I let you go, I want to show you one more thing. That is the use off this. Help note that Riverton over here so I can say get help as we use it for any other commandment. And I'm going to say Show me held for get a list of applications. If I enter, it's going to give me all this content over here. When I say that's the name of the command led. That's how you can use it. And you can modify this information as you need. OK, that's hold for now. And I will see you in the next lecture. Thank you. 13. 12 Parameter Splatting and Sending Emails via PowerShell: Hello, everyone. And welcome back in this lecture, we're going to have a look at parameter splitting and how we can send emails in power show to send emails in power shell. All you got to do is you see, send mail message. Come on. Now, if you have a look at the send mail message command over here, you can see that the syntax is quite long and huge. So I gotta do in, like, send mail mess agent than from and then the subject and love a block. Now, each and every time if I want to send an email, it's gonna be really painful declaring these declaring all these primaries together over here. Right? So what I can do in that case is I can group these parameters into a single set, and that is call is permitted splitting. So if I want a group, all these prime minister together, I'm simply going to enclose them with the at symbol. So I'm going to declare a variable, and then I'm gonna say equals at open curly braces and close curly braces. And then I have all of these key and value pairs in over here and then Finally, once I've put in all the information that I need, I'm going to say, send email message and then I'm going to call this variable. One thing to note is that when you call a group of variables, that is, if you use prime minister plotting, you have to call or passing the parameter with the at symbol over here. And now what's gonna happen is if I execute the script, it's going to take in all these parameters as one. And then it's gonna send on the email at highly recommend you try this out in your work environment. If you have a test environment set up, we're using an extreme server. Orilla Next mail server. If you try and use this with things like Gmail, you see these options over here is sometimes don't work. Why? Because Gmail has a lot of security settings like you have to sort of conficker use less secure applications and so one same with Yahoo and other common email providers. But if you have your own email infrastructure in your office environment, I'd recommend you go ahead and try this out. And in that case, in case you get any error message off anything failing awesome. You have complete control over the extra and serve, and it can change certain settings if you try to use something like from Gmail and use this smtp at gmail dot com. Gmail is gonna think that some sort of a but Owen automated script is trying to send emails on your behalf, though you supplied the credentials and it may block it, so I'd recommend you to try the stripped out in your work environment. So we've had a look at how we can group parameters together, which is on us perimeter splitting. So if you have any command, let not only the send me a message. Come on. Let if you have any commander that has that demands a number off different parameters, you can simply group them over here and then pass a minutes one and the next time, if I want to change any daughter India, I simply coming in and change it over here. And nothing changes over here. So that way it becomes neat and clean. And one of the examples you would use this is say, for example, you are running a backup job and you want to send an automated email out every day or two users saying that backups have been completed or you just want to send out a greeting message every day. So you can used the Window Star schedule and schedule the script to run every day, say, 8 a.m. in the morning, and then it'll send out an email message to all of these users. So that's how you can sort of automate sending email messages using power show. Okay, guys, that's it for this lecture. If you have any queries, please email me and I'll get back to us and as I can, thank you. 14. 13 Writing Event Logs: Hello, everyone. And welcome back in this lecture, we're going to have a look at how we can use power show to write events to the Windows event log. So if you open up windows, even log, have you even looks? There you go. So if I expand this up and you can see Windows logs, So at a system administrator, you generally know that if an application crashes on your system or if the system shuts down on expectedly, the first thing become and the first thing we do is we open up windows him and we ran. Check the logs to see what exactly has happened. We have four different categories off when those logs once the application look, which means your applications send error information or any sort of information regarding them to the application section off. When those logs, we have the security log, which gives you security rigid events like if a computer account fail to log in or if it was successful, that where you can't see which uses logged in and when and whether the attempt was successful on month, and then you have the other important one. With this system logs now Let's see how we can get Power Shell to send in the events to the event. Log off windows. So I opened up my power shall Iasi. And as you can see over here, what were first gonna do is we're going to create a new event long. The reason why we use this is because because we want to tell when those event logs that I'm creating a new source, What is the source? So the sources, basically where the era came out from. So if there's an error over here and I don't know where that air originated from, I don't have a clue. So what that error is so this era could be, For example, if I goto application, you can see that it's coming from this application or this information is coming from this application. So that's what your sources. So from where exactly the error came out. So I'm gonna say source. I'm just gonna call it my custom application. This flag over here that says log name is application, meaning, where do you want to send this lock to? And in this case, I'm seeing application because I want to send this love to the application section of the windows logs. Now let's first execute the statement Once that executed power shall now knows that this source exists. Now let's look at the other command to Astri Wright Animal log. I'm going to say right, even log the log name that I want to write it too, which could be any one of these. It could be application or security your system. And then I'm going to say the entry type. So what is the entry type For every log you have things like information, error and warning. So if you stroll down again, See, I have a type and entry type of information. I have an entry type as error. And then if you scroll down, maybe you might see a warning as well. So I'm saying that the entry type is going to be information. The source from where this era comes out from is my custom. It should be my custom applications. Sorry about that. And in this event, I d can be anything. And then the name of the message. So now if I execute this, I have no areas. And if I go to my event, if you have And if I say application, there you go. It says source of this information that's come from my custom application, and it says Test application. Log entry. Great. Let's change us too, So we can type in application entry type era. And if I execute now, if I go back over here You see, I've got here a message over here that says tests Look, test application log entry coming from my custom application. So that's generally how you send events to the windows even longer. You were using power show. Okay, everyone, that's it for this lecture. If you have any questions, please feel free to email me. And I'd like thank you for washing. 15. 14 PowerShell Remoting and the Invoke command: I love everyone. And welcome back in this lecture we're going to talk about power shell promoting. So there are basically two ways in which we can execute commands remotely on other computers once by using the new PS session Command and de Aza and the other by using the inward command, let's have a look at the first option. So for demonstration purposes, I've installed Oracle VM virtual box and I've created to virtual machines ones a Windows 10 . Which one machine and the other machine is A when those 2012 domain controller so have set up active directory and, um, in controller settings on that machine. And I've joined this Windows 10 machine Do that domain. Now, since you're part of the same domain, we should be able to run these Kamins with ease. So before we get started, I'd like to highlight something that could not make this work. So just go right to go on a tosspot, go to toss manager, more details and under services, filter it out by name and make sure that the Vin Arm Services running Venera um, is Windows Remote Management service. And it's used by PS session and invoke Command. Great. Now let's see how we can establish a new session. So I'll type in new dash PS session, the computer name, which is in this case, this is the name off my windows during 12 server and hit enter. And there you go. As you can see, you can see that there is a connection that has bean open. This is the I. D. And this is the name. No. Once you create the session, we would have to into the session. So for that, we type in, Enter PS session computer name the name of my computer hit, Enter. And now, as you can see, I've got access to the show off my windows. Treadwell server Hucles that now, whatever. Come on to execute on the server is going to be actually executed on the 2012 server. Let's have a look at an example. So if I hit get process, it's gonna display all processes on my windows when it will sever In this way, you can create PS sessions for any computer on your network and then remotely run commands over it. I can even do something like reboot system or shutdown system or check processes and then kill certain processes off. Eight. Remote computer Very useful when troubleshooting. And when you can't use Microsoft's Rdp to remote in four sudden reasons, then you can resort to using PS sessions to exit recession. All you can do is type in exit PS session Great, and now you're back to your own show. That's one way you can execute Chemins on a different computer. The other way you can work commands on the computer is by using the in work. Kim in Command it and then I would say, computer name in the name of my windows. When it rolled, Sever went to stun. After Abby, I have to add a another flag call script block, and that's the name suggest I have to enter in my code. Within the set off. Carly braces. Whatever needs to be executed on the command for this example. Again, I'll execute D get process command, and if I hit enter, you can see that I get a list of processes from my Windows 2012 7 This is another way that you can use to execute remote scripts or command Let's on remote computers. Remember, he can also again substitute this computer name with a variable name and that variable name could equals. Get content a name for text file with multiple computer names in it. You can then use for each solute forward and then run these commands on multiple computers as well. Okay, everyone, that's it for this lecture. If you have any doubts, please email me and I'll get back to you as soon as I can. Thanks for watching. 16. 15 REST methods and downloading files with PowerShell: Hello, everyone. And welcome back in this lecture, we're going to look at how we can send requests through matters like get and post to a rest a p I. So what is rest? It's simply stands for representation State transfer and what does that mean? It means that you can use methods like get post put and elite to either get data from a website posted to a website, modify or delete data from a website that has exposed an A P I. For example, when you go onto google dot com in your browser behind the scenes, it's in working a get request when you key in your user name and password to log into an account like Gmail, for instance, you are submitting a post request because you're posting derogatory website using power show we can use to get and post method to fetch and post at our website using the in work rest minted command. For this example, I'll be using a free website that allows us to test AP requests. So if you open up your browser and go to Jason placeholder dot type the code dot com forward slash posts. This is a bunch off data that's pre populated over here on this website, you can freely frets data from this website using power show. Let's see how we can do that. So I'm going to define a variable and I'm going to name it get And I'm going to use the invoke rest Method Command, specify the method name and then the u R I in this case, the girl is this. So once I hit the play button that's going to fetch all that data is gonna go up to this website, get all the data as it can from there and then it's gonna place it in this variable snuffle get get. I can see that all the starter from the website has been fetched and stored in this variable similarity. You can post data to that a p I. So to post data, all I've uses I'll say, I'll create a variable. I'll name it post. I'll use the invoke rest omitted the method to post and the u R. I. Now, when you post something, you need to obviously sending data and you do that through the body flag and then enter the body, which in this case is a variable that up to find with some preloaded data. It's basically a hash table with key value pays. And then I'm taking this body and I'm converting into Jason because the a p a. That we're going to send data to understand Jason so I can use the convert to Jason Method to convert dollar that I've got in this variable into ages on format. Now if I hit, enter If I run the script, there you go. It hasn't come up with any errors, but it as it tells me that I've run my script now, you can not actually post data onto this website over here. They have blocked it out for some reason, and I think it's pretty obvious that if we keep on sending requests, if everyone off us keeps on sending requests over here, if you keep on posting data, it's eventually going to max out its stories capacity. And that's possibly one of the reasons why it doesn't tell you that it is a road out, but it won't let you to post data onto their A p I. But if you have your own AP, I Oh, if you have an A p I that your company uses You can post data to that. A p I using the in work, rest with it. Command using the method post one last command that I want to talk to you about this the invoke the Progress Command. You can use the in work rep Request command to download files onto your computer. Say, for example, and we'll get get requests. Do you? Are I the name of the girl and that I'm going to say out foul should be test one Don't jpg means once you get that content, save this file on your system as test one dot jpg on this location, Let me change my location here. Stolen. So first, let's go on to this link and see what's exactly on this link. So for Open up my browser and I pace in that link. What's gonna happen is is directly going to in town. But that photo for me open up that photo. There you go. But if I want to automate this process of downloading files, then I can use the in book rep request method in power show. And similarly, when I execute this now, there you go it's gone, requested it, and it has saved the file on my desktop with the name test one dot jpg. Great. So that's how you can download files using in Brook Web request. OK, everyone, that's it for this lecture. If you have any doubts or questions, please feel free to email me and I'll get back to us. And as I can, Thanks for watching. 17. 16 WMI classes: Hello, everyone. And welcome back in this lecture, we're going to talk about the Windows management instrument. W M. I basically has a set off classes that help us automate administrative task daily like, say, running a monthly report on a system or in a group of systems in your network and grabbing information. Say, for example, things like the space physical memory services running on the system and so on. So us A basic syntax of how I would get the disc information off a computer. If you're running this command locally on your system, all you need to do is just type in this command. Get a player. My object, the class the classes win 32 underscore logical disk. So this is the class that we will be using to get information on the destroy lives on your local host. You can omit this computer named Flag if you're running it on your local computer, but if you need to get information on another computer, you can add any computer name. Similarly, you can also find details like the operating system, the service on the physical memory. There are a bunch of other classes available as well So if you're interested, you can Google eight list off w my classes and you'll get those other options as well. Primarily, I use these options. So let's take a look at an example so I can say, get a player my object class When 30 geological disk. I don't need the computer named Flag because I'm running this because I need information from my local computer. So if I hit enter, it gives me information about my drives on the computer like free space size volume name device I D. And so I can also pipe the results of this to the select a man that reviewed in previous lectures. So, for example, say I want to select only the device I d. And then the volume name in the free space and the size. So this is how I will select only the attributes that I I would like to see and I'll execute the script. And there you go. You get the information in a nuclear unstable great. Similarly, you can also use something like get wmal object class operating system. This will just give you information about the operating system like this. The system directory. Um This is my manufacturer. This is the bill number and so on. Let's take a look at physical memory. If I execute this, I get a bunch of details. How cool is that again? If I want to select only certain elements from this upward again Usti. I can pipe these results to de select a man and then select only the fields that I need. And again, if you need a bunch of information from a list of computers, you can simply specify the computer name flag to be a variable on that variable can then be get content from a text file, which has a list of computer names, for example, I can say computer name, and then I can just put in a variable over here like, say, list. And then I can define list over here to be, get content and then say the pot say, for example, the pot said My father's in the C drive directly, and it's named as Let's start Txt. And then once I get this contact and then once I get this list, I can say for each item in a list executed following command, okay, and that way you'll get information money, a bunch of computers within your network. That's it for now, guys and again in this lecture view of spoken about w on my classes and are recommended to try these on your local computer or if you have a bunch of computers in your corporate environment, or if you have a test environment that encouraged to go ahead and try this out in your network environment as well. That's it for this lecture. Thanks for viewing guys, and if you have any questions about, please feel free to email me. 18. 17 Working with CSV and XML files: Hello, everyone. And welcome back And this lecture, we're gonna take a look at how we can work with CSP and XML files. Well, first, start with CSP files to improve data from a CSP file. We used the import CSP commanded given to a spy power show for demonstration purposes. I already have a dot CS three file in my system that I've created, and I've created a table with some dummy data in it. Now, if I want to import this file into Power Shell, I can use it using the import CSP commander. And there, after I can run queries on this excel, she lets see how that's done. So, as you can see here, a first created a variable have given it a name of data and then I say, equals import CS three and then the name of the CS Revile. Not that you can't use get continent this case because get content wandering nasty format off this year's free file. That's what we used the import CS three command let So if I now run the script There you go . It has imported everything into data. So if I now display data, I get all this data from the CSP file. Now I can do something like, say, for example, I can run a query like data. Pipe it through there. The last name equals crow. If I had enter, it will give me data off the student whose last name is Crow. Let's try another example. I can query data where h equals study one. So I'm clearing data where h is 31. And if I hit Enter, I get the entire record off that student whose ages? 31 If I want to only view sudden columns, I can do something like Dara. Pipe it through, select and then first name. And if I enter, I only get the first column. I can also say something like First name Comma H and I'll get the first name and the age. So this is how you can query data from a CSP file. Great. Now let's move on to working with XML files. One way I can import an XML file is by enforcing my variable to be of type XML. And then I'm going to use get content and import this XML file that's execute the script. The ego. Now let me open up my XML file to show you the contents off it. I've created a sample XML file that has certain tags similar to hate steam attacks like people and inside the main people. Doctor have person with different persons and then I have inside person. I have name and age. Let's see how I can query this daughter from an XML file in power show. So once have imported that data over here, I can run commands like, say, data dot people. And then you go I get Gwen, King, Arthur and Merlin, so it'll query everything inside the people tag. I can also use data dot people don't person to get more information. And there you go. So all this information is inside the person tack. I d age. Except you can also do something like that. I don't people that person. And if I hit zero, this will give me only the first tag, the first element in my XML sheet. And similarly, to get the second element, I can use one enter and I'll get the details of the second element. So this is how you can query XML files 19. 18 Error Handling: Hello, everyone, and welcome to Section five. In this section, we're gonna talk about air handling the AWS module in power show, the active Directory Mario and the archived audio. In this video, let's talk about the error handling options that power Shell gives us. So as you can see an era, action performs a sudden action that we tell it to to either suppressor errors. Stop, continue, inquire. Except this is the basic syntax, the dash or action keyword and then the action. If you want to specify what happens in case doesn't Aargh! And again we have six different options there. Action. Want silently Continue. We're in the error messages are suppressed, but execution continues. Then we have stopped, which forces the execution of the script to stop. Then we have continue continuous the default option. So if you don't specify an error action, it defaults to continue. This means that errors will be displayed on the screen and execution of the script will still continue. Inquire will promptly. Whether you want to execute the script or not suspend a similar to stop and again ignored is somewhat similar to silently continue. Let's have a look at a few of these options. So having my power shall I see opened up and I'm going to use it, for example, Get content. I'm going to specify a file that does not like that does not exist. So, for example, say, if I do not have any air action away, what's going to happen is if I execute the script, it's going to give me a big red error message, and then it's going to proceed to the next command in the script. Why is it giving me this er mrs. And then proceeding to the next command? Let is, because by default, the interaction is continue. Now let me remove this folder and try another option so I can say era action. And there you go power shall I see automatically gives a D options over here. Let's go with silently. Continue so this part doesn't exist. And if I click the play button, the error message is going to be suppressed and the script litigation is going to continue . Similarly, let's try, ignore, ignore would simply do the same thing. Let's try, inquire. So if I do enquire, let me first remove the folder again. So if I do Enquire. The ego is going to prop me as to what I need to do. I can either say yes to all. I can neither stop the command. Why Canada suspend the command. So if I say yes, it's going to execute the next command in sequence. And there you go. It will give up the error message, but it will continue to the next command after enquiring with the user. So that's how you can handle errors in power show. 20. 19 Active Directory Module: Hello, everyone. And welcome back in this lecture, we're going to talk about the active directory model. This is one of the most helpful models have come across while learning power show, and especially now when at work were migrating to another domain. I've been able to put a bunch of information on reports off users and groups and a lot of other information, and give them to my manager for review as to which objects and users and groups need to be migrated across to another domain. So it's been really helpful for me off light. There's a lot off active replica man. Let's. But in this lecture, we look at a few commonly use. Come on, let's in active directory. So I've got my Windows 2012 server running up here. It's a virtual machine that I've just created, and the first commandment that we're gonna have a look at is get 80 domain command lit. It's a very simple commanded, and it's going to give you a bunch of information about your domain. And if you just want specific things, as we've discussed earlier and different lectures, you can simply pipe it to select and then type in a particular item that you're looking for . Now let's look at the get 80 group. Come on, Let So they get 80. Group commanded simply displays information about a particular group. Sir, In my active directory, I have a group that's named administrators, which have a bunch of you, isn't it? So if I hit the play button, if I run the script, that's going to give me all information about the administrators security group. Similarly, if I want to filter out all security groups in my current domain, I can use the command. Let get 80 Group filter it out to group category equals security. And I missed the single cut closing over here too close to query and now for execute the script. There he goes, giving me a bunch of information about all the groups that are in my current directory. We can also do something like F T, which means format table, and then I can do something like name. If I hit play, it just gives me the name and it eliminates all other unwanted information. Now let's have a look at this Query this. Come on, let us call get 80 group member identity administrators, which means is simply going to list all the users that are part of the administrators group on my domain. So if I hit play sorry that I dismissed a space so remote that space. So if I hit play there you go. It's gonna give me all the uses that are there in my administrators group and again I can pipe it and use FT with Santa format table and simply filter out the names. So if I hit OK, there you go. These are the three users that are a part of the administrators group. So now let's have a look at this query. So over here I'm using Get 80 Group to get information about the test group, and then I'm going to pipe it to remove 80 Group member and the name of the members John Doe. So I'll open up my active directory, and, as you can see, I have a test group over here with John Doe at its member. So using the command line, I can simply remove John Doe from the group test group. If I could play, it's too low. And now if I have a look at the group, you can see that John Doe has disappeared has been removed from the group. Now let's have a look at the get 80 computer. Come on, let's so this simply gets information about a computer that has been joined to your domain . So if I hit, play and then you go and gives me information about the computer like it's Deanna's house name and other details like the object class, this object classes basically, what type of an object is it in active directory? It could be a user or a computer or another object. So get 80 computer, then filter name like PC or one. This is the only computer that's currently joined to this test on May. I can also further enhance this query by typing in the command that get 80 computer filter where name like this is from my work. So a name like P. C 01 and then properties. I need the I P V four address as well. Okay, let's see what this does first. So we'll take this off for now, and when I hit play, it gives me a bunch of information as the previous command. But over here it gives me the I P V four address s Wilton, sir. Specifically requested that now you can filter it to you can pipe it through and then use the F D command for for my table. And then he only won the name the d n a source name and the i p before address. So if I hit play begin, see that it has given me. Ain't need table off the name D an associate man. I'd be before address. So that's how you can query information about a particular computer that has been joined to your domain. And remember, you can always loop over this by adding, get content to a variable with a list off PC names. Now let's have a look at this query. This query is going to give me a list of computers that have said their password 90 days ago. Let's start with this variable. So I'm just declaring a variable and this expression that he can see you, will you? It's a dotnet expression. So what's happening is we're simply asking for the date and then we are substrate ing 90 days from it. That means we're going 90 days before today state. So we're going in the past. Now I can use get 80 computer commanded filter it out where passport last set is greater than this value. So in this case, the value is minus 90. It'll take us 90 days back and the property is password last set. So it'll give me all the list off computers. That's password was last set 90 days ago. Now, unfortunately, I can't run this query on my active directory because I've just set up my active directory about two days ago on this virtual machine. So obviously I won't get this result. But feel free to go ahead and try this out in your work or test environment, because again, this is just getting information. It's not going to write information to your active directory, and it won't break anything to other simple commands. That I'd like to show you is the enable 80 account and the Disable. Any accounts of your first look at any malaria count and I'll just say, enable Eddie forceful, disabled this account and then enable it cuts already enabled. So I'll do disable 80 account and the name of the accounts of the name of the account is the user name is john dot doe. And if I execute the script, if I not weapon, my active directory and I go to users, you can see that John Doe do has been disabled. Can you see that Aramark down here? That means the account has been disabled. No, if I go to enable 80 account if I hit play, it's going to enable the account. But after refresh it. So I'll go to users and refresh the street. And they can't see that that Aramark it's no longer there, and the account is not enabled. So John, look in our log into the domain, so that's a lot of important active directory command. Let's that we have learned on the most commonly used ones as well. Let's take a break. And in the next lecture, we'll talk about the archive model 21. 20 Archive Module: Hello, everyone. And welcome back in this lecture will take a look at the archive model so you would use the archive model to either compressed files into a single zip file or extract the contents of a compressed file. The archive model is strangely used in scripts where a lot of lock files are generated. So at the end of the script, you would compress all of these lock files into one single zip file. Still, it's easier for you to manage and send these log files. Maybe. Why email? Let's see these commands in action. So before we proceed, as you might have seen in the presentation, we have two Main Command let's, which is the compressed archive and the expand aircraft commanded pretty strimple and straightforward. So in the compressed archive, come on, let you specify the part to the folder that you want to compress. The compression level in this case will say fastest cause we just want to sit the files and then the destination part the part where you want to see if there's a file. I learned the other end. If you want to extract a particular file, you use expand archive, part the zip fell and the destination for whatever you want to extract the contents. Apart from the fastest compression level that we have over here, we can also specify optimal, which will take a bit off a wilder compress your lock fouls, but it will ensure that your file is a far smaller size, and then we also have no compression at all, which will simply just subdue file together. Fastest is the one that I usually use in my scripts. Let's have a look at these two commands in action, so I have an archive over here, and the full name is actually Result Docks. Let me just correct this. He's a docks, so I'm going to use compressed archive part. This is the part where my full delights and I'm going to say compression level fastest and the destination part will be desktop. And let's call this file sipped foul. Now, when I execute the script, there you go. It will support my files. Let's have a look at that. A zip file. So if I go to my desktop so see users dove in desktop before doing a less. There you go. You see that it has compressed. This is that file and let me see if I can literally show it to you on my screens of a minimize everything. There you go. There's this zip file. If I double click this file, there's my full Lovisa docks, and in that I have a a bunch off period files that were compressed. Similarly, I can use expand archive to extract contents of these that fell. So in this case, Flag is called literal part. And then I'll specify the name off my supply answer. In this case, it's zipped file, and in this case we don't specify the compression level cause they're simply extracting it . And then the destination path would be this folder called Lasted file. So if I hit execute, so I got to make sure that I even put in the extension that zip. And there you go. So now if I go to my desktop again and they do an LS to list the contents of my desktop folder, we should see a folder name called Zip File. And there you go. Here it is. It has just been created. 9:55 a.m. That's the time on my computer as Well, great. Okay, guys. So this was a very short lecture on using the archive model. If you have any questions or doubts, please feel free to email me on Dahlgren f at gmail dot com. Thanks for watching. 22. 21 AWS module for offsite backup: Hello, everyone. And welcome back in this lecture, we're going to take a look at the AWS publishing module. So AWS is one of my favorite cloud providers. They give you a bunch of tools and options where you can set up things like an history bucket for storage. Amazon easy to instant isn't much more. We'll be using the AWS partial model to back up our files to ancestry. Bucket an s three bucket is simply Amazon. Simple storage service. It's similar to Google Drive or Dropbox, where you can upload files. We'll see how he can use power show to automate uploading of files to on AWS s three bucket . First things first, head over to this link or you can simply Google aws power shell install. And then if you scroll down over here, you can see that years an XY file. So once you download this XY file, the insulation is pretty straightforward. It's just a simple next next and finish. Once we have the AWS partial module installed, you can head over. And if you do not have on AWS account, you can simply Google aws and then you concerned I'm trying aws free tier account. So I already up signed up to AWS. And if you go to services, that's type in S three, which is Amazon's simple story service. And we'll use to come online to create a bucket. And then through the common line, we will upload files to this bucket again. They simply call it a bucket. It's just a plain folder that's stored on the cloud. So before we can get started uploading our files to AWS, we have to first set up authentication. So Power Shell needs to know how it's going to communicate with AWS. So to do that, we will first create a user inside your account. So let's type in I Am, which stands for identity Access management. Click on I am that head over to uses and we'll say, Add User, let's say the user name is power show. I'm going to make sure I give it programmatic access. I want to click next for permissions, attach existing policies directly, and in this case, for demonstration purposes, I'm going to use administrator access. That's it. Next review and then finally create user. Now you can see that a user has been created by the name of power show and take a look at this. You get a access key, I d ending secret access key. All right, I'm gonna show this way. So once you've got this information, let's open up a partial Iasi and it's paste. This came out in here. So in this link, as you can see, you can simply use the in salt module on the name AWS Power show and it will install the AWS partial module for you. So let's get to setting up our credentials. So now I'm going to use the command that set AWS credential I'm going to enter in the access key. In this case, my access key is this. Paste it. And then the secret key is this. It's a copy and then paste it out the stories. Flag is simply telling Power show what? You want to store this credential? As so I'll say I just use my name here in this case. So I'll hit the play button. It'll take a few minutes and will then configure this set of credentials to be used with power show. One less common that we would use before we get started is the initialized aws default configuration, which means by default, if you have multiple profiles, which one would you like to use to communicate with? AWS? So I'm going to say my profound in that I created was dull did so it's gonna be golden, and then the region would be AP southeast Haven't do because I'm based in Sydney. So it's easier for me and I will have less latency. So did the play button, and it will do its thing. So now this is set as the default profile for Power shell to communicate with AWS. Now let's see how we can create an AWS bucket. I can simply use the command that new s three bucket bucket name, which would be the name off the bucket and then the profile name that I'm going to use. So in this case is gonna be dolphin. One important thing to note is that this bucket name has to be unique because it creates a DNS entry. So if you get an Arab and you run this command, make sure you try different bucket names because your bucket name is unique throughout the entire AWS community. You cannot use an orderly previously used pocket name. So let's it play. There you go. And it says that member kit has now been created on the bucket. Name is Dahlman backup files in this case. So if I go to services, if I go to s three, you can now see that my bucket has been created. Now let's see how we can upload files to this s three bucket again. A bucket is just a fancy name given by AWS. It's simply a folder in the cloud. So to upload a file to my new s tree bucket, I can simply use the common let write history, object the name of the bucket that I want to upload the file do and then the file. So in this case, I will upload the CFL that we just created the previous lecture. So dolphin destruct and it was called zip file. That is it great. I lived the play button as it can see its now uploading my file to the vestry bucket. And there you go. It's done. So now if I go ahead and if I open my bucket, I can see that it has a file over here on us and zip filed a zip. Great. So that's how you would upload files into an extra bucket using power show. I usually use this for backing up files at work to the cloud as offsite storage. Well, not everyone. That's it for this lecture. I hope you enjoyed doing this and I'll see you in the next lecture. 23. Final note: Hello, everyone, and welcome back. I'd like to congratulate each and every one of you for making it this far. It takes a lot of time and effort and sacrifice to set aside some valuable time to learn a new skill. You've learned some really awesome and advanced power shell stuff and on our way ahead off , other system administrators feel proud to be one of those system administrators who know how to script. I'd like to hear from you about your feet back on the course, because again, I'm only human and may tend to make a few teaching arrest here and there. So please email me or leave a review. Thanks again, everyone. It's a lovely, bright Sunday morning here in Sydney and I'm headed out to the beach. Enjoy the rest of your day. And don't forget to show off your power. Shall skills at work once again? Thanks for taking this course