Microsoft PowerShell
Microsoft Video Courses · 8 lessons · Free on YouTube
Getting Started with Microsoft PowerShell: 02 The pipeline: getting connected & extending the shell
About this course
[Music] [Music] so you’re ready to do a little help and help me out and add a little help help help because guys this is probably the
most important section of the entire day and it may not even seem like it at first but I swear to god this is the most important thing and here’s why it’s so important when you go to PowerShell
you’re going to stare at that console and go now what do I do yeah this is the answer so take your gold card called that the dizziness of freedom you look at that prompt and you
can do anything they’re like uh what do I do and that is that a lot of it affects all of us and a lot of us you know you get past that with what we’re going to do now yeah it’s a health
system but I think for a lot of folks I see it all the time it okay it made sense when you were doing it but now I’m staring at that console and I just don’t know what to do
yeah and I don’t know where to go and they create a solution for you this is a beautiful solution so what we’re going to start off with is looking at the help system showing you how to get it updated
this is actually a fascinating feature in v3 remember I saying you’re going to want to be using v3 and this is going to be one of them the most important thing is the discoverability that the help
system provides you basically it is your it is your Bing for PowerShell it is your it is it is answers all of your needs and all of your questions and also we’re going to show you how to read
syntax and so forth so let’s get started with the help stuff and here in about ten minutes we’ll take a break and then we’ll come back in and look at all the syntax and start getting into it so
first of all why you need help well I just want to go to bullet number two yeah exactly can we talk about this I don’t I’m a smart guy
but I’m not smart enough to just know everything absolutely so tell me what the idea here is yeah so one of my jokes although it’s actually true is that PowerShell is such a great product
because I’m such a deeply flawed human because it’s true a deeply flawed emulator and I was in a position to say hey let’s build a tool that helps me right so concretely you know I can’t
remember all that stuff either I’m a terrible typist etc so you’ll see there’s a ton of stuff in PowerShell that helps with those things so really is a goal to not be able to memorize
things actually there’s a great story they recently did a study of UNIX admins and came out with this report and I was really amused by this because basically about 25-30 years ago they had done
exactly the same study and produced exactly the same results and here’s what they did they took a bunch of beginner UNIX admins and expert UNIX admins and they
said hey here’s a test if you wanted to do this how do you do it a written test and what was interesting was that there we scored these there wasn’t very much of a difference between the expert in
UNIX admins and the beginning UNIX admins and so there’s like whoa why are we paying these experts so much money you know they can’t objectively they’re not that much better than just some
beginner right and so then suddenly said ok well now let’s put them in front of a machine and give them a set of tasks and what you saw was this huge difference in performance that the experts were able
to perform amazing things that the beginners struggled with and the conclusion was that what expert UNIX guys are great at is not knowing things but in figuring things out ok and so
that’s the deal this is not about you sitting there saying hey it should work this way right no no that’s not the deal the deal is hey let me figure out how to do things and so that’s what we’re it’s
all about what you’re going to learn is a schema right you’re going to learn a set of things you’re going to learn how to learn and then you’re going to use those techniques over and over again and
that’s why once you learn how to use PowerShell and you’re managing say exchange then when someone says oh we got this linked server it’s like well let me have at it and you’ll be able to
go and you’ll be able to learn and learn and learn and just figure stuff out so basically what you’re telling me is is that the first time I walked up to a UNIX guy and I said hey how did you do
that and he turned around and usually barked mara barked at me going RTFM yeah he was actually trying to educate me he wasn’t just being a terrible person no both okay you feel
about that I think and this is really the moral of the story is you’re not gonna be able to memorize stuff guys Amy you know powershell v ii had like 236 core Commandments
okay i might be able to memorize those but here’s the deal when you start working with products you know exchange has depending on your version of exchange has between 535 and 600 10
commandments you got five hundred and some-odd commandments for sharepoint you’ve got a hundred and some-odd commandments for Active Directory in Server 2012 you have thousands of
commandlets yeah thousand yeah there’s no way to memorize them so what they did is they created a help system now before you go oh no other help says yeah because I know if you and I’m not okay
maybe I am if you’ve used the help system in in a particular product before and I’ve found it unuseful well just remember it wasn’t spent a lot of time on this was spent a lot of time on by
people who wanted you to be successful knew that the only way that you’re going to be successful is to have a great help system we all of us use this every single day and I want to point out it is
Jeffrey insane it’s about using the help system reading and comprehending it and then figuring it out where IT pros that’s what we do we figure things out this is actually fun
when you get start working with it but one of the challenges that we have is the RTFM side I mean as a 19 Pro one of the reasons I got into ITT is because I was really good at sitting down into the
computer and just figuring it out I didn’t have to read the manual well that’s not going to work here we’re going to have to use and read and comprehend the manual and they’ve made
it really easy for us so let’s start doing a little get help stop first of all and guys some of this stuff is in the slides and so we’re just going to demonstrate it first of all let’s talk
about update help versus the way that we used to have it yeah okay so we used to ship the help with the product and turned out that that was there were all sorts of problems with that so basically
the way Microsoft works because we ship to hundreds of millions of people right it really matters that the releases button top right which is to say that you stop
changing things and then you test and you test and you test and you test and then you release it so what ended up happening was that just as soon as you’re like finishing putting the
finishing bits on the code the documentation has to be done and and of course that doesn’t work but now it’s cooked like you hate don’t change it because you might break something so
then it gets shipped and the documentation there’s differences between the documentation and the and the product and the answer used to be well you know hey just hang in there
you’ll release again in three years and we’ll fix that well that’s kind of a crummy answer and then there was a second problem the second problem is guess what the help is huge right
because there’s a ton of it and then would you say well geez I’m now go into a cloud world where I’ve got a gazillion machines to get a gazillion servers what one set to use those be as efficient as
possible with those servers and you don’t need the help on all those servers right you need to help on the machine you’re managing them from and to put the help on all those systems is just
loading down those servers with stuff that you’re not going to use so because of those two problems in Windows are certain PowerShell version 3 we move to an updatable help model which is to say
we ship and there’s some very kind of like structural help they can generate based on metadata you’ll see some examples of that but then all the help text is available from download from
from the internet so that’s the way that works and and let me just say that in v2 one of the challenges was if you’re using a health system and there’s an example in there there was a possibility
you know that maybe that example was wrong and I’ll show you a way around that if you’re in v2 to get the latest information for it but really the joy here with v3 is is as soon as Microsoft
updates to help or they find an issue my help gets updated on my management station so the first thing that we’re going to do and then we’re going to take a break here enjoy know can I give an
example yeah so have you ever use wql yeah okay right so I can never remember WQ I just can’t it’s one of those things once there’s certain things that just never sink in for me wql is one of them
and so constantly whatever I want to use that I’d have to do search and there’s something about the search con and I can never find it on the internet either right and so at some point
somebody had this exactly the same problem so they went and on Microsoft Kinect and said you had having that bio topic for four wql and guess what they went and wrote one and so now we have an
about wql and it’s just their point was you didn’t have to wait for another release you had a problem you told us about your problem and we responded and then in a matter of like well forget how
long that one took but there was one where somebody complained about an error in the documentation two days later we had an update so this pretty pretty peppy it’s continuous publishing and so
what you want to make sure that you’re doing is you’re updating help and let me show you how to do that first of all you’re going to need an internet connection now there is a way around
that but let’s just start off with the basic update health care and so we’ve got a commandment for that called update as update get it – what would you have hello an update yeah what do you want to
update the health so the verb the noun so that’s working out and I like to use – for some guys this is something that you can run every single day to make sure you have the latest and greatest
health and what it’s going to do it’s going to go out to the Internet and it’s going to download all of the help files that you need for all of the stuff that you have on your system see a progress
bar says ooh which is what it should say in PowerShell whew so cool now look if you have a serious budget machines that don’t have direct access to the Internet you can save this help with save help ah
you can save this help and turn it out as a set of files and then you can update from that set of files but having the internet connection sure does make your life a lot easier now here’s the
idea we’re going to take a break here and so what we want to do is make sure that you’ve got a PowerShell console up and make sure that you’ve updated help because when we come back we’re going to
start using my favorite things and let me just show them to you real quick get – help which yep that’s going to get its help on stuff but it’s also going to help us
search for stuff and so that’s a guest important thing before though we go I want to show you there’s a difference you’re going to see people use get – help you’re going to see people use help
and you can see people use man and I want to show you that there’s a it’s between these two get – up and I’m just going to pick a commandment what I’m going to do is I’m going to keep
things real simple right now and I want you to notice my screen it scrolled all the way to the bottom now this is not a complete help file but we’ll get to that after break but I want you to notice it
scrolled all the way down to the bottom now watch the difference between using help on the same thing look at the bottom of the screen see I’ve got that little more so I can
and you probably heard that I can spacebar now and and move through the help file man does the same thing so man and I’ll do get serviced gives you that same you know like you put two more kind
of deal where you can pound your way through it use whichever one makes you happiest and probably today you should experiment I know I’ve got friends that are just help
I always only use help I happen to be a get – help kind of guy cuz I like it to scroll to the bottom of the screen the help system is a super discoverable great tool to help me find things and
and let’s do a couple of examples I’ll start off and you can join in Google this is this is going to be really awesome because and don’t memorize or write down anything that we do yep swear
to God don’t do it because that’s kind of the whole point so let me give you an example first of all health is the ability to discover stuff and I’m going to imma get help get – health kind of
guy so I’m going to use get – help and I want to find out here’s here’s Mike here’s Mike I want to see if there’s any commandment that can help me work with services so I’m going to do star service
star yeah boy a star is your friend’s star is a wild-card and says find anything at the beginning or find anything at the end match anything at the beginning rent yeah and make sure
that when you mean wildcards you use a wild-card because some Commandments will let you not use the wild-card and that’s not a good practice to get into so oh my gosh look at all of these Commandments
so many Commandments that have service in them whoa but now is where the fun begins look is there a commandment that in this list that looks like it might retrieve or I don’t know get
a list of services on my computer so yeah there happens to be one right here so you get – service it would probably get me a list of services it would only affair oh oh you should about it when we
is yes you can just use the up-arrow now watch us now use the right arrow blip right left arrow left arrow and put a G in front of the star check this out now do it
Oh short list these wild cards are great as the wild cards are great and actually knowing how to do a good search isn’t really give us notice straight is great so here’s the idea and we’re going to do
this a couple times the idea is you search for and probably by noun you search for the thing that you want to find I want to know something about processes or I want to know something
about services which are the examples I’m going to use a lot but it could be as simple as 80 computers or something like that and you search for what you want and when you find it while there’s
a help file for it so let’s go in and take a look I’m going to get help get – service now this is the simple view as a help file and let me just show this to you real quick it’s usually the name
synopsis syntax which we’re going to talk about here shortly gives you a description of what the camila does and some related links and information now this is not the full
help so don’t panic we’re going to do the full help but let’s try this discovery thing again I want to do let’s see get help and I want to find something that would oh and I’m going to
use your trick I’m going to say that would G star something with a B computer in it because I want to I want to work with Active Directory computers oh look there’s there’s a clan there get a D
computer you know what I’m thinking I’m thinking in my head that’s probably going to solve my problem but to be sure what I’m going to do is do get help get a D computer and take a look at it
and again this is the simple health view and we’ll get to a better ones here in just a second but so the concept is pretty simple what you want to do is you want to discover what you want to work
with and then look at the help for what you want to work with now the concept is simple but doing this seems to be loved a big challenge for a lot of folks you have to become trusting
in that this is how we do it and this actually works no matter what product you’re working with think of what is it that you want to do something to what what’s the noun that you want to find
and then have help search for it it sounds like a great way to get help to work for it yeah we very much tried to create a world where you could think about what you want type it and get it
okay so let’s just say you wanted to assign something well you look for a sign you wouldn’t find that and you’d then quickly learn that we use the word set
and so you’d say well okay so there’s an infinite number of nouns but the verbs are pretty regular so imagine you won to get the help on the verbs like yeah dude type you type it’s go ahead okay so what
you do is you’d say you take GATT verb and shows you all the verbs and so these are all the verbs that you’re going to learn and you see well how many are there so you might want to say well I’d
get the verb I’d like to measure them and you see that there are 98 verbs and here you see we break them up into into you know whether their security verbs or
communication verbs etc anyway so those you learn those 98 things and then and then you’re going to be able to think type and get what you want and what what happens often is you’re not even going
to learn all ninety eighty dollars you’re just going to learn a few of them because you’ll know that what the verbs will do for you and you end up looking for the noun so it becomes a very easy
process to follow through now let’s start getting into what this help can do for us so once again I’m going to do this get help I want to find Commandments
that’ll retrieve me some services now notice well there’s get service and so I want to take a look at what this can do for me so I’m going to do get help and get service again this is a simplified
help view but there’s more to help than just this once you’ve updated help this help can be extended or expanded upon and let me show you a couple of things this is where it gets a little just so
happy for me because watch I’m going to do get help on get service but we have a parameter that will allow us to get detailed detailed health and here’s what detailed help is going
to show us I’m going to scroll all the way back to the top and get service gives you the synopsis again the syntax which we’re going to talk about in a second and the description this is what
we saw before but here’s this when we talk about syntax we’re going to start talking about what these things are parameters these parameters change how the Commandant acts well I don’t
necessarily know what these things mean well when you go to detail help look the parameters are listed here with an explanation of what they mean and so what you’ll do is you’ll actually be up
here looking on I have no idea what that is and then you can just scroll down and get a definition of the parameters also as I scroll down here I want you to notice something really interesting now
we start to get examples now I want you to think about this for a second I’ve got a commandment called get – service so let’s think about what it’s probably going to do I ever run it yet it’s good
probably going to give me and if I read the description a list of all of the services on my computer whether they’re running soft or cost and it’ll tell me about that how many examples of that do
you really think we need well we need eleven of them and here’s here’s why I want to point this out we apparently we need eleven examples of this and there’s a reason for this because the people
that work so hard on these help files knew that there were going to be all kinds of different ways that you’re going to want to try to use this may wanted to give you examples what happens
is this is oftentimes you’ll be thinking of a business problem we’re trying to solve a business from and you’ll say gee whiz let me go I found the command let me go look at the example you’ll find an
example that is really close to probably exactly what you wanted to do which is one of the cool things so a big shout out to all the folks that work on you know the other thing we did was there
are a few of the ones we knew people were going to use a lot like get process boy you always want to spend time looking to get process because they are what we did was we said hey get process
get service people are going to use these a lot and so in our help and our examples we show you not just how to use get process and get service but we also show you some very common PowerShell
techniques that then help you you can lead you to the net step you start off saying oh I’d like to get something get services what we’re going to do and then you say well geez
actually I’d like to format it a little differently or I’d like to find these things filter and so we use those two high-volume topics to kind of go a little bit deeper to teach you the next
level of PowerShell which is you’re going to as we take you through learning all of this deep level part of PowerShell you’re going to look at these help files in a totally new way and
you’ll see that examples of sorting and filtering and getting the kinds of information that you want and changing the kinds of information you want a lot of times writing the examples a lot of
people the first thing they do is they go to examples as a matter of fact there is rather than detailed you have a parameter called example that will take
you right into just the examples if you want to get there real quick something else that you can do and this is going to become a big deal this afternoon as we work through this
there’s also full help I don’t know Jeffrey I don’t know if they can handle the full help I’m yeah that’s that’s an awful lot of stress test exactly here we go full help
well seatbelt on your seatbelt on full help guys I’m going to you right now the full help is very similar to detailed except when you’re in the parameters there’s some special information and
this is going to make in the next section we’re going to talk about what this information means to you it’s actually very important to us and this will help us understand how the commands
work in the pipeline and so we’re going to talk about that stuff in a little bit so right now when you’re running get help you can use detailed or you can use examples but a little bit later on
you’ll always end up using full now I want to promise you earlier that for the you folks that are running PowerShell v2 and even if you’re running v3 sometimes if you’re running b2 your help files
they’re not up to date and you want the latest that I need the latest and greatest information well you can’t run an update help if you’re in v2 which is why on your admin box you should be
running v3 however let me just show you this is how we used to get around that Microsoft helped us with this – online I love this – online look at what it just did
takes me opens up a browser and takes me out look updated shows you when it was last updated and here the full help for whatever it is that I was looking for in this case gets
serviced so again don’t close that I’ll lose the chat – online now I mention my favorite react to the Eid I hope you do know this I think if you played this at first but go ahead by what well yeah
I’ll show you you go okay so it’s up to mine so here would you get get help Oh get service so here’s the thing you can say examples right examples and they say oh that’s cool let’s let’s let’s run
this let’s let’s let’s let’s let’s do one of these okay and type that and by the way so you do you do enter and then left mouse button and okay great now you want to do the next one oh well
so you see is the workflows all messed up so what you can do is you can say get help – show show window and look here comes up in a window okay now this has all
sorts of great stuff one of these is settings and you say hey I want to just see I want to see all this stuff I just want to see the examples look at all the stuff you can have control over it’s
amazing because now you just go here cut paste sort of paste and do that and then the next one cut paste and so it’s a very nice workflow much nicer workflow you know again that is this this show
window and you’ll see there’s some really fun stuff with show window catchments more time absolutely okay so now let’s turn all this back on there okay so you see it’s got lots of stuff
here okay so now in the show window you can do things like memorize what is it that well anyway you got to find here right so you can find stuff like the pen
dent and okay and so notice it gets highlighted and says here says who 18 matches okay and and it gets searched enough I don’t do that very well anyways then you can start searching for these
things and so it’s super nice I and I think the addition of this this was added to v3 and I think the addition of this is really phenomenal because guys let me show you traditionally you’re
going to spend so much time in the help file and you’re going to want to do just that you’re going to want to cut and paste from a help file or you’re going to want to read a help file while you’re
working in PowerShell that a lot of times when a lot of guys would do is if you take a look at my screen I’m going to well yeah I’m just going to launch to PowerShell sessions now if you have two
monitors this is great right so you do help in one and then you can work in another one but would be three having the show window stuff well first of all it fits better on your screen it’s
easier to move around you can have the help it’s easier to get stuff at the part that always confuses me is and then we’re going to fix this later when we start talking about the magical ISE but
it’s the cut in the pace man it’s that whole yeah is that right clicking and stuff in the console why can’t we fix that why can’t we fix that why can’t we fix that console because it’s horrible
yes so it really give you a little tutorial about some of the behind the scenes stuff at Microsoft so there was some point where people said oh you know
Microsoft stopped advancing ie you know oh that just proves what bad guys they are there’s no competition they stopped innovating no no no my friends honestly that now what happened what happened was
was that it got to the point where every time we made a change we broke a bunch of people right right and so there’s like well people like hey jerk stop pranking us and so and so they
stopped doing that and then all sudden some competitors got up there and so now they went and started doing things even though sometimes thanks brake same thing happens with the
console window the console window man every time you change that thing you break tons of people you break tons of them and so you don’t want to change that thing very much now here’s the
thing actually I’m pretty hostile to the console window okay so that’s it I’m trying to make this thing die I’ll just be straight up about it make it why die and why is that and the answer is that
there are these things called console apps okay now a console app only works in the console now here’s why I want to kill the console because I want to kill console apps and it turns out that the
reason I want to kill console apps is you go and you write you do something on the console app and it writes directly onto the console which means you cannot automate it okay
you can’t run something get its output process the output and do something with it because it writes directly on the screen so this is just evil incarnate it is the enemy of automation so we’re
trying to get rid of those things so we’re trying to get everybody on to PowerShell ISE which is a much richer investment so by the way stop asking me to fix the console and I gotta fix like
at all and that’s the point that I want is that the console and look I know cut and pasting in the console and some guys ago the console is driving me nuts a little bit later on today we’re going to
help you with well he hates it and so there’s actually a really cool solution to it but I want you to wait till we get there with the ISE so to cut and paste in the console is if you haven’t done it
yeah it’s you highlight it you right-click and then you can right-click again so no ctrl C no ctrl V in this puppy I think we may have something cooler for you later on but right now
that’s how you do it so right click and right click will take care of it for you Geoffrey you know what we need to do we need to start to take a look at and explaining syntax because yeah here’s
the thing everybody wants to work with commandment but you know commandment is going to do great stuff for you but sometimes you want to command it to alter its output or change what it’s
actually doing for you you know get service is great but it’s going to give you a list of all your services I maybe I just want the one called bits or something like that so
the syntax of the command will explain to you the options that you have available to control the command and so at first it looks very very confusing now we’ve got slides for this and so
it’s all in the slide deck but let’s take a look here I’ve got get service up right now and I’m going to take a look at something pretty subtle you if you do this in show and oh it comes out better
you like it show Lindo back yeah because watch do it don’t you okay done let’s do show window see cuz one you get the zoom there at the bottom did you know that oh oh that’s it and so that I
think is that it highlights some things so it’s a little I think very easy and it’s easier to select and say ok so we’re going to use we’re going to use different step this is much better so
take a look at this right here see the thing with a dash in front of it so you’ll notice that I’ve got a command lit and then it starts followed by all of this magical characters we’re going
explain what all these characters are but the first thing I want you to notice is look how many times under syntax I see the name of this commandment I see it three times now Jeffery technically
this is called parameter sets but rameters that what why am I seeing three of these yes so here’s the thing imagine take a look at the net command right there’s net use and net view etc these
are different parameter sets and what happens is when you type net view you get one set of functionality when you type net use you get a different set of functionality so what happens is that
that then they reuse the word the command net now that’s essentially what a parameter set is now we take a different take on it net use is extremely different functionality than
net use okay so we don’t like that we want to be clear but the point about gets service is that there are different parameter sets sometimes you want to say get service based upon its name or
you’re going to say I want to get service based upon its display name okay so those are two different parameter sets or a better example would be get process sometimes you want to say get
process whose name is this sometimes you want to say get process whose ID yes or sometimes you’re going to just say get process and get them all and get them all yes there looks a different
parameter set and let me show you what Jerry’s Tana is notice in these three different get services and yet don’t worry we’ll take a look at get process to in these three different get services
look at this one this one has – name down here in these other two you don’t see – name this one has – display name you don’t see that in the other two so that’s what makes that particular
parameter set unique and in fact I’m going to demonstrate these here in just a second but again look at these dashes these dashes indicate that their parameters – its parameters parameters
will allow you to change the results of what the command is going to do and I want to do an example for you let’s take a look at – name I want you to notice it’s followed by these characters here I
just kind of go like this culture who is or something like this Shailaja hood that nuts the technical term is that many people knew that I I didn’t realize that you the official technical term now
is – who is Luis and what this is is this is the kind of values that you can give did we’re giving into trouble with HR on that one really okay D Ziggler well note it is like pac-man pac-man so
these can eat can beat now these are the values that you can give to the parameter and I’m going to show you so let me let me give you a quick example here let me lower this well I’m not
going to lower it down I’ll just do it here watch I’m going to do get service and I’m going to use one of the parameters now parameters always begin with a – so make sure you always put a –
from the parameters and now I’m going to put in a value that would be inside those chuckleheads and it said that the value type of string which means often numeric and I’m going to put in the name
which is a short name of a service I’m going to do bits instead of getting the entire service list this parameter now is going to allow me to just get the service that I want so here’s the idea
parameters can have these arguments on them and a lot of parameters can take multiple arguments let me show you what that look like let’s say I wanted to services notice the comma in between now
the space is optional but to put a space there makes it easier to read now I get those too let me show you how that looks in the syntax and so let’s go back here notice up here at – name
that’s the parameter then we have the jello hose with the type of data that we can put in there the value type see these guys inside these guys and they got a big doing close together because
we’ve got these guys and we’ve got these guys who is what are these so jululu is I just call them banking’s because there ain’t ya so you’ve got your hula hula and inside the children who is you have
these binky’s if you see binky’s in there that means it can take multiple values separated by a comma now I’ll show you some stuff later where you won’t see the internal banking and so in
it boy there’s going to be a whole phrase book now and so it can only take one value this is very important for you to be able to know but here’s the part where it starts to get a little
confusing let me do a little demonstration here of – name with multiple values which I just did but let me show you something else this isn’t the confusing part I’m going to ask
Jeffrey about this confusing part again you can do wildcards so – name beasts armies I’m going to get all the services listed that begin with B okay there’s no conflict between wildcards and arrays or
collections so do this do that up arrow now do now comma C star oh yeah this is all gathered three-point and a great point so now I get both the ones to begin with B’s and with C’s and C
that’s awesome that’s totally awesome so oh I closed my show window so let me go up here and open up the show window here’s the part where I start getting kind of confused here and it just
originally kind of threw me off is I want you guys to notice this guy down here computer name and I want you to notice what’s around computer name see these brackets that surround both the
parameter and the argument there so it’s not the internal binky’s inside that yahoo is it’s these things that surround either the parameter or the parameter and it’s argument this means you don’t
have to use it it’s optional but wait we’re not done yet a great example is take a look at this first syntax the syntax up here notice that everything has these around
it which means that there’s nothing actually required that I type in notice I’ve got them around here got them around here and every single one of them optional
that means all I need to do or all they have to do is type get service and it gives me a whole list in other words no parameters were required but take a look at this inside the syntax look at this
second syntax I want you to notice look at this guy down here see how the splaining doesn’t have these around it well that means if you’re going to use display name you’ve got to put it in and
then you’ve got to give me a value for it now here’s an example display name by the way is the long name so it’s this really long name and I can get services by that display name but I want you to
notice that you’ve got a choice – name or – display name so get service – display name and now I can type in whatever long lengthy and I’m just making it up display name that I want to
type in but if you’re going to use display name now you have to use display name and the value that goes with it that’s what get you into that other syntax let’s do something else let’s
just stop why even book you yeah so here’s the thing so imagine you want to get like do a get service be star just be star feet b.o.b starting point okay so look at the name for BitLocker Drive
Encryption service be de sv now remember we said oh well you want to create a world where you think about what you want you type it you get it how many of you are thinking oh I want to get the BD
yes vc service right like wow so no you want BitLocker okay so then you want to say okay we’ll get service month display bit no you can type BitLocker it’s BitLocker Drive Encryption service so
what so remember how I show is great because I’m flawed I can’t remember be de as VC and I’m definitely not going to remember BitLocker Drive Encryption service and look even if I could
remember it I can guarantee you I can that I’m like incapable of typing that correctly so what you do is you type display name bit star no just bill just bit star yeah did start something to do
with BitLocker yeah I do miss it doesn’t work it got us by the long name which actually makes more human sense than those little tiny short names see was one of the things we said was with
PowerShell it’s like programming with with hand grenades versus like a rifle you know it just sort of just sort of like over there not if I ever told you that story
my buddy I college I I uh my roommate used to be in Vietnam he was Vietnam eighteen Special Forces and not actually a guy I worked with he was a Navy SEAL and the Navy SEALs get their own weapons
right so everybody else like your this kind of guy you get this kind of weapon the Navy SEALs like the the gun manufactures would make them guns and he talked about this thing I never quite
got it in focus but it’s basically sort of like a machine gun shotgun a machine shotgun he said and the great thing about that was is in Vietnam you had the the jungle and you certainly had to know
what like was my problem over there or over there and you set up with this thing and he says you let loose with it and three seconds later your problem was gone or
everything between you and your problems we’re gone okay today’s problem that’s the same sort of thing you just sort of like hey BitLocker is something to do with BitLocker bit star star so that’s
the kind of the model we’re trying to go for is you just start over here or start over there now there are times when you need to be precise and you can be precise and there are times where it’s
just sort of like over there is good enough and by way when you need both you’ll see how we deal with that through something called – what if and – confirm yeah yeah
yeah and so and Jeffrey what I need you to help me with is this is the this is the one that seems to throw most people off so a – don’tdon’t means that you have a parameter and if it’s followed by
– who-who is that means you can put arguments on it and you get the value type of the argument string and that kind of thing and if it’s got bang keys in there you can take multiple arguments
separated by a comic see plenty of examples of us doing that and if you’re surrounded by these brackets I don’t have the optional you don’t have to do it at all but there’s
something tricky here in this view yeah let’s look at this guy look at this – name this guy throws everybody off so I don’t have to type this in I don’t type anything in because we all know that I
can just run get serviced and get all of them but if I’m using – name and I want to specify a name of a service like this what is it with these little booters inside here yeah this is something
called positional parameters okay and so that means that if you just specify the value you don’t have to specify – name so so this makes so watch get service I can do this you might be saying I got a
type a lot actually you don’t have to type a lot but here’s what positional means if you’re going to give me a bunch of names of services you don’t have to use – name see works the same way which
means so those brackets around the parameters simply mean you don’t have to use the parameter but you got to give me the argument that’s what makes it oh and it gets even better because now you can
just type gsv oh yeah you can use the alias to even it up even for so oddly sorry you want to go ahead and render this g sv fitbit and so here’s kind of a key kind of principle of PowerShell okay
the principle is we want to have this very regular very self describing surface okay so when it’s three o’clock in the morning and things didn’t go the way you want to and during some IT
upgrade you bring up son described you want that script to be absolutely readable you want to know what’s going on okay and so that’s why PowerShell is very clear you
know get that service that’s name etc so when you’re reading it you know exactly what’s going on on the other hand when you’re interactive you can type that if you want and we make it easier to type
that with things like tap completion but sometimes you just want to go go go go go and so we have all these shortcuts and aliases so that you can be very very productive as a high speed advanced
interactive user but then when you go and write scripts we encourage the more verbose style as a matter of fact let’s just to emphasize on that a little bit further so when you’re writing scripts
this is the way that you’re going to want to do it here in the top example you’re going to want to be very explanatory of what you’re doing but as Geoffrey was saying when your console
free rein I mean if you can use aliases and shorten this up with the positional parameters so that you can quickly get things done you’re going to see examples of that today because Geoffrey uses an
awful lot of aliases and I usually because I’m getting ready to automate it sometimes I just do the whole thing the first time through where I use all the parameters and all the arguments so you
can see that contrast between working quickly interactively with the short you know short versions and then the long versions that you’re going to want to see in a script but let me give
you a hint and then we’ll do another example and then take a look at how to work with all of this and you guys been hitting the tab key you take your pinkie take a pinkie if you’re a touch typist
this is this is probably not for you but this pinkie he’s showing you the official flexing oh yeah yeah you want to make more master I want to warm it up at graduating of every day Gretchen
stretch the pinkie and you want this pinkie to hover right over the tab key always because what you want to do is watch get se I’m going to start you in a techie look start going through the
commands we got so many Commandments now it’s a lot of them to go through there we go wait a minute shift cam goes backwards watch – I’m gonna hit the tab key it’ll cycle through the parameters
for me just oh this is cool remember I said we make it easier to help type this stuff out that’s where I’m at so look in just about as the keystrokes is doing like gsv bit
just a couple more and I can bang this out and get it to look really nice and clean so that if I’m going to use this in the script so the tab key is your friend use the tab you’re going to see
is use it all the time today let me show you another example of finding something as kind of a summary here of finding a commandment and then taking a look at its syntax and then
we’re going to show you how to start to put commands together on the pipeline so let’s do this I have this business problem business problem time and my business problem is I need to get I need
some errors I need to loop it I need the newest errors the newest five errors out of my system log oh yeah so I need to be able to look at my event alive Bob yeah the log files so I’m thinking I
need to look at my event logs I wonder if PowerShell has a command luyt that can help me with my event logs so get help star policy do you have anything with the event logs Oh and lo and behold
there are plenty as a matter of fact this is great time now you can take a look at the verbs you can just guess what what do you think clear event logs going to do wouldn’t it would clear it
III I bet it would clear it to you know what do you think get event log is going to do tada it’s going to I know it seems ridiculous but this is the point is you’re looking
at the verbs and figuring out what they’re going to do and it’s not that difficult at this point now what we’re going to do is I want to get an event log now I can just try to run this but I
want to take a look at the help file first so I’m going to do get help on get event log and I want to take a look at the syntax and I also if I have questions about the parameters I want to
be able to see the definitions of those parameters so I’m going to do – detailed right now and I’m going to go up here and go hey here’s get event log take a look at the syntax look get event log
look at all of these parameters see the dashes see the arguments that they can have whether they can have multiple values and if you don’t know what something is like hmm I wonder what
newest means you can scroll down and you can take a look down here and the read I’m going through this is this is what we all have end up doing is I don’t know necessarily what all the parameters mean
so a lot of times I go to the list and I read the list of parameters first just to find out what capabilities I have I know that seems like an make take a few extra minutes but it’s worth it because
I found that newest means I can get the newest entries in the log but to also take a look at something else in this syntax looks where to go look at all of the things that are optional
but I want you to notice something looking up here I want you to notice that – long name isn’t required but this guy is I want you to see what happens when something is mandatory and you try
to run it so if I just tried to run get event log I want you to think about this if this works just like this think about all of it it’s going to go through all the logs and spit all of the logs out
onto my screen could that be a little performance issue especially if you’re doing it to 50 machines at once that’s now called big data big database so watch I’m going to strike enter and
PowerShell smart let’s go hey look you need to know what log you want to look in so we’re going to make you tell us what log so I’m going to say system now of course it’s now going to give me the
entire system log but let me just show you by using the help file looking at the examples reading the parameters you can start to make solutions like this get event log I know once a log name I
want the log name system I also know that I want say the newer thinking attack complete that – I think you can now – yeah wait let’s try it didn’t used to be able to do that let’s see oh look
it’s that cool that is totally cool I just said a lot in v3 that you can now tab complete on a lot of the things the system has okay another reason you should be using v3 yeah yeah right
that’s a v3 ism not on v2 ism yeah so I know that by looking at the help file the newest will let me get the newest I’m just going to say three entries but here’s the thing you guys know this in
our log file there’s a lot of that information stuff and I don’t want that just so happens if you look at the help file you find an entry type error that’s going to
give me the three latest errors now you might be thinking yourself well that’s not you know that’s cool but you know I had to do a lot of reading I could have just opened up you know the graphical
for this oh yeah but watch this thing is this is a parameter near called computer name I want the latest three errors from three different computers um here’s the thing I you need to kind of get from all
of this you can’t open the graphical fast enough more or less get that data that quick so in this one command that I figured out I can get errors from multiple computers all on my display now
it’s on my display and we’re going to fix that here in this next section because maybe I don’t want it on my display maybe I want it I don’t know in a web page or a CSV or something like
that but they miss the look show that again ooh I tried to give a go so so I’ve used a HelpOut to build one great command and now we want to start doing more with it so kind of wrap this up
here I’ve got some slides in here and like I said everything that we’ve been doing is in the slide deck so let me just kind of thumb through here the slides again crunchy leaves something
crucial good yeah what are we like to go back to it the wild card help interactive right would you always good work yes sir – but he said get help help start event log ok and point it out oh
look here you got clear you got get limit but look here about I forgot I’ll talk about the about house and though this is like one of the most important things just about event logs okay so
these are what we call conceptual topics okay so you say okay clear screen and then bowi here’s a trick I do right so if I did clear screen here thing so now I want to see this if I do clear screen
and then what that I was going to do oh shoot coach right because again I’m flawed right right we got about something okay so here so what you do is you do clear
screen and then semicolon semicolon is able to statement separator that says do this and then do something else so it’s a way to do two things at once then we say get well let’s just say help about
event walk by Wade tapper turn your grant logs so then it clears the screen and shows me the bout and so here notice it gives me a short description describes things viewing the
event logs goes through the discussion about the topic tells you about the commands etc so there’s quite a bit here and then clear screen if you just say help about underscore the star yeah
that’s there you go you’ll see lots of about topics I mean look at them there’s a and there’s just a ton of really good stuff here like wild cards hate about wild card about
wild cards about PowerShell version four guess which one I’m using about the ISC about WMI and there’s the one I mentioned remember remember about wql yeah so so I got to tell you this is one
of the best investments you can make is to go and do this help about and spend some time reading them I mean there’s really good great stuff there yeah and I think I think the important side of this
is that there’s actually two health systems the help the help will help you discover out of both of them you’ve got help system for the commandments and then you have this about underscore
health system which is Jeffrey just said is a conceptual stuff as we go through today we’re going to be pointing out oh yeah you need more information go to the about underscore blah blah blah blah and
all know there’s more information in it there’s one that what’s more than that oh so you don’t know about category category yeah so get help – category and here here’s a trick right
so you say um I know that category takes some value but I don’t know what value it is right and so sometimes we have to have completions sometimes you don’t here’s what I have to do I just like
give a bad value and then often what I’ll do is it’ll tell you if you deal with categories the argument blah blah blah does know not belong to the set and it tells you
the set of things that you can type also you can get specifically for like the providers was very bad about and I’ll tell you here we did this and set this up and we had quite ambitious things for
the help subsystem and we haven’t fully implemented all of them some of our partners have been prevented some of them but we didn’t like we were going to have fa Q’s and glossary terms so so if
you say it help FAQ it’s not there okay like to get around to that but in particular notice here it says where the provider right so you can do is you can say goodbye we tab works and tells you
oh look here are the various providers now we’re going to talk about this topic later but if you did that and you said Oh get help certificate certificate so TIFF TIFF
TIFF to it okay it give you information about a provider and when we get to the topic about providers this will make more sense but it’s a very very rich helpless yeah very rich help system
[Music]
THERE IS ALWAYS MORE