1 00:00:06,210 --> 00:00:12,350 You need to learn the basics and have a point of reference for build on your own scripts. 2 00:00:12,430 --> 00:00:19,810 And this lesson will cover core power shell concepts that will provide you with a foundation of knowledge 3 00:00:19,900 --> 00:00:23,470 for using their remaining examples. 4 00:00:23,500 --> 00:00:31,570 In this course if you are already familiar with power shell you may want to use this video as a review 5 00:00:31,600 --> 00:00:36,780 or as a reference for later after you've started writing scripts. 6 00:00:36,790 --> 00:00:41,830 If you are completely new to power shell the concept might be familiar. 7 00:00:41,830 --> 00:00:51,190 If you've worked with Unix common shells like Unix based shells or Shell also allows you to stream multiple 8 00:00:51,190 --> 00:00:56,230 commands together on one line using a technique called Pipeline. 9 00:00:56,230 --> 00:01:01,790 This means that the output of one command becomes the input for another. 10 00:01:01,810 --> 00:01:07,790 First off let's open power shall run a search for power shall on your computer. 11 00:01:07,840 --> 00:01:15,830 You probably have several different options like power shall power shall I as a power shell x eighty 12 00:01:15,870 --> 00:01:16,950 six. 13 00:01:17,010 --> 00:01:24,400 The ISC or integrated scripting environment as I have mentioned already is a handy tool which allows 14 00:01:24,400 --> 00:01:31,730 you to write scripts on the fly and also has a conventional low carb for all the power shell commands. 15 00:01:31,750 --> 00:01:38,860 Right now this is more than we need access to six exist for backwards compatibility. 16 00:01:38,860 --> 00:01:47,690 We want X 64 bit for our usage and we'll use the one just called Windows power show. 17 00:01:47,740 --> 00:01:55,450 You may want to be in it to your bar right click it together this option when you open it it will look 18 00:01:55,450 --> 00:01:56,170 like this. 19 00:01:56,350 --> 00:02:04,930 If you don't like the white on blue right click the top bar select properties and go to colors to change 20 00:02:04,930 --> 00:02:05,770 things. 21 00:02:05,770 --> 00:02:12,250 You may have to close and threw open power shell together to display correctly when we are ready. 22 00:02:12,250 --> 00:02:20,620 We can navigate our system and I seen about power shall as you always know where you are because it 23 00:02:20,620 --> 00:02:22,860 tells you that in the prompt. 24 00:02:22,960 --> 00:02:27,500 In my case it's like this but you should see something similar. 25 00:02:27,550 --> 00:02:35,240 Marta is your user name in case you don't just type a cell space field character. 26 00:02:35,350 --> 00:02:37,210 Make sure to include this space. 27 00:02:37,210 --> 00:02:39,130 This will bring you to your home. 28 00:02:39,130 --> 00:02:48,640 Director a director is just another word for folder and power shell considers your user folder to be 29 00:02:48,640 --> 00:02:49,740 your home. 30 00:02:49,860 --> 00:02:58,960 Entering our cell space tilt is just like opening the folder called to users and from there using your 31 00:02:58,960 --> 00:03:00,790 graphical user interface. 32 00:03:00,910 --> 00:03:07,420 So let's start by learning how to move around between directories and view their contents. 33 00:03:07,420 --> 00:03:13,810 To view director accountants you could use get the child item command led. 34 00:03:13,840 --> 00:03:16,470 There are several aliases for it. 35 00:03:16,470 --> 00:03:28,360 Also you could type GC I alas or Dear All those are aliases for the get this child Titan command let 36 00:03:28,540 --> 00:03:35,860 our first command is girl child Titan so go ahead and type it in and hit enter. 37 00:03:35,860 --> 00:03:39,530 You'll see a list of everything in your current director. 38 00:03:39,670 --> 00:03:45,010 In my case that looks like this it could be different on your screen. 39 00:03:45,010 --> 00:03:52,710 Notice that instead of this long command get this child to item you could just enter juicy AI. 40 00:03:52,840 --> 00:03:57,850 It's an abbreviation for it or alias the commands will let command. 41 00:03:57,850 --> 00:04:02,750 So we will be alone in are all of the form verb Dash. 42 00:04:02,770 --> 00:04:11,080 Now these so-called command levels and to their form is supposed to make it easy to remember what they 43 00:04:11,080 --> 00:04:16,670 do and predict similar command levels because command lets a rather long. 44 00:04:16,720 --> 00:04:20,170 Most of them come with slick or aliases. 45 00:04:20,170 --> 00:04:23,610 As I've mentioned that you can use instead. 46 00:04:23,710 --> 00:04:24,970 I will first present. 47 00:04:24,970 --> 00:04:32,770 Come on let's with their names but all this subsequently use the standard aliases because they are much 48 00:04:32,770 --> 00:04:34,530 faster to work with. 49 00:04:34,540 --> 00:04:40,920 It is important to note that many command LEDs have multiple aliases for instance. 50 00:04:41,050 --> 00:04:49,920 These Goodchild type item either GCI dear or less all of them do exactly the same thing. 51 00:04:49,990 --> 00:04:59,440 While it is unsurprising that GCI is short forget child Titan you might be wondering where deer or alas 52 00:04:59,440 --> 00:05:05,690 come from power show is relatively new and its designer as anticipated. 53 00:05:05,800 --> 00:05:13,420 Many people who would use it would already have experience with some existing command line interface 54 00:05:13,510 --> 00:05:20,950 specifically either with Microsoft command line interface called command prompt or as Linux command 55 00:05:20,950 --> 00:05:27,660 line interface like bash which is now also standard on all six last man. 56 00:05:27,670 --> 00:05:35,320 Come on let's have an alias that is standard command in one of these two systems and often for both 57 00:05:35,530 --> 00:05:44,020 in the present example duel comes from command prompt and allows comes from bash I'll use power shell 58 00:05:44,020 --> 00:05:52,660 style aliases in this demonstration but I'll try to mention are the common aliases particular those 59 00:05:52,660 --> 00:06:02,380 familiar for bash users so Linux users so go ahead and try use them GCI dear or allows command and see 60 00:06:02,380 --> 00:06:04,600 the contents of your directory. 61 00:06:04,600 --> 00:06:13,240 Now when we did it we can move between directories with set dash location command left or as L abbreviation 62 00:06:13,240 --> 00:06:22,570 for it or C D command it's good for common to prompt previous command prompt Windows system and Linux 63 00:06:22,570 --> 00:06:32,170 system lets type a cell and some folder which you can see in the output of your previous command and 64 00:06:32,290 --> 00:06:41,830 it'll change your location from your current location to the folder you've specified we can move back 65 00:06:41,830 --> 00:06:51,430 to your previous location again by type in SL and two dots and of course the space between a cell command 66 00:06:51,460 --> 00:06:59,920 and two dots now trial navigate and back to the folder you've been before and to some other folder Mixon 67 00:07:00,020 --> 00:07:07,870 Siddiqa amount and a cell command if you want to navigate to level sloppier good try type in a cell 68 00:07:08,050 --> 00:07:17,290 space two dots backslash two dots instead of backslash you could also type slash so power Shell is not 69 00:07:17,290 --> 00:07:25,620 case insert sensitive and doesn't care about the slashes so it could be a backslash or just slash. 70 00:07:25,640 --> 00:07:34,390 Now we can try create a new directorate with M card dear command in any folder you lie if you want to 71 00:07:34,390 --> 00:07:42,490 get back to your home direct to reforest you could type again a cell space tilt and it'll get you to 72 00:07:42,490 --> 00:07:51,250 your home director and here we can make a new directory Let's type M Kadir and call the directory like 73 00:07:51,400 --> 00:08:01,030 the s or whatever name your line Move into your new director using as our command by type in a cell 74 00:08:01,060 --> 00:08:09,670 and whatever your title to your director in my case it's appears now Let's type GC I and you'll see 75 00:08:09,670 --> 00:08:16,120 that there is nothing here that's because we've just created this directory and it's empty we could 76 00:08:16,240 --> 00:08:25,120 again create a sub directory here with M.K. dear so let's create it type in M.K. dear and give it some 77 00:08:25,120 --> 00:08:34,090 long name in quotes like this is very long name note that if you give some long name to this directory 78 00:08:34,090 --> 00:08:36,190 you should put it in quotes. 79 00:08:36,260 --> 00:08:43,290 Now enter GCI and hit enter again and you'll see your new directory. 80 00:08:43,300 --> 00:08:51,550 Suppose we want to move into this director who would have to type as L and this long name. 81 00:08:51,550 --> 00:09:00,310 Not only will this take a while to tie but if we have got one letter from power shall won't be able 82 00:09:00,310 --> 00:09:01,900 to find our director. 83 00:09:02,230 --> 00:09:03,340 Instead try. 84 00:09:03,580 --> 00:09:12,430 Just type in a cell D and then hit the tab key and power shall complete the name of the director for 85 00:09:12,430 --> 00:09:20,590 you including the quotes you then tap for auto completion will save you a lot of time you'll notice 86 00:09:20,590 --> 00:09:29,240 that when power shell completed the name it also threw in a dot backslash at the beginning of the directory 87 00:09:29,250 --> 00:09:36,790 name the dot is just shorthand for the car and director when you type commands power shall. 88 00:09:36,790 --> 00:09:41,530 All this assumes there is a dot backslash at the beginning. 89 00:09:41,560 --> 00:09:48,490 In other words that you are referring to Sampson in the current director so you don't have to type this 90 00:09:48,490 --> 00:09:50,650 part all the time. 91 00:09:57,670 --> 00:10:04,780 If you want to find some specific command but don't know if this command exists at all you could use 92 00:10:05,080 --> 00:10:13,390 get command command led which is very important and you can try looking for a command with this command 93 00:10:13,400 --> 00:10:22,450 lat so get command itself will output all the commands which are available for you if you need some 94 00:10:22,450 --> 00:10:31,540 command which will be looking for a noun like process you could use get command the noun and specify 95 00:10:31,540 --> 00:10:39,430 the noun you're looking for for example process if you are looking for a command which contains a verb 96 00:10:39,730 --> 00:10:48,250 like start stop etc. You could try years and get command this verb and specify the warp you are looking 97 00:10:48,250 --> 00:10:56,440 for for example start if you're looking for some specific command which is part of some module which 98 00:10:56,440 --> 00:11:04,660 you know like power shall get or active directory module or some other module you could try using get 99 00:11:04,660 --> 00:11:13,080 command module power shall get that will find all the commands in that specific module and of course 100 00:11:13,080 --> 00:11:20,170 you could the standard with specified that you are looking for verb in that module like get commander's 101 00:11:20,170 --> 00:11:27,550 module power shall get and you are looking for a verb find in that module of course you can always look 102 00:11:27,550 --> 00:11:36,910 for help on that command with Get the hell command let and specify the command you need help on for 103 00:11:36,910 --> 00:11:47,410 example find this module get help have has several options like get help us on line get help desk fool 104 00:11:47,690 --> 00:11:56,730 etc. You could try type and get help find this module this fool or dash online or dash. 105 00:11:56,770 --> 00:12:03,130 Examples that will show you only the examples of usage of this command 106 00:12:10,530 --> 00:12:18,750 in addition to get an command led help for commands you can use get help to view supplemental help files 107 00:12:19,080 --> 00:12:27,270 that explain General Power shell concepts that focus primarily on script and to display the help file 108 00:12:27,270 --> 00:12:29,970 for a particular concept type. 109 00:12:29,970 --> 00:12:38,700 Get help about underscore followed by the concept name for example to view the help for the core power 110 00:12:38,700 --> 00:12:39,530 shell commands. 111 00:12:39,530 --> 00:12:40,830 Type the following. 112 00:12:40,830 --> 00:12:50,570 Get help about underscore core underscore commands or to view the entire list of conceptual help files 113 00:12:50,940 --> 00:12:52,610 using the following command. 114 00:12:52,740 --> 00:12:56,430 Get help about underscore asterisk. 115 00:12:56,460 --> 00:13:05,160 Now some words about command aliases throughout this course and the examples used will refer to command 116 00:13:05,160 --> 00:13:07,850 tell us or command letter aliases. 117 00:13:07,920 --> 00:13:16,470 For example the short name of the full command let the aliases can be very handy when trying to type 118 00:13:16,730 --> 00:13:24,290 long scripts where you might want to optimize and keep them as small as and as short as possible. 119 00:13:24,300 --> 00:13:27,990 For instance we have the command left where object. 120 00:13:27,990 --> 00:13:30,220 We have two aliases for it. 121 00:13:30,300 --> 00:13:36,120 You can use question mark for it or just wear it. 122 00:13:36,120 --> 00:13:39,290 Another example is for a rich object. 123 00:13:39,300 --> 00:13:42,300 There are two aliases for riot as well. 124 00:13:42,390 --> 00:13:48,690 You can use % character or just one word for reach. 125 00:13:48,690 --> 00:13:50,850 Another example is select object. 126 00:13:50,970 --> 00:13:59,720 You can use alias just select for release command lat and so on to get a list of all car until this 127 00:13:59,730 --> 00:14:00,910 is just type. 128 00:14:00,920 --> 00:14:02,420 Get Alice. 129 00:14:02,450 --> 00:14:04,950 Now some words about pipelines. 130 00:14:04,980 --> 00:14:12,530 The single most important concept in power Shell is the use of its flexible object based pipeline. 131 00:14:12,660 --> 00:14:15,580 The concept of pipelines is similar. 132 00:14:15,660 --> 00:14:20,450 Is that your sound and the output from one command to another. 133 00:14:20,550 --> 00:14:27,600 But instead of passing plaintext power shell works with objects and we can accomplish some very complex 134 00:14:27,600 --> 00:14:30,540 tasks in just a single line of code. 135 00:14:30,690 --> 00:14:39,210 As a quick example you can get all the services running on the server and pipe it to stop servers command 136 00:14:39,210 --> 00:14:41,340 let with just one line. 137 00:14:41,340 --> 00:14:45,360 You will find all the services and stop them of course. 138 00:14:45,360 --> 00:14:49,390 Don't try to perform this on production server. 139 00:14:49,410 --> 00:14:55,500 Now let's take a look at using a variable sound to objects which you'll be using very often. 140 00:14:55,500 --> 00:15:03,660 The variables are supposed to save temporal data to a new object so you can workers at later for example 141 00:15:03,660 --> 00:15:09,470 to create a variable that stores an instance of the test user mail books. 142 00:15:09,510 --> 00:15:17,420 You can type the following command do your character mailbox equals to get mail box test user. 143 00:15:17,580 --> 00:15:24,600 As you can see to create a variable or instance of an object you prefix the variable name with a dollar 144 00:15:24,600 --> 00:15:27,530 assigned to the right of the variable name. 145 00:15:27,600 --> 00:15:36,510 You have to use the equals assignment operator followed by the value of or the object that should be 146 00:15:36,510 --> 00:15:38,480 assigned to the variable. 147 00:15:38,490 --> 00:15:45,660 Keep in mind that the variables are only available during your current shell session and will be destroyed 148 00:15:45,690 --> 00:15:47,610 when you close the shell. 149 00:15:47,610 --> 00:15:56,060 And remember that you can work with variables in the same room as you work with any object containing 150 00:15:56,330 --> 00:15:59,090 its properties methods and so on.