PowerShell For Beginners Full Course | PowerShell Beginner tutorial Full Course — Transcript
Full transcript
- 0:08[Music]
- 0:18good morning and welcome to the
- 0:19microsoft virtual academy and this is a
- 0:21special virtual academy jump start
- 0:23of getting started with the best one
- 0:25it's going to be the best one ever of
- 0:27getting started with powershell whether
- 0:28you're an it pro or even a dev
- 0:30this is the strongest most powerful
- 0:32management tool you have in your arsenal
- 0:34to take control of your network and
- 0:36we're going to take you through today
- 0:37step by step
- 0:38and when i say we well it's a very
- 0:41special training event today
- 0:42i'm jason helmick but this is the
- 0:45inventor of powershell
- 0:47distinguished engineer jeffrey snowberry
- 0:51and this is going to be a great event
- 0:52for for all of us today
- 0:54we're going to take you through step by
- 0:55step on how to get started and working
- 0:57with powershell
- 0:58and who better to learn it from than
- 1:00jeffrey snover so
- 1:01i'll tell you what jeffrey let's let's
- 1:03start out with some intro since there
- 1:04i'll flip the little slide thing in okay
- 1:07yeah so howdy i'm jeffrey snover um i'm
- 1:09a distinguished
- 1:10engineer and uh let's see so i you know
- 1:13start off the powershell team about 12
- 1:15years ago maybe a little bit more um and
- 1:19that worked out pretty well because
- 1:20after having shipped a couple versions
- 1:22they
- 1:22made me a distinguished engineer and
- 1:24then the lead architect for
- 1:26windows server 2012. awesome
- 1:29that worked out pretty well so now i'm
- 1:30the lead architect for windows server
- 1:33and system center data center products
- 1:34so
- 1:36having some fun oh boy having a lot of
- 1:38fun and with powershell and what we're
- 1:40going to talk about the windows
- 1:40management framework
- 1:41all of this bundled together not just in
- 1:44server 2012 but it works
- 1:45all the way backwards to 2003 so that we
- 1:48can
- 1:49we can do all of this management with
- 1:50everything that we have in our
- 1:51environment not just necessarily the
- 1:53latest and greatest that's the plan
- 1:55back to filling up your arsenal i like
- 1:57that term i like that term too
- 1:58that's turning out pretty good so let me
- 2:00tell you a little bit about myself
- 2:02i'm jason helmick i work with
- 2:04concentrated technologies i
- 2:06do this for a living i love to train i
- 2:07do powershell and i also work as an
- 2:09engineer and a consultant
- 2:11mainly doing a lot of automation with it
- 2:13uh author of a new book that's coming
- 2:15out
- 2:16learn windows iis in a month of lunch is
- 2:20tough title to say uh and it's not only
- 2:23about learning iis but it's
- 2:25using powershell for it so yeah just
- 2:27some uh interesting little tidbits about
- 2:29me
- 2:30truly what the best thing to know about
- 2:31me is i get to sit next to him
- 2:34so as we do this so this is gonna be a
- 2:36lot of fun
- 2:37let's start off with um showing you what
- 2:39we're gonna talk about today
- 2:41so as you can see from the agenda we're
- 2:43gonna cover several topics today and
- 2:44it's actually quite a few of them
- 2:46i'm gonna start off with one of my
- 2:47favorite ones which is don't fear the
- 2:49show you know i think a lot of
- 2:51it guys when they first get started with
- 2:53this i hear this all the time
- 2:55they they're scared to get started with
- 2:58powershell they're not used to a command
- 2:59line they don't say they're scared
- 3:01but they're not used to using a command
- 3:03line deep down
- 3:04they see that console window and they
- 3:06just like i don't know what to do yeah
- 3:08so one of the first
- 3:09headlights yeah so one of the first
- 3:10things we're going to want to do is
- 3:12get rid of some of that fear show you
- 3:14how straightforward you can get started
- 3:15with powershell
- 3:17and then we're going to take you into
- 3:19what powershell starts to look like
- 3:20and of course we're going to talk about
- 3:22the reasons why powershell even exists
- 3:23and there's some
- 3:25incredibly important ones so we'll also
- 3:27get into the help system probably one of
- 3:29the most important things that we do
- 3:30today
- 3:31the pipeline and extending the shell all
- 3:33of this stuff that we're going to do is
- 3:34going to make more sense as we hit it
- 3:36looking at what objects are
- 3:37and drilling into the pipeline what is
- 3:39that weird character i keep seeing
- 3:41between these commands and we'll get
- 3:44into one of the most important
- 3:45advantages that you have
- 3:46which will be uh powershell remoting
- 3:49which will let you do
- 3:50a lot of your stuff in scale that's
- 3:52where it gets fun that's where it really
- 3:53gets fun
- 3:54by the way so people should be uh doing
- 3:56these exercises with us so
- 3:58you know you should be at your computer
- 4:00fire up a powershell window and uh type
- 4:02along with us
- 4:03that's the way you get the most out of
- 4:05this course and actually i think that's
- 4:06the best way to get the most out of this
- 4:08is i i know you want to kick back and
- 4:10kind of you know
- 4:10sip some coffee or whatever and listen
- 4:12to us but keep your fingers close to
- 4:13that keyboard on that console
- 4:15um and powershell so you can work with
- 4:17us on this and you should be joining are
- 4:18you gonna tell them about the
- 4:19q a yeah yeah a matter of fact i got a
- 4:22slide coming up oh
- 4:23here let's do the expectations things on
- 4:25our target audience and then we'll
- 4:26talk about how to join us um the this
- 4:29was designed
- 4:30for it pros however if you're dev uh
- 4:33please join us on this this was designed
- 4:36for it pros
- 4:37to be a quick deep dive and get started
- 4:39with powershell there are so many
- 4:41guys out there right now and gals that
- 4:43are trying to get started with
- 4:44powershell
- 4:45and sometimes you find it really
- 4:47difficult well this is the ideas to get
- 4:48you through the difficulty and we're not
- 4:50just doing an introductory level we're
- 4:51going to go in pretty deep with using
- 4:53powershell
- 4:54and it doesn't matter what product you
- 4:56want to use it with whether you want to
- 4:57use it with active directory or
- 4:58sharepoint
- 4:59you got to know the tool and if you know
- 5:00the tool then the products are
- 5:02easy to deal with so if you're an it pro
- 5:05if you work in help desk if you're a
- 5:07developer interested in what powershell
- 5:09can do for you
- 5:10this is the place to be and as a couple
- 5:13of additional resources first of all we
- 5:14have chat available if you're all in on
- 5:16chat you can chat us questions and i'll
- 5:18constantly be reminding you to chat in
- 5:21questions
- 5:22we have an amazing support staff out
- 5:24there today
- 5:25a lot of the powershell mvps are joining
- 5:27us today
- 5:28to help answer questions and we'll be
- 5:30out there answering questions so we want
- 5:32you to join in
- 5:33and contribute and ask whatever
- 5:35questions you have and we'll do the best
- 5:36we can make sure you all get an answer
- 5:38to it
- 5:38yeah and the powershell community is is
- 5:40blessed with some fantastic
- 5:42mvps a number which are online and
- 5:44they'll be coming and
- 5:46going throughout the day so you know
- 5:48don't hesitate to ask questions you know
- 5:49you got some rock stars out there
- 5:51you certainly do and i also want to keep
- 5:53in mind that
- 5:54this particular virtual academy we're
- 5:57going to have a second session not the
- 5:58same thing we're going to go beyond this
- 6:00session
- 6:01further and further into scripting and
- 6:03tool making here in just a couple of
- 6:04weeks on august 1st right yeah
- 6:06it's going to be on august 1st so you
- 6:08want to join the mba community as a
- 6:10matter of fact you can join the mba
- 6:12community
- 6:13you get signed in online as you go
- 6:16through
- 6:16the videos that are available out there
- 6:18you get points and
- 6:20for right now you can get 50 special mva
- 6:23points if you put in the
- 6:24code that's at the bottom of the screen
- 6:27so make sure you keep track of what's
- 6:29going on with the mba community so that
- 6:30you can get
- 6:31more sessions just like this one
- 6:34i don't know i think we're ready to
- 6:36maybe let's go
- 6:38let's get into this my favorite topic i
- 6:40know this i just love talking about this
- 6:41so folks
- 6:42here we go we're going to get into uh
- 6:44don't fear
- 6:45the show come on you can hear the music
- 6:47right don't fear the don't
- 6:49fear the shell and in it okay maybe not
- 6:51yeah um okay we'll stop that then
- 6:54so look we're going to go through an
- 6:55overview of what powershell is white
- 6:56even exists and of course this is the
- 6:58great time for jeffrey to
- 7:00to help us out understand why we even
- 7:01have this and then we're going to start
- 7:02going into
- 7:04how to take some of the fear out of
- 7:05running powershell we'll show you how to
- 7:07get it installed and how to get it set
- 7:08up
- 7:09so let's rock and roll first of all the
- 7:11purpose of
- 7:12and i just want to point out can you see
- 7:13the slide yeah yeah look at you guys you
- 7:16see the you
- 7:16and the them that that picture you
- 7:18that's that's a picture of me when i was
- 7:20younger
- 7:21uh-huh i swear to no it's not really a
- 7:23picture in me so here's the idea
- 7:25you're sitting there struggling with the
- 7:27day-to-day events of everything that's
- 7:29around
- 7:30you you've got projects that you have to
- 7:32have done there are things that are on
- 7:33fire
- 7:34and everything's going right and you
- 7:35have them you have your your end users
- 7:37your boss
- 7:38all of these people that are that are we
- 7:40need this now we need this now
- 7:42and in microsoft environments this has
- 7:44been a challenge we've had some tools
- 7:47and you've had some scripting languages
- 7:49and we had vb
- 7:50script but there were certain
- 7:51limitations that would
- 7:53challenge us and it wasn't quite
- 7:56complete enough
- 7:57was also kind of hard and doing
- 8:00automation and solving problems
- 8:01was a huge challenge then came along
- 8:06this product that you made so why is it
- 8:09that
- 8:10what is it that you were trying to solve
- 8:11for all of us guys in i.t
- 8:13yeah you know when i came to the company
- 8:14i uh i said well you know we need an
- 8:16automation strategy and they said well
- 8:18we have an automation strategy i said
- 8:20really where and they said well you know
- 8:23here and it was vbscript it's like uh no
- 8:26my friends that's not an automation
- 8:27strategy
- 8:28and they said well here you know we've
- 8:29got these great apis like no my friend
- 8:32that's not
- 8:32automation i don't like the sound of
- 8:34that exactly
- 8:36and so what i knew was that we needed to
- 8:39have an interactive shell
- 8:41an environment that someone would say
- 8:42hey go explore the system try this try
- 8:45that try that
- 8:46be able to get things done and then from
- 8:48there the idea is like hey
- 8:50i i notice i do type the things over and
- 8:53over and over again
- 8:54why don't i put it in a script and just
- 8:56run it from there
- 8:58and then say well you know that's great
- 9:00now it's you know
- 9:01reduced my repetitive strain injury and
- 9:04i'd like to parameterize it oh i'd like
- 9:06to parameterize it now i can
- 9:08use it for a wider range of things and
- 9:09now i'd like to share it with you
- 9:11and now we'd like to use it to manage
- 9:13thousands of machines
- 9:14so we had this model we called it the
- 9:16develop or the admin development model
- 9:19which really you know bruce payet
- 9:20superstar bruce he says
- 9:22uh the the average lifetime of a command
- 9:25line script
- 9:26or sort of a script um starts at the
- 9:28prompt and
- 9:29ends at the the carriage return that it
- 9:31was very important that it be an
- 9:32interactive environment so that you can
- 9:34explore and honestly have fun
- 9:36i mean if there's two things you get out
- 9:38of today's session one
- 9:39is a spirit of exploration hey this is a
- 9:42great environment to go explore explore
- 9:44explore
- 9:45and then two just how much fun it is i
- 9:47mean it's just a blast to be able to
- 9:49to use and then from there to be able to
- 9:52automate
- 9:52you know automate automate automate you
- 9:54know if we had just transformed
- 9:56you know a click click click experience
- 9:58to a click click experience
- 10:00like okay that's good like lots of
- 10:02people prefer this
- 10:03over over this but you really
- 10:06wouldn't have transformed the platform
- 10:09it's the ability to then do this this
- 10:11and this and then say
- 10:12save right and then just say click
- 10:16and run and i and i i just want to
- 10:17emphasize that
- 10:19we're unaccustomed in windows
- 10:21environments of having an
- 10:22interactive shell a real time solve your
- 10:25problem tool i mean we've always had
- 10:27basic commands but that really wasn't
- 10:29solving our problem
- 10:30this means solve your problem and then
- 10:33literally
- 10:34copy paste or hit save and now you can
- 10:37automate it
- 10:38and it doesn't require any more than
- 10:41have fun
- 10:42finding and solving the problem and now
- 10:44i'm on my way
- 10:45yeah you know i mean you might say well
- 10:47why do i need to do that
- 10:49and the answer is because everybody's
- 10:50scenario's different
- 10:52so we were talking in the car last night
- 10:54about how well hey in
- 10:55exchange you know the gui you know
- 10:58honestly we spent a lot of time talking
- 10:59to customers and trying to understand
- 11:01the scenarios and put that into the gui
- 11:03so that you just click click click
- 11:04but the reality is and jason was telling
- 11:06me the story about hey
- 11:07i did that but then what i needed to do
- 11:09was i needed to have different quotas
- 11:11for these
- 11:11types of users versus those types of
- 11:13users versus those types of users
- 11:15and uh and and the gui didn't help me
- 11:18you know i had to go
- 11:19do a ton of clicking so we might have
- 11:21gone and said oh well okay we'll add
- 11:23that to the gui
- 11:24but then all of a sudden if you try and
- 11:25deal with everybody's scenarios in the
- 11:27gui
- 11:27it becomes big and it becomes complex
- 11:29and it becomes hideous
- 11:30and then you can't use the gui and i
- 11:33think that that's one of the uh
- 11:35biggest issues that people will will
- 11:37start to see at first is that
- 11:39the graphical there's nothing wrong with
- 11:41using a graphical interface
- 11:42i mean sometimes i use it too i and i
- 11:44use it for things that i just need to do
- 11:46once one off once every blue moon you
- 11:49know creating a site link in active
- 11:51directory
- 11:52the graphical is great for that but when
- 11:53you have business challenges that can't
- 11:55be met
- 11:56such as and i think what we were talking
- 11:57about last night was i needed to set the
- 12:00mailbox limits of
- 12:01a particular ou in active directory well
- 12:04the graphical doesn't support that and i
- 12:05don't expect microsoft to solve that
- 12:07problem for me because
- 12:09how are they supposed to know what my
- 12:10issues are powershell is the way that
- 12:13you can solve those issues and that you
- 12:15can
- 12:15get these business problems solved and
- 12:17it doesn't take six months you get them
- 12:19solved right now
- 12:20and then you automate them so the
- 12:22purpose to powershell really is all
- 12:23about
- 12:24making you more effective getting stuff
- 12:26done faster
- 12:27and solving problems that you probably
- 12:30had a hard time solving before
- 12:32so because often they're unique yeah
- 12:34very unique
- 12:35so let's see here installing powershell
- 12:38now
- 12:38right now there's there's a lot of it's
- 12:40kind of confusing for a lot of folks
- 12:43first of all let's talk about some of
- 12:44the versions of powershell nobody should
- 12:45have v1
- 12:46right now right can we you should
- 12:48upgrade
- 12:49you've got to release okay so v2 um
- 12:53came out a couple of years ago right
- 12:55yeah a couple years ago
- 12:56and you should have v2 on windows 7 and
- 12:59you should have it on 2000 a 2008 r2
- 13:02um and v2 also works and is is part of
- 13:05the update stream that you can uh
- 13:07update for windows xp and shame on you
- 13:09if you still have windows xp
- 13:10and of course server 2003
- 13:13now v3 is the new one and v3 came out
- 13:17for windows 8
- 13:18and for server 2012. if at all possible
- 13:22as the administrator
- 13:24you want v3 on your box and you're going
- 13:26to see plenty of examples of that today
- 13:27oh yeah of needing to have v3
- 13:30you can upgrade v3 um and have that on
- 13:32your box for both
- 13:34the uh uh uh windows 7 and
- 13:38server 2008 r2 and that's it though
- 13:40right windows server 2008
- 13:422008 2008 r2 and 2008 r2 i got to make
- 13:45sure i get all them all in there
- 13:47so you can upgrade to v3 now you don't
- 13:49have to rush right out right now and
- 13:50start upgrading your servers
- 13:52to v3 and you should take some cautions
- 13:55out there there are some products that
- 13:56aren't quite ready to handle v3 and
- 13:58there's plenty of information on that so
- 14:00don't be that guy or gal that makes that
- 14:02mistake and accidentally upgrade a
- 14:04server
- 14:05to v3 if the product running on it is
- 14:07not ready for it but on your
- 14:09administrative machine
- 14:10you got to have v3 you're going to love
- 14:12the features we show you today with it
- 14:13yeah you should always read the release
- 14:14notes you know we tell you what what it
- 14:16works with
- 14:17if you have this don't install that yeah
- 14:19release notes are really good along with
- 14:22you know testing is also really good um
- 14:24as well
- 14:25um if you take a look at the slide real
- 14:26quick you'll see that there's a place
- 14:28where you can download it's a strange
- 14:29name to download uh powershell three
- 14:31it's called the windows management
- 14:32framework
- 14:33we're gonna talk a lot more about what
- 14:34the what the term the windows management
- 14:36framework means it's not just powershell
- 14:38and there's a link there for you so that
- 14:40you can get it downloaded now if today
- 14:42you have v2 on your laptop you'll be
- 14:44fine
- 14:44but probably during lunch you're going
- 14:46to want to use v3
- 14:48and just to let you guys know so that we
- 14:49can get the confusion out of the way
- 14:51what we're doing today
- 14:52is how to use powershell what we show
- 14:54you how to use today
- 14:55is going to work on v2 v3
- 14:59and that mythical thing that's coming
- 15:00out sometime in the future
- 15:02v4 ish like stuff so you're
- 15:05going to be just fine with without
- 15:08whatever version you have that's we're
- 15:10going to be using
- 15:10it's all going to be about the tool
- 15:12today so
- 15:14well let's talk about launching
- 15:15powershell how do you find powershell to
- 15:17launch it and guys i'm actually going to
- 15:19demonstrate this off of my box real
- 15:20quick
- 15:22one of the most interesting things here
- 15:24is if you're on windows 8
- 15:26you have this magnificent windows key
- 15:28that brings up
- 15:29your desktop for you and to find
- 15:31powershell it's actually very simple
- 15:33just start
- 15:34typing the word powershell
- 15:37now i have to tell you the first thing
- 15:39that i always do is right click and pin
- 15:41this
- 15:42to my taskbar i need to you'll have this
- 15:45you're going to have
- 15:46powershell open more than anything else
- 15:49that you work with so
- 15:50you want to make sure you right click
- 15:51and get this guy pinned i've already got
- 15:53mine penned
- 15:54down here on my desktop so that you can
- 15:57see it now if you're working with
- 15:59um a pre windows 8
- 16:03operating system you're going to have to
- 16:05click on the start menu and i've got a
- 16:07screenshot of what that looks like here
- 16:09in the slides
- 16:11you'll click on the start menu as soon
- 16:12as i can figure out how to bring the
- 16:13slide back
- 16:14up it's this guy over here you're going
- 16:16to go under accessories and then
- 16:17windows powershell will be at the bottom
- 16:20and you're going to notice that there
- 16:21are two kinds of them out here you're
- 16:22going to see some repeats x86 versus
- 16:25ones that aren't x86
- 16:27the x86 are obviously the 32-bit
- 16:29versions you don't want to run those you
- 16:30want to run the
- 16:3164-bit version on your 64-bit os
- 16:35and we'll talk a little bit later about
- 16:36the ise but this is a great scripting
- 16:38editor
- 16:38that we can use as well so as long as
- 16:42you got powershell ready to go
- 16:43then we're ready to start to work with
- 16:45it rock and roll baby
- 16:47now let's talk a second about comfort
- 16:51comfort is important like these chairs
- 16:53right here
- 16:54in this studio are very very comfortable
- 16:56and that's very nice
- 16:58we're going to spend a lot of time and
- 16:59i'm rocking back and forth because
- 17:01they're so comfortable
- 17:01swaying swaying we're going to spend a
- 17:04lot of time
- 17:06looking at this console yep and
- 17:08powershell uses
- 17:10does he use every possible character on
- 17:12the keyboard
- 17:13no actually there's the up arrow
- 17:16great it's the up arrow that we don't
- 17:20use
- 17:20oh that's awesome well guys this is what
- 17:22i'm talking about
- 17:24first of all let me launch powershell
- 17:25and show this to you now i'm going to
- 17:27launch it i'm logged in as a regular
- 17:28user account
- 17:30and i want you to notice when i launch
- 17:31powershell the first thing you take a
- 17:32look at the top of the screen here see
- 17:33how it says windows powershell
- 17:35if you want to do some administration
- 17:36that's not what you want it to say so
- 17:38let me close this and show you
- 17:40if you're in as a regular user account
- 17:41you want to right click and do run as
- 17:43administrator if you're an administrator
- 17:44it'll already launch it
- 17:46with administrator if not it'll prompt
- 17:48you for credentials so that you can
- 17:50have administrative access we're going
- 17:52to talk about security later but this is
- 17:53actually an important thing
- 17:55notice as i'm looking at the console
- 17:57right now
- 17:58this is something that we're going to be
- 18:00staring at for a long time
- 18:02so there's a couple of things that you
- 18:03definitely want to be able to tell the
- 18:04difference in
- 18:06by the way one of the tricks there is if
- 18:08um if you're trying to do something
- 18:10and it's not working like this morning
- 18:12or trying to set some things up
- 18:14and i did get vm and it there was it
- 18:17showed me nothing
- 18:18i was like oh do i have the wrong
- 18:20machine did i provision this i recently
- 18:22provisioned it did i
- 18:23like forget to set things up and then i
- 18:25looked and i saw that i wasn't in
- 18:26admin mode so then you bring it up in
- 18:29admin mode and i said get vm and you see
- 18:31all your vms
- 18:32so if something's going a little wonky
- 18:33go check and uh
- 18:35see that you are running his admin and i
- 18:37just have to say that we're gonna be
- 18:38doing
- 18:39several things today and out of those
- 18:40things that we're doing today
- 18:42if you're not in administrative mode it
- 18:44isn't going to work it's going to be
- 18:46very wonky you're going to get error
- 18:47messages
- 18:48access denied messages and so you want
- 18:51to make sure you're in as administrator
- 18:52mode
- 18:53take a look at the characters i have on
- 18:55the screen can you see the difference
- 18:57on your screen with those characters you
- 18:59zoom it
- 19:00well no i i want them to look at it and
- 19:02go i can't tell the difference
- 19:03oh i want them to go no i don't know
- 19:05what it is don't you zoom it yeah don't
- 19:07use it with that
- 19:07um this is important you need to make
- 19:10sure that this screen
- 19:11you can see these individual characters
- 19:13i've got a grave character or a backtick
- 19:16character
- 19:17and then a single quote and there's only
- 19:18a couple of pixels in difference
- 19:20so here's actually one of the most
- 19:22important things to do when you're
- 19:23getting ready to use
- 19:24powershell i'm going to go in here to
- 19:26the properties and we're going to adjust
- 19:27this console
- 19:28now i'm not going to change mine because
- 19:30that'll screw all the views up but let
- 19:32me kind of show you the idea here
- 19:34under fonts you want to use a font that
- 19:37is
- 19:38nice and bold and thick and they gave
- 19:40you one called lucida console did
- 19:42i did i say that right you see concert i
- 19:45i have no idea
- 19:46consoles lucida
- 19:49nevermind that's okay consoles is a nice
- 19:52font but it's thinner i prefer the
- 19:54heavier weight font
- 19:55and then you want to adjust the font
- 19:56size but when you do that
- 19:59to get it to a nice font size you're
- 20:00going to notice in this preview pane
- 20:02that the pretty powershell window is
- 20:04going to extend to the right
- 20:05and go to the bottom and these are all
- 20:07bad things and let me tell you why
- 20:09when powershell is giving you
- 20:10information it wants to
- 20:12sometimes put information all the way to
- 20:14the right and all the way at the bottom
- 20:16and so if your screen has extended
- 20:19beyond the boundaries of your desktop
- 20:21you're not going to see anything so and
- 20:24you don't want scroll bars all over the
- 20:26place so let me show you how to fix that
- 20:28oh you don't use bold i always use bold
- 20:30do you use bold always
- 20:32really yeah that scares me oh because it
- 20:34feels like it's yelling at me or
- 20:36something
- 20:37okay well you want to turn the bullet on
- 20:40i always do
- 20:40okay let's turn bold on i find well
- 20:42here's the deal when you present
- 20:44if any of you ever present to the the
- 20:46audience always use bold
- 20:48because then it's just easier to read
- 20:50like a couple hundred females
- 20:52i don't want to turn it on now okay okay
- 20:55now in layout guys layout is where
- 20:57you're going to adjust
- 20:58your screen width and so that it fits
- 21:02and then what you want to do is fit just
- 21:03like this in the preview window
- 21:05let me show you two things the window
- 21:06size for width is right here and that'll
- 21:08adjust its width and i'll screw mine up
- 21:10for a second
- 21:12and see how it's kind of going off to
- 21:13the the right over there
- 21:15you don't want that you want your width
- 21:16so that it fits so you don't have a
- 21:18horizontal i think that's this way
- 21:19horizontal
- 21:20scroll bar when you adjust the window
- 21:24width size you also want to make sure
- 21:25that you keep the buffer size you don't
- 21:27want things going off into the buffer
- 21:28where you'll never be able to see it
- 21:30height is an important one as well i
- 21:32want you to notice as i scroll up and
- 21:33down this height
- 21:35what i don't want to do is scroll that
- 21:37all the way below my desktop because
- 21:39then when you see data
- 21:40data will get put down at the very
- 21:42bottom and you won't see it so i want it
- 21:44to fit on my desktop
- 21:45a vertical scroll bar you'll have will
- 21:47be okay
- 21:48make sure that for the height buffer
- 21:50size you get at least three
- 21:523000 or greater and i want to warn you
- 21:54that when you're working with some
- 21:55products that have a powershell console
- 21:57that console is set to 300 by default so
- 22:00you definitely want to change that
- 22:02you're going to lose information and not
- 22:03be able to scroll back and see it
- 22:05when it comes to colors oh dude
- 22:08i'm not changing the colors because i
- 22:10like the color scheme you picked out
- 22:12i mean you could i mean but you know if
- 22:14you want to change the colors to
- 22:15something that you like to read
- 22:17you know you want to make it green
- 22:18screen or whatever or
- 22:20come up with some weird color
- 22:22combination knock yourself out but i'm
- 22:24going to leave it at the default color
- 22:25size the important thing is good
- 22:27yeah i know i thought the yellow would
- 22:28look great the important thing is
- 22:30is that your console is now ready to go
- 22:33and it's all set up and it's in a
- 22:35comfortable font so while we move on
- 22:37take a second and make sure that you've
- 22:39got a nice looking powershell
- 22:41console to take a look at so let's see
- 22:44what we're doing next here i think we're
- 22:45ready to kind of
- 22:47get into some demonstration stuff
- 22:50yeah yeah this is lucky lucky lucky
- 22:55oh man that's old and you get like this
- 22:57milk mustache going i just like this is
- 22:59great get powershell this is awesome
- 23:01so let's talk a little bit um and start
- 23:04off by taking some of the fear out of
- 23:06powershell before we talk about this
- 23:08this magic word commandlet um
- 23:12you needed to come up with your own
- 23:15commands
- 23:16not the windows native ones you needed
- 23:17your own commands
- 23:19why the term commandlet yeah so there's
- 23:22two answers to that
- 23:23so first is that uh powershell um
- 23:27we want to have a model of composition
- 23:30okay and so the model of composition if
- 23:32you actually take a look at it
- 23:34the commands that you write are really
- 23:36really really small
- 23:37and the idea is that then you leverage
- 23:40the engine to do common processing
- 23:43so if you had each one of the
- 23:45commandlets try and do big tasks by
- 23:48themselves
- 23:48i want to get things and i want to
- 23:50process things and i want to format them
- 23:52then every developer would be doing
- 23:53things differently right you know
- 23:55oh well i like the term sort and you
- 23:58like the term order and order by and all
- 24:00that and so
- 24:01so he said no no you write the things
- 24:03that you
- 24:04and only you can use do and then
- 24:07leverage the engine to do everything
- 24:09else okay and so these commands got
- 24:12really really small and that was the
- 24:13whole point they're really really small
- 24:16and you use the pipeline to do bigger
- 24:18tasks
- 24:19and because of that you get or you get a
- 24:22a
- 24:22regularity that is to say you're going
- 24:24to learn something and then you can use
- 24:26it over
- 24:26and over and over again so that's where
- 24:28the term commandlet came from
- 24:30but then when we went to bring it out
- 24:32the documentation people said
- 24:34no way you can't do that we don't make
- 24:36up terms
- 24:37it's called command that's like well no
- 24:40we're going to call it command line
- 24:41and they just went to the mall it's like
- 24:42no no no no i said i'll tell you what
- 24:45bring up a a a search window okay say
- 24:48search for command and there was like x
- 24:51hundred million things
- 24:52i said now search for commandlet and it
- 24:54was x
- 24:55thousand i said every single one of
- 24:57those is related to powershell
- 24:59and they're like oh search engine
- 25:00optimization there you go a little
- 25:03seo on the exact using the term camel
- 25:06and i just have to say that
- 25:07my wife refers to them as kimblets
- 25:09because that's the way they're
- 25:11they're spelled but at any rate
- 25:12commandlets now the
- 25:14the how a commandlet looks is also kind
- 25:16of bizarre
- 25:17if you've never been at the the command
- 25:20i mean if you've been at the command
- 25:21line
- 25:21you see dir but now you're seeing these
- 25:24well we've got verbs and we've got this
- 25:26dash and we've got this now and
- 25:27why did you so a lot of people take a
- 25:30look at powershell and they say oh you
- 25:31know ver looks very much like unix right
- 25:33and by the way it's just you know we
- 25:35actually tried to to use unix right we
- 25:37didn't uh
- 25:38start off wanting to invent something we
- 25:40started off saying i gotta solve a
- 25:41customer problem
- 25:43and so there were some really great
- 25:44tools out there the unix tools so my
- 25:46first effort was to get those tools
- 25:47available on windows
- 25:49but it turned out that that didn't work
- 25:51and the reason why is because unix
- 25:53is very much of a document oriented
- 25:56operating system which is a lot of the
- 25:58management is done through
- 25:59documents or files whereas windows is an
- 26:02api oriented operating system
- 26:05okay now both have their advantages but
- 26:07here's the thing the management's
- 26:09completely different
- 26:10so when i got bash and awk and sudden
- 26:13grep available on windows okay
- 26:16it didn't help that much right why
- 26:18because then you go and you say awk
- 26:20awk doesn't work against the registry
- 26:22grep doesn't work against
- 26:24wmi sed doesn't work against uh uh
- 26:27active directory and so in in unix those
- 26:30those tools those text manipulation
- 26:32tools
- 26:32are management tools but on windows
- 26:34they're just text manipulation tools and
- 26:36there's not much text so
- 26:38they didn't help so we had to invent our
- 26:40our own stuff
- 26:41and so then the question is okay well we
- 26:43want to invent as little as possible
- 26:46uh and so we leveraged a lot of the
- 26:48technology a lot of the
- 26:49the concepts of unix the compositional
- 26:51model
- 26:52but unix you love unix guys did a great
- 26:55job
- 26:56on the other hand it has weaknesses as
- 26:58well and this is an area where we
- 27:00looked more to vms dcl or the as400
- 27:04they have very good production-oriented
- 27:06environments
- 27:07and they were extraordinarily regular in
- 27:10their environments
- 27:11which is to say you had verb-noun
- 27:14and then this well-defined set of of
- 27:17parameters and what happened the first
- 27:19time i learned it right
- 27:20i was a unix guy for a long time and
- 27:22then i had to do
- 27:23vms and i got on i was like i hate this
- 27:26thing i despise this thing it's a piece
- 27:28of
- 27:29junk and i would go around telling
- 27:31everyone this and it's like okay but i
- 27:32got to do it for my job and i try
- 27:34somewhere and i just i
- 27:35hate it and at some point i just had to
- 27:37like
- 27:38sit myself down and like put your big
- 27:40boy pants on jeffrey
- 27:42you gotta learn this and says like okay
- 27:44stop
- 27:45get out of your head condemning things
- 27:47just like
- 27:48experience it and so about an hour later
- 27:51i'm like hey you know this thing's
- 27:52pretty cool
- 27:53and then all of a sudden two hours later
- 27:55it's like something new comes up and
- 27:57and having learned a set of things i
- 27:58said boy i wonder if that works and it
- 28:00worked
- 28:00so what happened was you learned this
- 28:02schema right
- 28:04verb dash noun or slash is there but
- 28:06then
- 28:07it was the schema you learned it once
- 28:08and then you were able to do it over and
- 28:10over and over again
- 28:11and that was the joke at deck at deckley
- 28:14used to say hey
- 28:15somebody put a fish finder on the vax
- 28:16can you manage it and they're like sure
- 28:18show fish finder get fish finder slash
- 28:20no log slash confirm
- 28:22and i think that's really i mean that's
- 28:24the epitome of what's going to help us
- 28:25all out
- 28:26not only today but going forward is the
- 28:28fact that you get used to
- 28:30i want to work with x well i know that
- 28:32i've got these common verbs that i'm
- 28:34going to use i'm going to be able to get
- 28:35this i'm going to be able to set this
- 28:37you know change it i'm going to be able
- 28:38to new create something new
- 28:41and i think that's very important and i
- 28:43started out in as400 and my
- 28:45my my first um well i was being trained
- 28:48my first
- 28:48there was a problem and my first thing
- 28:50was can't we just reboot it
- 28:52and i thought the operator was going to
- 28:54punch me when i
- 28:56said so yeah he should have so hey guys
- 28:58let me show you uh what these
- 28:59commandments are take a look at my
- 29:00current directory location now if i was
- 29:02in
- 29:03something like dos you guys know that i
- 29:04could do cd backslash but we have
- 29:06commandlets now so watch set dash
- 29:08location c calling backslash
- 29:11yeah that's cool now if i wanted to get
- 29:14something like a directory listing in
- 29:16dos you guys know you can do dir but
- 29:18here's the interesting thing we have
- 29:19commandlets for this so get
- 29:20child item will give me a directory
- 29:23listing if i want to clear the screen if
- 29:24this was dos we'd do cls but we have a
- 29:26commandlet for that called clear
- 29:28dash host please tell me that you're not
- 29:32impressed yet
- 29:34yeah i think we got the guys in the back
- 29:35there going yeah that was
- 29:38let's start to take the fear out of
- 29:39powershell one of the the things that
- 29:41helped me tremendously
- 29:42especially when i got started with
- 29:44powershell was that
- 29:46yes there are commandlets and yes we're
- 29:48going to show you how to discover
- 29:49and learn and use those commandlets but
- 29:51you can start using powershell right now
- 29:54even if you don't know those commands
- 29:55let me show you this is kind of
- 29:56interesting i'm going to close my shell
- 29:58and reopen it again
- 30:01and so if i want to change from this
- 30:03directory location back to the root of c
- 30:06cd oh it worked if i want to get a
- 30:08directory listing
- 30:11dir worked just perfect if i want to
- 30:13clear the screen
- 30:14cls see it's working as i would expect
- 30:17and here's the interesting thing
- 30:19let's see if i was a unix guy how would
- 30:21i get a directory listing
- 30:22um ls um how would i clear the screen
- 30:25well
- 30:26clear it's it's it's
- 30:29doing unix stuff and it's doing windows
- 30:31stuff and it's
- 30:32it's making me happy because i can be a
- 30:35windows guy and i can sit down and start
- 30:36using powershell
- 30:38a unix guy can sit down and start being
- 30:40using powershell
- 30:41my question is is why is that working
- 30:43yeah so what we do is we got a regular
- 30:45uh experience right
- 30:47so you've got get child items set
- 30:50location etc
- 30:51and you can always back use those things
- 30:53and then what we did was we put
- 30:54personalities on it which is to say we
- 30:57knew that unix guys would be coming to
- 30:58this we knew that dos guys would come
- 31:00into this
- 31:00and so we have aliases and so uh the
- 31:03aliases
- 31:04uh as much as possible we wanted
- 31:05people's first experience to not be a
- 31:08frustrating one that they try a set of
- 31:09things and they just work ps
- 31:11continues to work exactly and i think
- 31:13this is one of the interesting things is
- 31:16is that they're aliases and they just
- 31:17think of them as shortcuts
- 31:19to real commandlets okay so we're we're
- 31:22not
- 31:23using the actual ls command or anything
- 31:26it's pointing to a powershell commander
- 31:28but the idea was i love your use of the
- 31:30term personalities
- 31:31we built personalities into this is that
- 31:33it makes it comfortable for whatever
- 31:35environment you're coming from so that
- 31:36you can get started right away
- 31:38as a matter of fact let me just kind of
- 31:39show you get dash alias
- 31:42gives you a list of the current aliases
- 31:45by the way you guys should print this
- 31:46out and memorize this in the next few
- 31:47minutes so
- 31:48it's you have all the aliases but this
- 31:51is what allows you to
- 31:52start working and you know things like
- 31:54making a directory i can make a
- 31:55directory oh boy
- 31:56see i can go right to work right away
- 31:58and this starts to bring us to another
- 31:59oh
- 32:00we're going to talk if you're if you're
- 32:01a unix guy you'd use
- 32:03victor right right so let's see let's
- 32:05see make
- 32:06dirt this works jeffrey
- 32:10awesome it's it's
- 32:14it's all that easy um so basically your
- 32:18normal command line experience you can
- 32:20bring right to powershell but wait
- 32:22there's more okay yes there's more
- 32:26there's more get a ginsu knife out of
- 32:28this
- 32:28even better than against a knife now
- 32:30first of all i just want to kind of
- 32:31point out that
- 32:32we're going to talk about help
- 32:34extensively but if you want to get help
- 32:36you can type help and if you're a unix
- 32:39person and want to type help you can
- 32:40type man now personally i think
- 32:42you know unix is kind of sexist for the
- 32:44whole man thing but in powershell if you
- 32:46want to get a list of
- 32:47if you want to get a list of aliases you
- 32:49can type get dash alias
- 32:51but there's an alias for get alias
- 32:53called called gal and see this is what
- 32:55makes me so happy is that
- 32:56powershell isn't sexist so you should
- 32:57use this um anyways
- 33:00let me show you stupid but
- 33:03so here's where it gets really cool
- 33:08you know what i can do from powershell
- 33:09besides working in an environment that
- 33:11already kind of feels comfortable
- 33:12with me i can i can use windows native
- 33:15commands i love this ping
- 33:20a computer and it works this is so
- 33:23awesome yeah
- 33:24i can run notepad i can i can i oh yeah
- 33:27i know everybody's impressed now i can
- 33:28oh look calculator
- 33:30and oh hey you know what i haven't tried
- 33:31this yet on windows 8 i should try this
- 33:33can i run do we still have ms paint oh
- 33:36this is awesome so we still
- 33:39okay but the point was this is that
- 33:43you can still use your windows native
- 33:44commands in here you guys are always
- 33:46checking you know ipconfig and all that
- 33:48stuff
- 33:49don't don't be that guy or that gal i i
- 33:52have to tell you this is one of the
- 33:53funniest things i have
- 33:54i was teaching an advanced scripting
- 33:56class for for powershell this guy
- 33:57i've known him a long time was writing
- 33:58this magnificent tool
- 34:00to go out and do a bunch of things to a
- 34:02couple of computers
- 34:04and he said you're going oh my script's
- 34:06broke can you help me and i'm like
- 34:07what's your problem he says well the
- 34:09scripts broke and because
- 34:10it's getting those two machines but it's
- 34:12not getting anything from that machine
- 34:14and one time i said well first of all
- 34:16don't forget you're an engineer
- 34:18what do you what do you usually do if a
- 34:20machine's not responding how do you
- 34:22test that and he says oh oh
- 34:25i'll ping it i'm like yeah see if it's
- 34:27even turned on very good very good
- 34:29so he's sitting at a powershell console
- 34:31no
- 34:32you know what he did yes start programs
- 34:35accessories opened up command
- 34:37prompt to type ping i literally looked
- 34:40at him
- 34:40and went get out
- 34:42[Laughter]
- 34:44so the idea guys is you have your
- 34:46windows native commands
- 34:49and they work the way that you expect
- 34:50them to work so that you have an
- 34:52environment to get started in so
- 34:54between aliases helping you out and
- 34:57between running windows native commands
- 34:59the idea is open up powershell don't
- 35:01open up the command prompt
- 35:02open up powershell and start using
- 35:04powershell because you're going to start
- 35:06then learning the commandlets and
- 35:08which we're going to do today but you're
- 35:10going to start learning the commandlets
- 35:11and make your learning curve much
- 35:12easier this way it was designed for you
- 35:14to do it this way
- 35:16and so make your life easy and just go
- 35:18ahead and start using it and make sure
- 35:19you show your other administrative
- 35:20friends
- 35:21open up the shell and start using it
- 35:23it's going to work
- 35:24for you so at least that's taking a
- 35:27little bit of the fear out of it
- 35:28let's hope so besides having aliases and
- 35:32all that kind of good stuff folks we
- 35:34want to do kind of a reminder for you
- 35:37oh wait can you go back oh yeah i can go
- 35:38back yeah can i can can i show you
- 35:39something
- 35:40you can go to my screen okay
- 35:44hoo-ha perfect let's see okay so i don't
- 35:47know if you know this but uh so
- 35:48the aliases right so you saw aliases for
- 35:51gal pwd right okay
- 35:55so they're these personalities yeah okay
- 35:58but
- 35:58if you take a look there's just a ton of
- 36:01these things
- 36:02yeah and so so you notice like what are
- 36:04they alias too it's all verb noun verb
- 36:06noun
- 36:06sorry yeah okay uh but the aliases are
- 36:09very regular as well
- 36:11okay so take a look at this let's say
- 36:13gal well gal
- 36:14g star okay notice wild cards
- 36:17so notice all the g's start with get
- 36:21okay you know what i i don't think i've
- 36:23actually ever noticed that
- 36:24okay now here's the thing now that's
- 36:26that's sort of obvious right
- 36:27but apparently not because but
- 36:30here's the interesting thing look at
- 36:32this one g as v okay let's let's see if
- 36:34i can zoom it working here
- 36:36okay oh look at that okay so get service
- 36:39gsv so then the question is well geez
- 36:42what about if i did gal star sv
- 36:47and look there okay so you've got some
- 36:49so gsv
- 36:51saesv start service spsv
- 36:55stop service so look at this sasv
- 36:58okay so let's see oh i'm getting good at
- 37:01this
- 37:01sasv is start service so
- 37:05sv for service let's say gal sa star
- 37:09and look start start starts so it's not
- 37:11always the case right
- 37:12cell al for alias but yeah sa
- 37:15jb so we've even been tried to be
- 37:19thoughtful and and schematize the
- 37:22the um the aliases as well and you made
- 37:24them easy to
- 37:26search through and this has become
- 37:28really important when we get to
- 37:29start talking about using the help
- 37:31system which is what we're going to do
- 37:32next
- 37:33but you've made them easy to search
- 37:34through to find aliases and one of the
- 37:36things
- 37:37guys i want to show you is a is on to
- 37:39what jeffrey was showing you
- 37:40is with those aliases um
- 37:44a lot of times get alias a lot of times
- 37:46you're going to have a commandlet and
- 37:48you're going to want to know what the
- 37:49alias is for the commandlet
- 37:51there is a way to do this and we're
- 37:52going to explain what parameters are
- 37:54they alter the command and there's a
- 37:56parameter called definition and if i
- 37:57were to type in
- 38:00a particular commandlet it'll tell me
- 38:02what the aliases are available for
- 38:03notice in this case there's a couple of
- 38:05them ps and gps for it
- 38:07um so there's a couple of different ways
- 38:09to find and work with your aliases i
- 38:11find it much easier if you just memorize
- 38:12the list
- 38:12no just kidding don't memorize the list
- 38:15as a matter of fact don't
- 38:16memorize anything but we'll we'll talk
- 38:18about that more yeah
- 38:19good um so because we don't want you
- 38:21memorizing stuff yeah that just takes
- 38:23the pain out of it
- 38:24so questions or comments make sure that
- 38:27you're in the chat rooms you're asking
- 38:29questions
- 38:29and we're going to be checking on you
- 38:31guys as we go throughout this
- 38:33to see if you have any questions and
- 38:35there will be a recording of this later
- 38:37i know a lot of people are asking if
- 38:39there's going to be a recording of this
- 38:40absolutely and it will be available for
- 38:42you online with mba
- 38:44so and i'm going to remind you with this
- 38:45slide often to ask questions
- 38:47and stuff like that
- 39:04[Music]
- 39:13so you're ready to uh do a little help
- 39:16and help me out and
- 39:18do a little help help help yeah because
- 39:21guys this is probably the most important
- 39:24section of the entire day and it may not
- 39:27even seem like it at first but i swear
- 39:29to god that this is the most important
- 39:31thing and here's why it's so important
- 39:34when you go to powershell you're going
- 39:36to stare at that console and go
- 39:38now what do i do yeah this is the answer
- 39:41so
- 39:42kicker girl card called that the
- 39:44dizziness of freedom
- 39:45you look at that prompt and you can do
- 39:46anything you're like uh
- 39:48what do i do and that is that a lot of
- 39:50it it affects all of us and
- 39:52a lot of us you know you get past that
- 39:54with what we're going to do
- 39:56now yeah it's a help system um but i
- 39:58think for a lot of folks i see it all
- 40:00the time that
- 40:02okay it made sense when you were doing
- 40:04it but now i'm staring at that console
- 40:06and
- 40:06i just don't know what to do and i don't
- 40:09know where to go
- 40:10and they created a solution for you this
- 40:12is a beautiful solution so what we're
- 40:13going to start off with
- 40:14is looking at the help system
- 40:17showing you how to get it updated and
- 40:19this is actually a fascinating feature
- 40:20in v3 remember i was saying you're going
- 40:22to want to be using v3 and this is going
- 40:23to be one of them
- 40:24the most important thing is the
- 40:25discoverability that the help system
- 40:27provides you
- 40:29basically it is your it is your bang for
- 40:32power shell it is your
- 40:33it is it is answers all of your needs
- 40:35and all of your questions
- 40:37and also we're going to show you how to
- 40:39read syntax and so forth so
- 40:41let's get started with the help stuff
- 40:43and here in about 10 minutes we'll take
- 40:44a break and then we'll come back in and
- 40:46look at all the syntax and
- 40:47start getting into it so first of all
- 40:49why you need
- 40:51help well i just want to go to bullet
- 40:54number two
- 40:56exactly can can we talk about this i
- 40:59don't
- 40:59i'm a smart guy but i'm not smart enough
- 41:02to just know everything
- 41:04absolutely so tell me what the idea here
- 41:06is yeah so
- 41:07one of my jokes although it's actually
- 41:08true is that uh powershell is such a
- 41:10great product because i'm such a deeply
- 41:12flawed human
- 41:14okay it's true i'm a deeply flooded
- 41:17human and i was in a position to say hey
- 41:20let's build a tool that helps me
- 41:22right so concretely you know i i can't
- 41:25remember all that stuff either i'm a
- 41:26terrible typist
- 41:28uh et cetera so you'll see there's a ton
- 41:30of stuff in powershell
- 41:31that helps for those things so really is
- 41:34a goal to not be able to memorize things
- 41:36actually there's a great story they
- 41:38recently did a study
- 41:40of unix admins and came out with this
- 41:42report and i was
- 41:43really amused by this because basically
- 41:45about 25
- 41:4630 years ago they had done exactly the
- 41:49same study
- 41:50and produced exactly the same results
- 41:52and here's what they did
- 41:53they took a bunch of beginner unix
- 41:55admins and
- 41:56expert unix admins and they said hey
- 41:58here's a test
- 42:00if you want to do this how do you do it
- 42:01a written test and what was interesting
- 42:04was
- 42:04that there when you scored these uh
- 42:06there wasn't very much of a difference
- 42:08between the
- 42:09expert unix admins and the beginning of
- 42:11unix admins
- 42:12and so then it's like oh why are we
- 42:14paying these experts so much money you
- 42:15know they can't uh
- 42:17objectively they're not that much better
- 42:20than just some
- 42:21beginner right and so then so then they
- 42:24said okay
- 42:24well now let's put them in front of a
- 42:26machine and give them a set of tasks
- 42:28and what you saw was this huge
- 42:31difference in performance
- 42:32that the experts were able to perform
- 42:34amazing things
- 42:35that the beginners struggled with and
- 42:37the conclusion was
- 42:39that what expert unix guys are great at
- 42:42is not
- 42:42knowing things but in figuring things
- 42:45out
- 42:46okay and so that's the deal this is not
- 42:49about you sitting there saying
- 42:50hey um it should work this way
- 42:53right no no that's not the deal the deal
- 42:55is hey let me figure out
- 42:58how to do things and so that's what it's
- 43:00all about what you're going to learn
- 43:01is a schema right you're going to learn
- 43:03a set of things you're going to learn
- 43:05how to learn
- 43:06and then you're going to use those
- 43:07techniques over and over again
- 43:09and that's why once you learn how to use
- 43:11powershell and you're managing say
- 43:13exchange
- 43:14then when someone says oh we got this
- 43:16link server it's like well let me have
- 43:17at it
- 43:18and you'll be able to go and you'll be
- 43:20able to learn and learn and learn
- 43:21and just figure stuff out so basically
- 43:23what you're telling me is is that
- 43:25the first time i walked up to a unix guy
- 43:27and i said hey how'd you do that and he
- 43:28turned around
- 43:29and usually barked uh barked at me going
- 43:33rtfm yeah he was actually trying to
- 43:35educate me
- 43:36he wasn't just being a terrible person
- 43:39no both
- 43:40oh okay but i think
- 43:43and this is really the moral of the
- 43:44story is you're not gonna be able to
- 43:46memorize stuff guys
- 43:47we you know powershell v2 had like 236
- 43:50core commandlets
- 43:52okay i might be able to memorize those
- 43:53but here's the deal when you start
- 43:54working with products
- 43:56you know exchange has depending on your
- 43:58version of exchange has between 535 and
- 44:00610 commandments
- 44:02you got 500 some odd commandlets for
- 44:03sharepoint you've got a hundred and some
- 44:05odd commandlets for active directory
- 44:08in server 2012 you have thousands of
- 44:11commandlets now there's no way
- 44:15to memorize them so what they did is
- 44:17they created a help system now
- 44:19before you go oh no not another help
- 44:21system
- 44:23because i know if you've and i'm i'm not
- 44:25okay maybe i am if you've used the help
- 44:27system in
- 44:28in in a particular product before and
- 44:30have found it unuseful
- 44:32well just remember it wasn't spent a lot
- 44:36of time on this was spent a lot of time
- 44:38on by people who
- 44:39wanted you to be successful knew that
- 44:41the only way that you're going to be
- 44:42successful is to have
- 44:44a great help system we all of us use
- 44:47this
- 44:48every single day and i want to point out
- 44:50that as jeffrey was saying it's about
- 44:52using the help system reading and
- 44:53comprehending it
- 44:55and then figuring it out we're i.t pros
- 44:58that's what we do we figure things out
- 45:00this is actually fun when you get start
- 45:03working with
- 45:04it but one of the challenges that we
- 45:05have is the rtfm
- 45:07side i mean as an it pro one of the
- 45:09reasons i got into it is because i was
- 45:10really good at sitting down at a
- 45:12computer and just figuring it out
- 45:13i didn't have to read the manual well
- 45:16that's not going to work here we're
- 45:17going
- 45:18to have to use and read and comprehend
- 45:20the manual and they've made it
- 45:21really easy for us so let's start doing
- 45:24a little get
- 45:24help stuff first of all and guys
- 45:28some of this stuff is in the slides and
- 45:30so we're just going to demonstrate it
- 45:31first of all let's talk about
- 45:33um update help versus the way that we
- 45:35used to have it
- 45:36yeah okay so we used to ship the help uh
- 45:38with the product
- 45:39and uh turned out that that was there
- 45:41were all sorts of problems with that
- 45:42so basically the way microsoft works uh
- 45:45because we ship
- 45:46to hundreds of millions of people right
- 45:49um
- 45:49it really matters that the release is
- 45:51buttoned up right which is to say that
- 45:53you stop
- 45:54changing things and then you test and
- 45:56you test and you test and you test and
- 45:58then you release it
- 45:59so what ended up happening was um that
- 46:01just as soon as you're
- 46:02like finishing putting the finishing
- 46:04bits on the the code
- 46:05the documentation has to be done and and
- 46:08of course that doesn't work
- 46:10but now it's cooked like hey don't
- 46:11change it because you might break
- 46:12something
- 46:13so then it gets shipped and and the
- 46:16documentation there's differences
- 46:17between the documentation and the
- 46:19and the product and the answer used to
- 46:21be well you know hey just hang in there
- 46:23you know we'll release again in three
- 46:24years and we'll fix that well that's
- 46:25kind of a crummy answer
- 46:27and then there was a second problem the
- 46:28second problem is guess what the help
- 46:30is huge right because there's a ton of
- 46:32it
- 46:34and then would you say well geez i'm now
- 46:36going to a
- 46:37cloud world where i've got a gazillion
- 46:39machines i get a gazillion servers won't
- 46:42want to
- 46:42to use those be as efficient as possible
- 46:45with those servers
- 46:46and you don't need the help on all those
- 46:48servers right you need the help on the
- 46:49machine you're managing them from
- 46:51and to put the help on all those systems
- 46:53is just load you know bogging down those
- 46:55servers with
- 46:56stuff that you're not going to use so
- 46:58because of those two problems in windows
- 47:00or certain powershell version three
- 47:01we move to an updatable help model which
- 47:04is to say
- 47:05we ship and there's some very uh kind of
- 47:07like structural help
- 47:08that we generate based upon metadata
- 47:11you'll see some examples of that
- 47:13but then all the help text is available
- 47:16from download from
- 47:17from the internet so that's the way that
- 47:19works and and let me just say that
- 47:21in v2 one of the challenges was if
- 47:23you're using the help system and there's
- 47:24an example in there there was a
- 47:25possibility you know that maybe that
- 47:27example was wrong
- 47:28and i'll show you a way around that if
- 47:30you're in v2
- 47:31um to get the latest information for it
- 47:34but really the joy here with v3 is
- 47:36is as soon as microsoft updates a helper
- 47:39they find an issue
- 47:40my help gets updated on my management
- 47:42station so the first thing that we're
- 47:44going to do and then we're going to take
- 47:45a break here and just like
- 47:46can i give an example yeah so i don't
- 47:47know if you ever use wql
- 47:49yeah okay right so i can never remember
- 47:51wql
- 47:52i just can't it's one of those things
- 47:54well there's certain things that just
- 47:55never sink in for me wql is one of them
- 47:59and so constantly whenever i want to use
- 48:01that i'd have to do search and there's
- 48:02something about the
- 48:04search the content i can never find it
- 48:06on the internet either
- 48:07right and so at some point somebody had
- 48:09this exactly the same problem so they
- 48:10went
- 48:11on microsoft connect and said you ought
- 48:13to have an about topic for
- 48:15for wql and guess what they went and
- 48:18wrote one
- 48:18and so now we have an about wql and it's
- 48:21just there
- 48:21point was you didn't have to wait for
- 48:23another release you had a problem
- 48:26you told us about your problem and we
- 48:28responded and then in a matter of like
- 48:30well i forget how long that one took but
- 48:32there was one where somebody complained
- 48:34about an error in the documentation two
- 48:36days later we had an update
- 48:38so this is pretty pretty peppy it's
- 48:39continuous publishing and so what you
- 48:41want to make sure that you're doing is
- 48:43you're updating help and let me show you
- 48:44how to do that first of all
- 48:46you're going to need an internet
- 48:47connection now there is a way around
- 48:48that but let's just start off with the
- 48:49basic update help here and so we've got
- 48:51a commandlet for that called
- 48:52update as update get it dash
- 48:55what would you have how did you want to
- 48:57update yeah what do you want to update
- 48:58the help
- 48:59so the verb the noun so that's working
- 49:01out and i like to use dash force and
- 49:03guys
- 49:04this is something that you can run every
- 49:05single day to make sure you have the
- 49:07latest and greatest help
- 49:08and what it's going to do it's going to
- 49:09go out to the internet and it's going to
- 49:10download
- 49:11all of the help files that you need for
- 49:13all of the stuff that you have on your
- 49:14system see that progress
- 49:16bar says ooh which is what it should say
- 49:19in powershell
- 49:21so cool now look if you have a siri a
- 49:24bunch of machines that don't have direct
- 49:25access to the internet you can
- 49:27save this help with save
- 49:30help you can save this help you figured
- 49:33it out
- 49:34as a set of files and then you can
- 49:36update
- 49:37from that set of files but having the
- 49:39internet connection sure does make your
- 49:40life a lot easier
- 49:41now here's the idea we're going to take
- 49:44a break here
- 49:45and so what we want to do is make sure
- 49:47that you've got a powershell console up
- 49:49and make sure that
- 49:50you've updated help because when we come
- 49:53back we're going to start using
- 49:55my favorite things and let me just show
- 49:56them to you real quick
- 49:58get dash help which yep that's going to
- 50:01get us help on stuff
- 50:02but it's also going to help us search
- 50:05for stuff and so that's its most
- 50:06important thing
- 50:07before though we go i want to show you
- 50:10there's a difference you're going to see
- 50:11people use get
- 50:12dash help you're going to see people use
- 50:14help
- 50:15and you can see people use man and i
- 50:16want to show you that there's a
- 50:17difference between these two
- 50:19get dash help and i'm just going to pick
- 50:21a commandlet and what i'm going to do is
- 50:22i'm going to keep things real simple
- 50:23right now
- 50:24and i want you to notice my screen it
- 50:25scrolled all the way to the bottom
- 50:27now this is not a complete help file but
- 50:30we'll get to that
- 50:30after break but i want you to notice it
- 50:32scrolled all the way down to the bottom
- 50:34now watch the difference between
- 50:36using help on the same thing
- 50:40look at the bottom of the screen see how
- 50:42i've got that little more
- 50:44so i can and you probably heard that i
- 50:46can spacebar now and
- 50:48and move through the help file man does
- 50:50the same thing
- 50:51so man and i'll do get service
- 50:55gives you that same you know like you
- 50:57pipe to more kind of deal
- 50:58where you can pound your way through it
- 51:02use whichever one makes you happiest and
- 51:04probably today you should experiment i
- 51:06know i've got friends that are
- 51:08just help i always only use help i
- 51:12happen to be a get dash help kind of guy
- 51:14because i like it to scroll to the
- 51:16bottom of the screen the help system is
- 51:18a super discoverable
- 51:20great tool to help me find things
- 51:23and and let's do a couple of examples
- 51:25i'll start off and then you can join in
- 51:27guys this is this is going to be really
- 51:29awesome because and don't memorize
- 51:32or write down anything that we do yep i
- 51:34swear to god don't
- 51:35do it because that's kind of the whole
- 51:37point so let me give you an example
- 51:39first of all help
- 51:40has the ability to discover stuff and
- 51:42i'm gonna i'm gonna get help get dash
- 51:43help kind of guys so i'm gonna use git
- 51:45dash help
- 51:46and i wanna find out here's here's my
- 51:48here's my i wanna see if there's
- 51:49any commandlets that could help me work
- 51:51with
- 51:52services so i'm going to do star service
- 51:56star
- 51:57yeah by the way star is your friend star
- 51:59is a wild card and it says
- 52:01find anything at the beginning or find
- 52:03anything at the end match anything at
- 52:04the beginning or then
- 52:05yeah and make sure that when you mean
- 52:08wild card you use a wild card because
- 52:10some commandlets will let you
- 52:12not use the wild card and that's not a
- 52:14good practice to get into so
- 52:16oh my gosh look at all of these
- 52:17commandlets so many commandlets that
- 52:19have
- 52:19service in them whoa but now is where
- 52:22the fun begins
- 52:24look is there a commandlet that in this
- 52:27list that looks like
- 52:28it might retrieve or i don't know get me
- 52:31a list of services on my computer so
- 52:35yeah there happens to be one right here
- 52:37see get dash service
- 52:38it would probably get me a list of
- 52:41services
- 52:42show them the up arrow oh show me up
- 52:44here
- 52:46you can just use the up arrow now watch
- 52:48this now use the right arrow
- 52:50right left arrow left arrow and put a g
- 52:52in front of the star
- 52:53check this out now do it
- 52:57oh got a short list these wild cards are
- 52:59great the wild cards are great and
- 53:00actually knowing how to do a good search
- 53:02is really good
- 53:03oh this is great this is great so here's
- 53:06the idea and we're going to do this a
- 53:07couple times the idea is you
- 53:08search for and probably by noun you
- 53:11search for the thing that you want to
- 53:13find
- 53:13i want to know something about processes
- 53:15or i want to know something about
- 53:17services which are the examples i'm
- 53:18going to use a lot but it could be as
- 53:20simple as
- 53:21ad computers or something like that you
- 53:24search for what you want and when you
- 53:25find it
- 53:27well there's a help file for it so let's
- 53:28go in and take a look i'm going to do
- 53:30get help
- 53:31get dash service now this is the simple
- 53:34view of the help file and let me just
- 53:36show this to you real quick
- 53:37it gives you the name synopsis syntax
- 53:40which we're going to talk about here
- 53:41shortly
- 53:42gives you a description of what the
- 53:43commandlet does and some related
- 53:45links and information now this is not
- 53:48the full help so don't panic we're going
- 53:49to do the
- 53:50the full help but let's try this
- 53:52discovery thing again i want to do
- 53:53let's see get help and i want to find
- 53:56something that would oh and i'm going to
- 53:57use your trick i'm going to say that
- 53:58would uh
- 54:00g star something with
- 54:03a d computer in it because i want to
- 54:06i want to work with active directory
- 54:08computers oh
- 54:10look there's there's a command there get
- 54:12a d computer you know what i'm thinking
- 54:14i'm thinking in my head
- 54:15that's probably gonna solve my problem
- 54:16but to be sure what i'm gonna do is
- 54:19do get help get ad computer
- 54:23and take a look at it
- 54:27and again this is the simple help view
- 54:30and we'll get to a
- 54:31better ones here in just a second but so
- 54:33the concept is is pretty simple what you
- 54:36want to do
- 54:36is you want to discover what you want to
- 54:39work with
- 54:40and then look at the help for what you
- 54:41want to work with now the concept is
- 54:43simple but doing this
- 54:45seems to be a big challenge for a lot of
- 54:47folks i you have to become
- 54:49trusting in that this is how we do it
- 54:52and this
- 54:52actually works no matter what product
- 54:54you're working with
- 54:55think of what is it that you want to do
- 54:58something to what
- 54:58what's the noun that you want to find
- 55:01and
- 55:02then have help search for it yep sounds
- 55:05like a great way to get help to work for
- 55:06it yeah we very much
- 55:07tried to create a world where you could
- 55:09think about what you want
- 55:11type it and get it okay so let's just
- 55:13say you wanted to assign something well
- 55:15you'd look for a sign you wouldn't find
- 55:17that and you'd
- 55:18then quickly learn that we use the word
- 55:20set
- 55:21and so you'd say well okay so there's an
- 55:23infinite number of nouns
- 55:25but the verbs are pretty regular so
- 55:26imagine you wanted to get the help on
- 55:29the verbs like yeah you type you type
- 55:32who are go ahead okay so what you do is
- 55:35you say
- 55:36you say get verb
- 55:40and it shows you all the verbs and so
- 55:42these are all the verbs that you you
- 55:44you're going to learn and you see well
- 55:46how many are there so you might want to
- 55:47say well i'd get the verb
- 55:49i'd like to measure them and you see
- 55:51that there are 98 verbs
- 55:53and here you see we break them up into
- 55:55into
- 55:56you know um whether they're security
- 55:58verbs or communication verbs etc
- 56:01anyway so those you're going to learn
- 56:02those 98 things and then
- 56:04and then you're going to be able to
- 56:05think type and get what you want
- 56:07and what what happens often is you're
- 56:10not even going to learn all 98 of those
- 56:12you're just going to learn
- 56:13a few of them because you'll know that
- 56:14what the verbs will do for you and you
- 56:15end up looking for the nouns so
- 56:17it becomes a very easy process to follow
- 56:19through but let's start getting into
- 56:21what this help can do for us so once
- 56:23again i'm going to do this
- 56:24get help i want to find commandlets
- 56:27that'll
- 56:28retrieve me some services now notice
- 56:32well there's get service and so i want
- 56:33to take a look at what this
- 56:35can do for me so i'm going to do get
- 56:37help and get
- 56:39service again this is the simplified
- 56:41help view but there's more to help than
- 56:42just this
- 56:43once you've updated help this help can
- 56:46be extended or expanded upon and let me
- 56:48show you a couple of things this is
- 56:49where it gets oh
- 56:50just so happy for me because
- 56:53watch i'm going to do get help on git
- 56:55service but
- 56:56we have a parameter that will allow us
- 56:59to get
- 57:00detailed ooh detailed help
- 57:03and here's what detailed help is going
- 57:04to show us i'm going to scroll all the
- 57:05way back to the top
- 57:06and get service gives you the synopsis
- 57:10again the syntax which we're going to
- 57:11talk about in a second and the
- 57:12description this is what we saw before
- 57:14but here's this when we talk about
- 57:16syntax we're going to start talking
- 57:17about what these things are
- 57:18parameters these parameters change how
- 57:21the commandlet
- 57:22acts well i don't necessarily know what
- 57:25these things
- 57:26mean well when you go to detailed help
- 57:29look
- 57:30the parameters are listed here with an
- 57:32explanation of
- 57:34what they mean and so what you'll do is
- 57:36you'll
- 57:37actually be up here looking and going i
- 57:38have no idea what that is and then you
- 57:40can just scroll down and get a
- 57:41definition of the parameters
- 57:43also as i scroll down here i want you to
- 57:45notice something really interesting
- 57:48now we start to get examples now i want
- 57:50you to think about this for a second
- 57:51i've got a command called get dash
- 57:53service so let's think about what it's
- 57:54probably going to do i haven't run it
- 57:56yet
- 57:56it's good probably going to give me and
- 57:58if i read the description
- 57:59a list of all of the services on my
- 58:01computer
- 58:02whether they're running stopped or
- 58:04paused and it'll tell me about that
- 58:06how many examples of that do you really
- 58:08think we need
- 58:10well we need 11 of them and here's
- 58:13here's here's why i want to point this
- 58:15out we
- 58:16apparently we need 11 examples of this
- 58:18and there's a reason for this
- 58:20because the people that worked so hard
- 58:22on these help files
- 58:23knew that there were going to be all
- 58:25kinds of different ways that you're
- 58:27going to want to try to use this and
- 58:28they wanted to give you examples
- 58:29what happens is this is oftentimes
- 58:31you'll be thinking of a business problem
- 58:33or trying to solve a business problem
- 58:34and you'll say gee whiz let me go i
- 58:36found the command let me go look at the
- 58:37example
- 58:37you'll find an example that is really
- 58:40close
- 58:41to probably exactly what you wanted to
- 58:43do
- 58:44which is one of the cool things so a big
- 58:45shout out to all the folks that work on
- 58:47you know the other thing we did was
- 58:49there were a few of the ones we knew
- 58:50people were going to use a lot like get
- 58:51process boy you always want to spend
- 58:53time looking at get process
- 58:55because there what we did was we said
- 58:57hey get process get serviced people are
- 58:59going to use these a lot
- 59:00and so in our help and our examples we
- 59:02show you not just how to use get process
- 59:04and get
- 59:05service but we also show you some very
- 59:07common powershell techniques that then
- 59:09help you
- 59:10you kind of lead you to the next step
- 59:12you start off saying oh i'd like to get
- 59:13something to get services what do i want
- 59:15to do
- 59:16and then you say well geez actually i'd
- 59:17like to format it a little differently
- 59:19or i'd like to find these things filter
- 59:21and so we use those high volume topics
- 59:24to kind of go a little bit deeper to
- 59:26teach you the next level of powershell
- 59:28which is you're going to as we take you
- 59:30through learning all of this deep level
- 59:31part of powershell you're going to look
- 59:32at these help files in a totally new way
- 59:34and you'll see that
- 59:35examples of sorting and filtering and
- 59:38getting the kinds of information that
- 59:39you want and changing the kinds of
- 59:41information you want
- 59:42a lot of times writing the examples a
- 59:44lot of people the first thing they do
- 59:46is they go to examples as a matter of
- 59:47fact there is rather than detailed
- 59:49you have a parameter called examples
- 59:52that will take you right into just the
- 59:54examples if you want to get there real
- 59:55quick
- 59:56something else that you can do and this
- 59:59is going to become
- 1:00:00a big deal this afternoon as we work
- 1:00:02through this
- 1:00:03there's also full help i don't know
- 1:00:06jeffrey i don't know if they can handle
- 1:00:07the full help
- 1:00:08i mean that's that's that's an awful lot
- 1:00:10that's stress testing that says
- 1:00:12here we go full help put your seat belts
- 1:00:14on put your seat belts on
- 1:00:16um full help guys i'm going to tell you
- 1:00:18right now the full help is very similar
- 1:00:20to detailed except when you're in the
- 1:00:22parameters
- 1:00:23there's some special information and
- 1:00:24this is going to make in the next
- 1:00:26section when we're going to talk about
- 1:00:28what this information means to you it's
- 1:00:29actually very important to us
- 1:00:31and this will help us understand how the
- 1:00:33commands work in the pipeline and so
- 1:00:35we're going to talk about
- 1:00:36that stuff in a little bit so right now
- 1:00:38when you're running get help
- 1:00:40you can use detailed or you can use
- 1:00:42examples but
- 1:00:43a little bit later on you'll always end
- 1:00:45up using full
- 1:00:46now i want i promised you earlier that
- 1:00:48for the you folks that are running
- 1:00:49powershell v2
- 1:00:51and even if you're running v3 um
- 1:00:53sometimes if you're running v2
- 1:00:55your help files they're not up to date
- 1:00:57and you want the latest
- 1:00:59i need the latest and greatest
- 1:01:00information well you can't run update
- 1:01:03help if you're in v2 which is
- 1:01:04why on your admin box you should be
- 1:01:06running v3
- 1:01:08however let me just show you this is how
- 1:01:09we used to get around that
- 1:01:11microsoft helped us with this dash
- 1:01:15online i love this dash online
- 1:01:18looking what it just did takes me opens
- 1:01:20up a browser and takes me out look
- 1:01:22updated shows you when it was last
- 1:01:24updated and here's the full help
- 1:01:27for whatever it is that i was looking
- 1:01:29for in this case get service
- 1:01:31so again don't close that i'll lose the
- 1:01:34chat
- 1:01:35dash online now i can't show my favorite
- 1:01:38yeah because
- 1:01:39you i that oh i hope you do now this i
- 1:01:41was confused by this at first but
- 1:01:43go ahead but what well yeah i'll show
- 1:01:45you you go okay
- 1:01:46so let's talk to mine so here we do get
- 1:01:50get help help
- 1:01:53get service so here's the thing you can
- 1:01:56say
- 1:01:57examples right examples
- 1:02:00and they say oh that's cool let's let's
- 1:02:02let's run this let's let's let's let's
- 1:02:04uh
- 1:02:05let's do one of these okay and type that
- 1:02:08and by the way so you do you do enter
- 1:02:11and then left mouse button and okay
- 1:02:14great now you want to do the next one
- 1:02:16oh well so you see the workflow's all
- 1:02:20messed up
- 1:02:21so what you can do is you can say
- 1:02:25get help minus show show window
- 1:02:29and look here comes up in a window okay
- 1:02:32now this has all sorts of great stuff
- 1:02:35one of these is
- 1:02:36settings and you say hey i want to just
- 1:02:39see
- 1:02:40i don't want to see all this stuff i
- 1:02:42just want to see
- 1:02:44the examples look at all the stuff you
- 1:02:46can have control over
- 1:02:48it's amazing to me so now you just go
- 1:02:50here
- 1:02:51cut paste sorry paste
- 1:02:56and do that and then the next one
- 1:03:01cut paste and so it's a very nice
- 1:03:04workflow
- 1:03:05much nicer workflow so again that is
- 1:03:08this
- 1:03:08this show window
- 1:03:12and you'll see there's some really fun
- 1:03:14stuff with show window can i spend some
- 1:03:15more time with you
- 1:03:16absolutely okay so now let's turn all
- 1:03:17this back on there
- 1:03:19okay so you see it's got lots of stuff
- 1:03:22here
- 1:03:24okay so now in the show window you can
- 1:03:27do things like remember i said what is
- 1:03:29it
- 1:03:29anyway you've got to find here right so
- 1:03:32you can find stuff like
- 1:03:33dependent depend
- 1:03:36okay and so notice it gets highlighted
- 1:03:38and it says here
- 1:03:39it says 18
- 1:03:43matches okay and
- 1:03:46and it could search i don't do that very
- 1:03:48well anyway so then you can start
- 1:03:50searching for these things
- 1:03:51and so it's it's super nice i and i
- 1:03:54think the addition of this this was
- 1:03:55added to v3 and i think the addition of
- 1:03:57this
- 1:03:58is really phenomenal because guys let me
- 1:03:59show you um traditionally
- 1:04:02you're going to spend so much time in
- 1:04:04the help file and you're going to want
- 1:04:06to do just that you're going to want to
- 1:04:07cut and paste from a help file or you're
- 1:04:09going to want to read a help file while
- 1:04:11you're working in powershell
- 1:04:12that a lot of times what a lot of guys
- 1:04:14would do is if you take a look at my
- 1:04:15screen i'm gonna
- 1:04:16well yeah i'm just gonna launch two
- 1:04:18powershell sessions now if you have two
- 1:04:19monitors
- 1:04:20this is great right so you do help in
- 1:04:22one
- 1:04:23and then you can work in another one but
- 1:04:25with v3
- 1:04:27having the show window stuff
- 1:04:32well first of all it fits better on your
- 1:04:33screen it's easier to move around
- 1:04:35you can have the help it's easier to get
- 1:04:37stuff out the part that always confuses
- 1:04:39me is
- 1:04:40and then we're going to fix this later
- 1:04:41when we start talking about the magical
- 1:04:43ise but it's it's the cut in the pace
- 1:04:46man
- 1:04:47it's that whole yeah it's that right
- 1:04:49clicking and
- 1:04:50stuff in the console why can't we fix
- 1:04:52that why can't we fix that why can't we
- 1:04:53fix
- 1:04:54that that that console because it's
- 1:04:57horrible
- 1:04:58yes that's the answer no so here's the
- 1:05:01thing
- 1:05:01here's the thing so let me give you a
- 1:05:03little
- 1:05:04tutorial about some of the behind the
- 1:05:07scenes stuff at microsoft so
- 1:05:08there was some point where people said
- 1:05:10oh you know microsoft stopped
- 1:05:13advancing i.e you know oh that just
- 1:05:15proves what bad guys they are
- 1:05:17there's no competition they stop
- 1:05:19innovating no no no my friends honestly
- 1:05:21that's not what happened
- 1:05:22what happened was um was that it got to
- 1:05:25the point where every time we made a
- 1:05:27change
- 1:05:28uh we broke a bunch of people right
- 1:05:30right and so then it's like well
- 1:05:31people are like hey jerks stop breaking
- 1:05:34us
- 1:05:35and so and so they stopped doing that
- 1:05:38and then all of
- 1:05:38a sudden some competitors got up there
- 1:05:40and so now they went and started
- 1:05:42doing things even though sometimes
- 1:05:44things break
- 1:05:45same thing happens with the console
- 1:05:46window the console window man
- 1:05:48every time you change that thing you
- 1:05:50break tons of people
- 1:05:52you just break tons of them and so you
- 1:05:54don't want to change that thing very
- 1:05:56much now here's the thing
- 1:05:57actually i'm pretty hostile to the
- 1:06:00console window
- 1:06:01okay so that's it i'm trying to make
- 1:06:02this thing die i'll just be
- 1:06:05straight up about it make it y die and
- 1:06:07why is that and the answer is
- 1:06:09that there are these things called
- 1:06:10console apps okay now a console app
- 1:06:13only works in the console now here's why
- 1:06:16i want to kill the console because i
- 1:06:18want to kill
- 1:06:18console apps and it turns out that the
- 1:06:21reason i want to kill console apps is
- 1:06:23you go and you write you do something on
- 1:06:24the console app and it writes directly
- 1:06:26onto the console
- 1:06:28which means you cannot automate it okay
- 1:06:30you can't
- 1:06:31run something get its output process the
- 1:06:34output and do something with it because
- 1:06:36it writes directly on the screen
- 1:06:38so this is just evil incarnate it is the
- 1:06:41enemy of automation so we're trying to
- 1:06:42get rid of those things
- 1:06:44so we're trying to uh get everybody on
- 1:06:46to powershell ise
- 1:06:48which is a much richer investment so by
- 1:06:50the way stop
- 1:06:51asking me to fix the console i'm not
- 1:06:53going to fix the console
- 1:06:54and that's the point that i want is that
- 1:06:56the console and look i know cut and
- 1:06:58pasting in the console and some guys ago
- 1:07:00the console's driving me nuts a little
- 1:07:01bit later on today we're going to help
- 1:07:02you with
- 1:07:04well he hates it and so there's actually
- 1:07:06a really cool solution to it but i want
- 1:07:07you to wait till we get there with the
- 1:07:08isc
- 1:07:10so to cut and paste in the console is
- 1:07:13if you haven't done it yep it's you
- 1:07:15highlight it you right click
- 1:07:17and then you can right click again so no
- 1:07:20control c no control v
- 1:07:22in this puppy i think we
- 1:07:25may have something cooler for you later
- 1:07:26on but right now
- 1:07:28that's how you do it so right click and
- 1:07:30right click will take care of it for you
- 1:07:32jeffrey you know what we need to do we
- 1:07:33need to start to take a look at
- 1:07:36and explaining syntax because here's the
- 1:07:40thing
- 1:07:40everybody wants to work with uh
- 1:07:43commandlet but
- 1:07:44you know commandlet's going to do great
- 1:07:45stuff for you but sometimes you want the
- 1:07:47commandlet to
- 1:07:48alter its output or change what it's
- 1:07:51actually doing for you you know get
- 1:07:52service is great but it's going to give
- 1:07:54you a list of all your services
- 1:07:56i maybe i just want the one called bits
- 1:07:58or something like that
- 1:08:00so the syntax of the command will
- 1:08:02explain to you the options that you have
- 1:08:04available
- 1:08:05to control the commandlet and so at
- 1:08:07first it looks very very confusing now
- 1:08:09we've got slides for this and so it's
- 1:08:12all in the slide deck
- 1:08:13but let's take a look here i've got get
- 1:08:15service up right now and i'm going to
- 1:08:16take a look at something pretty simple
- 1:08:17you know
- 1:08:18if you do this in show window it comes
- 1:08:19out better you like it in show window
- 1:08:21better yeah
- 1:08:21cause watch do it oh you oh no you're
- 1:08:23doing it let's see
- 1:08:26let's do show window see because one you
- 1:08:29got the zoom there
- 1:08:31down at the bottom did you ever notice
- 1:08:33that
- 1:08:35oh yeah yeah
- 1:08:38let's see and so the nice thing is that
- 1:08:39it highlights some things so it's a
- 1:08:41little i think it's a little bit easier
- 1:08:42to read
- 1:08:42very easy and it's easier to select and
- 1:08:45say
- 1:08:47okay so we're going to use we're going
- 1:08:48to use this instead this is much better
- 1:08:50so take a look at this right here see
- 1:08:52the thing with the dash in front of it
- 1:08:54so you'll notice that i've got a command
- 1:08:56lit
- 1:08:57and then it starts followed by all of
- 1:08:58this magical characters we're going to
- 1:08:59explain what all these characters are
- 1:09:01but the first thing i want you to notice
- 1:09:02is look how many times under syntax
- 1:09:05i see the name of this command line i
- 1:09:06see it three times now jeffrey
- 1:09:08technically this is called
- 1:09:09parameter sets but parameter sets why am
- 1:09:12i seeing three of these
- 1:09:13yes so here's the thing imagine uh take
- 1:09:15a look at the net command
- 1:09:17right there's net use and net view
- 1:09:20et cetera these are different parameter
- 1:09:23sets
- 1:09:23and what happens is when you type net
- 1:09:25view you get one set of functionality
- 1:09:27when you type net use you get a
- 1:09:29different set of functionality
- 1:09:30so what happens is that that then they
- 1:09:33reuse the word the command net
- 1:09:35now that's essentially what a parameter
- 1:09:38set is now we take a different take on
- 1:09:40it
- 1:09:40net use is extremely different
- 1:09:43functionality than net
- 1:09:44use okay so we don't like that we want
- 1:09:47to be
- 1:09:48clear but the point about get service is
- 1:09:50that there are different parameter sets
- 1:09:52sometimes you want to say
- 1:09:53get service based upon its name or
- 1:09:56you're going to say i want to get
- 1:09:57service based upon its display name
- 1:10:00okay so those are two different
- 1:10:01parameter sets so a better example would
- 1:10:03be
- 1:10:03get process sometimes you want to say
- 1:10:05get process
- 1:10:06whose name is this sometimes you want to
- 1:10:09say get process whose id
- 1:10:11is this or sometimes you're going to
- 1:10:13just say get process
- 1:10:14and get them all and get them all yeah
- 1:10:16so those are different parameter
- 1:10:17sets and let me show you what jerry's
- 1:10:19talking about is notice in these
- 1:10:21three different get services and yeah
- 1:10:22don't worry we'll take a look at get
- 1:10:23process too
- 1:10:24and these three different get services
- 1:10:25look at this one this one has dash name
- 1:10:28down here in these other two you don't
- 1:10:30see dash name
- 1:10:31this one has dash display name you don't
- 1:10:33see that in the other two so that's what
- 1:10:36makes that particular parameter set
- 1:10:39unique and matter of fact i'm going to
- 1:10:40demonstrate these here in just a second
- 1:10:42but again look at these dashes
- 1:10:45these dashes indicate that they're
- 1:10:47parameters
- 1:10:49dashes parameters parameters will allow
- 1:10:52you to change the results of what the
- 1:10:54command is going to do and i want to do
- 1:10:55an example for you let's take a look at
- 1:10:57dash
- 1:10:57name i want you to notice it's followed
- 1:10:59by these characters here i just kind of
- 1:11:01go like this call them chihuahuas or
- 1:11:03something like this
- 1:11:05that's the technical term not many
- 1:11:08people knew that i
- 1:11:09i didn't realize that the official
- 1:11:11technical term now is
- 1:11:13um and what this is is this is the kind
- 1:11:16of values that you can
- 1:11:18give this we're getting in trouble with
- 1:11:20hr on that one really
- 1:11:22okay these things well no
- 1:11:25like pac-man pac-man pac-man so these
- 1:11:28can can be now these are the values
- 1:11:32that you can give to the parameter and
- 1:11:34i'm going to show you so let me let me
- 1:11:35give you a quick example here let me
- 1:11:37lower this uh well i'm not going to
- 1:11:38lower it down i'll just do it here watch
- 1:11:40i'm going to do git service and i'm
- 1:11:41going to use one of the parameters now
- 1:11:43parameters always begin with a dash
- 1:11:45so make sure you always put a dash in
- 1:11:47front of the parameters and now i'm
- 1:11:48going to put in
- 1:11:49a value that would be inside those
- 1:11:51chihuahuas and it said that the value
- 1:11:52type was string which means alphanumeric
- 1:11:55and i'm going to put in the name or
- 1:11:57which is a short name of a service i'm
- 1:11:58going to do
- 1:11:59bits instead of getting the entire
- 1:12:02service list
- 1:12:03this parameter now is going to allow me
- 1:12:05to just get the service that i want so
- 1:12:08here's the idea parameters can have
- 1:12:11these arguments on them
- 1:12:12and a lot of parameters can take
- 1:12:14multiple arguments let me show you what
- 1:12:16that looked like let's say
- 1:12:17i wanted two services notice the comma
- 1:12:21in between now the space is optional but
- 1:12:23see if you put a space there makes it
- 1:12:24easier to read
- 1:12:26now i get those two let me show you how
- 1:12:29that looks
- 1:12:29in the syntax and so let's go back here
- 1:12:32notice up here at dash name
- 1:12:34that's the parameter then we have the
- 1:12:36chihuahuas with the
- 1:12:38type of data that we can put in there
- 1:12:40the value type see these guys inside
- 1:12:43these guys and they've got to be doing
- 1:12:44close together because we've got
- 1:12:46these guys and we've got these guys
- 1:12:48these chihuahuas
- 1:12:50i just call them bankies because they're
- 1:12:51inside yeah so you've got chihuahuas and
- 1:12:54inside the chihuahuas you have these
- 1:12:56binkies if you see binkies in there
- 1:12:59that means it can take multiple values
- 1:13:01separated by a comma
- 1:13:03now i'll show you some stuff later where
- 1:13:05you won't see the internal binky
- 1:13:07and so boy there's going to be a whole
- 1:13:09phrase book now
- 1:13:10um and so can only take one value and
- 1:13:13this is very important for you to be
- 1:13:14able to know
- 1:13:15but here's the part where it starts to
- 1:13:16get a little confusing let me do
- 1:13:19a a little demonstration here of dash
- 1:13:22name
- 1:13:24with multiple values which i just did
- 1:13:25but let me show you something else
- 1:13:28this isn't the confusing part i'm going
- 1:13:29to ask jeffrey about this confusing part
- 1:13:31again you can do wild cards so dash name
- 1:13:34b star means i'm going to get all the
- 1:13:36services listed
- 1:13:37that begin with b by the way there's no
- 1:13:39conflict between
- 1:13:40wild cards and arrays or collections
- 1:13:43so do this do that up arrow now do oh
- 1:13:47now comma c star
- 1:13:50oh yeah yeah this is oh yeah that's a
- 1:13:51great point yeah great point so now i
- 1:13:53get both
- 1:13:54the ones that begin with b's and with
- 1:13:56c's and c that's awesome that's totally
- 1:13:58awesome
- 1:13:59so oh i closed my show window so let me
- 1:14:01go up here
- 1:14:03and open up the show window here's the
- 1:14:06part where i start getting kind of
- 1:14:07confused here and
- 1:14:08this this originally kind of threw me
- 1:14:10off as i want you guys to notice this
- 1:14:11guy down here
- 1:14:13computer name and i want you to notice
- 1:14:14what's around computer name
- 1:14:16see these brackets that surround both
- 1:14:19the parameter
- 1:14:20and the argument there so it's not the
- 1:14:22internal binkies inside of chihuahuas
- 1:14:24it's these things that surround
- 1:14:26either the parameter or the parameter
- 1:14:28and its argument
- 1:14:30this means you don't have to use it it's
- 1:14:32optional
- 1:14:33but wait we're not done yet and a great
- 1:14:36example is is
- 1:14:37take a look at this first syntax
- 1:14:40this uh syntax up here
- 1:14:44notice that everything has these
- 1:14:47around it which means that there's
- 1:14:49nothing
- 1:14:50actually required that i type in notice
- 1:14:53i've got them around here
- 1:14:54got them around here and every single
- 1:14:57one of them
- 1:14:58optional that means alls i need to do
- 1:15:02or all i have to do is type get service
- 1:15:07and it gives me a whole list in other
- 1:15:08words no parameters were required
- 1:15:11but take a look at this
- 1:15:16inside the syntax look at this second
- 1:15:18syntax
- 1:15:20i want you to notice look at this guy
- 1:15:21down here
- 1:15:24see how display name doesn't have these
- 1:15:27around it well that means if you're
- 1:15:29going to use display name
- 1:15:31you you've got to put it in and then
- 1:15:33you've got to give me a value for it
- 1:15:35now here's an example display name by
- 1:15:38the way
- 1:15:39is the long name
- 1:15:42so it's this really long name
- 1:15:45and i can get services by that display
- 1:15:48name but i want you to notice that
- 1:15:49you've got a choice dash name or
- 1:15:53dash display name so get service
- 1:15:56dash display name and now i can type in
- 1:16:00whatever long
- 1:16:01lengthy and i'm just making it up
- 1:16:03display name that i want to type in but
- 1:16:06if you're going to use display name now
- 1:16:07you have to use display name and the
- 1:16:10value that goes with it that's what gets
- 1:16:12you into that other syntax
- 1:16:14let's do something else let's do stop
- 1:16:17wait you didn't
- 1:16:17you know yeah so here's the thing yeah
- 1:16:19so imagine
- 1:16:21you wanted to get like do a get service
- 1:16:24b star
- 1:16:26just v star b oh b star
- 1:16:30okay so look at this the name for
- 1:16:32bitlocker drive encryption
- 1:16:34service is bdesv now remember we said oh
- 1:16:38well you want to create a world where
- 1:16:40you think about what you want you type
- 1:16:41it and you get it
- 1:16:42how many of you are thinking oh i want
- 1:16:44to get the bde
- 1:16:46svc service right like wow
- 1:16:49so no you want bidlocker okay so then
- 1:16:52you want to say okay well get service
- 1:16:54might display
- 1:16:55bit no you can't type bitlocker it's
- 1:16:58bitlocker
- 1:16:59drive encryption service so
- 1:17:02so remember powershell is great because
- 1:17:06i'm flawed i can't remember b d
- 1:17:09e s v c and i'm definitely not going to
- 1:17:12remember
- 1:17:12bitlocker drive encryption service and
- 1:17:14look even if i could
- 1:17:16remember it i can guarantee you i cannot
- 1:17:18i'm like
- 1:17:19incapable of typing that correctly so
- 1:17:23what you do is you type display name
- 1:17:26bit star no just bits oh just bit star
- 1:17:29yeah dead star
- 1:17:31something to do with bitlocker a doom
- 1:17:33and it just works
- 1:17:34it got us by the long name which
- 1:17:36actually makes more human
- 1:17:37sense than those little tiny short names
- 1:17:39see one of the things we said was
- 1:17:41with powershell it's like programming
- 1:17:43with with uh
- 1:17:44hand grenades versus sniper rifles you
- 1:17:47know
- 1:17:47it's just sort of just sort of like over
- 1:17:49there i don't know if i ever told you
- 1:17:50that story
- 1:17:52my buddy out of college i uh
- 1:17:55my roommate used to be in vietnam he was
- 1:17:57vietnam 18
- 1:17:58special forces and no it's actually the
- 1:18:01other guy i worked with he was a navy
- 1:18:02seal
- 1:18:02and the navy seals get their own weapons
- 1:18:05right so everybody else like you're this
- 1:18:06kind of guy you get this kind of weapon
- 1:18:08the navy seals
- 1:18:09like the the gun manufacturers would
- 1:18:11make them guns and he talked about this
- 1:18:12thing
- 1:18:13i never quite got it in focus but it's
- 1:18:15basically sort of like a machine gun
- 1:18:17shotgun a machine shotgun he said and
- 1:18:20the great thing about that was is
- 1:18:21in vietnam you hit the the jungle and
- 1:18:24you sort of only had to know what like
- 1:18:26was my problem
- 1:18:26over there or over there and you'd set
- 1:18:29up with this thing
- 1:18:30and he says you'd let loose with it and
- 1:18:32three seconds later your problem was
- 1:18:34gone or everything between you and your
- 1:18:35problem was
- 1:18:36gone you could focus in on your problem
- 1:18:38well that's the same sort of thing you
- 1:18:39just sort of like
- 1:18:40hey bit locker is something to do with
- 1:18:43bitlocker bit
- 1:18:44star star and so that's the kind of the
- 1:18:47model we're trying to go for
- 1:18:48is you know just sort of over here or
- 1:18:50sort of over there now there are times
- 1:18:52when you need to be precise
- 1:18:53and you can be precise and there are
- 1:18:55times where just sort of like over there
- 1:18:56is good enough and by the way
- 1:18:58when you need both uh you'll see how we
- 1:19:00deal with that so through something
- 1:19:01called minus
- 1:19:02what if and minus confirm yeah yeah yeah
- 1:19:04and so oh and jeffrey what i need
- 1:19:06you to help me with is this is the um
- 1:19:11this is the one that seems to throw most
- 1:19:13people off
- 1:19:14so a dash means that you have a
- 1:19:18parameter and if it's followed by
- 1:19:19chihuahuas that means you can put
- 1:19:21arguments on it and you get the value
- 1:19:23type of the argument string
- 1:19:24and that kind of thing and if it's got
- 1:19:26binkies in there you can take multiple
- 1:19:28arguments
- 1:19:29separated by a comma you see plenty of
- 1:19:31examples of us doing that
- 1:19:32and if you're surrounded by these
- 1:19:34brackets i you don't have to it's
- 1:19:36optional you don't have to do it at all
- 1:19:38but there's something tricky here in
- 1:19:40this view yeah
- 1:19:41let's look at this guy look at this dash
- 1:19:43name this guy's it
- 1:19:44throws everybody off so i it i don't
- 1:19:46have to type this in i don't type
- 1:19:47anything in because
- 1:19:48we all know that i can just run get
- 1:19:49service and get all of them but
- 1:19:52if i'm using dash name and i want to
- 1:19:54specify a name of a service
- 1:19:56like bits what is it with these little
- 1:19:59duders inside here yeah
- 1:20:00this is something we call positional
- 1:20:02parameters okay
- 1:20:03and so that means that if you just
- 1:20:05specify the value
- 1:20:07uh you don't have to specify dash name
- 1:20:10so
- 1:20:11so this makes so watch
- 1:20:14get service i can do this
- 1:20:18you might be saying i gotta type a lot
- 1:20:22actually you don't have to type a lot
- 1:20:23but here's what positional means
- 1:20:26if you're gonna give me a bunch of names
- 1:20:29of services
- 1:20:30you don't have to use dash name see
- 1:20:32works the same way which means
- 1:20:34so those brackets around the parameters
- 1:20:36simply mean you don't have to use the
- 1:20:38parameter but you got to give me the
- 1:20:39argument that's what makes it
- 1:20:40oh and it gets even better because now
- 1:20:42you can just type gsv
- 1:20:44oh yeah you can use the alias to even
- 1:20:47shorten it up even for so watch
- 1:20:49do you want to go ahead and do that is
- 1:20:51it gsv
- 1:20:53bits and so here's kind of a key kind of
- 1:20:56principle of powershell
- 1:20:57okay the principle is we want to have
- 1:20:59this very regular
- 1:21:01very uh self-describing surface okay
- 1:21:04so when it's three o'clock in the
- 1:21:06morning and things didn't go the way you
- 1:21:08wanted to
- 1:21:09and uh during some it upgrade and you
- 1:21:11bring up some script
- 1:21:13you want that script to be absolutely
- 1:21:16readable you want to know what's going
- 1:21:17on
- 1:21:18okay and so that's why powershell is
- 1:21:20very clear you know
- 1:21:21get dash service dash name et cetera so
- 1:21:24that when you're reading it you know
- 1:21:25exactly what's going on
- 1:21:26on the other hand when you're
- 1:21:28interactive
- 1:21:30you can type that if you want and we
- 1:21:31make it easier to type that with things
- 1:21:33like tap completion but sometimes you
- 1:21:35just want to go go go go
- 1:21:36and so we have all these uh shortcuts
- 1:21:39and aliases so that you can be
- 1:21:40very very productive as a high-speed
- 1:21:43advanced interactive user
- 1:21:45but then when you go and write scripts
- 1:21:47we encourage the more verbose style
- 1:21:50as a matter of fact let's just to
- 1:21:51emphasize on that a little bit further
- 1:21:54so when you're writing scripts this is
- 1:21:55the way that you're going to want to do
- 1:21:56it here in the top example you're going
- 1:21:57to want to be
- 1:21:58very uh explanatory of what you're doing
- 1:22:02but as jeffrey was saying when you're at
- 1:22:03the console
- 1:22:05free reign i mean if you can use aliases
- 1:22:07and shorten this up with the positional
- 1:22:09parameters so that you can quickly get
- 1:22:11things done you're going to see examples
- 1:22:12of that today because
- 1:22:13jeffrey uses an awful lot of aliases and
- 1:22:16i usually
- 1:22:17because i'm getting ready to automate it
- 1:22:19sometimes i just do the whole thing the
- 1:22:21first time through
- 1:22:22where i use all the parameters and all
- 1:22:24the arguments so you're going to see
- 1:22:26that contrast between
- 1:22:27working quickly interactively with the
- 1:22:29short
- 1:22:30you know short versions and then the
- 1:22:32long versions that you're going to want
- 1:22:33to see in a script but let me give you a
- 1:22:34hint and then we'll do another example
- 1:22:36and and then
- 1:22:37take a look at how to work with all of
- 1:22:38this um
- 1:22:40um have you guys been hitting the tab
- 1:22:42key you take your pinky
- 1:22:44take a pinky if you're a touch typist
- 1:22:47this is this is probably not
- 1:22:48for you but this pinky she's showing you
- 1:22:51the official flexing
- 1:22:53moves yeah yeah you want to make sure
- 1:22:54you stretch you want to warm it up at
- 1:22:55the beginning of every day
- 1:22:56stretch it stretch the pinky and you
- 1:22:58want this pinky to hover
- 1:23:00right over the tab key always because
- 1:23:02what you want to do is
- 1:23:03watch get s e i i'm going to start
- 1:23:05hitting attack key look look look look
- 1:23:07let's start going through the
- 1:23:08commandments we've got so many
- 1:23:09commandments now it's a lot of them to
- 1:23:10go through
- 1:23:11there we go wait a minute shift tab goes
- 1:23:12backwards watch dash
- 1:23:14i'm going to hit the tab key it'll cycle
- 1:23:16through the parameters for me
- 1:23:18this oh this is cool remember i said we
- 1:23:20make it easier to help type this stuff
- 1:23:22out that's what he's talking about and
- 1:23:23so
- 1:23:23look in just about as many keystrokes
- 1:23:26as doing like gsv uh bits
- 1:23:30just a couple of more and i can bang
- 1:23:32this out and get it to look
- 1:23:34really nice and clean so that if i'm
- 1:23:36going to use this in a script so the tab
- 1:23:37key is your friend
- 1:23:39use the tab you're going to see us use
- 1:23:40it all the time today
- 1:23:42let me show you another example of
- 1:23:43finding something as kind of a summary
- 1:23:45here of finding a commandlet
- 1:23:48and then taking a look at its syntax and
- 1:23:50then we're going to show you how to
- 1:23:51start to put commandments together on
- 1:23:52the pipeline so
- 1:23:53let's do this i have this business
- 1:23:56problem
- 1:23:57business problem time and my business
- 1:23:59problem is
- 1:24:00i need to get um
- 1:24:03i need some errors i need the i need the
- 1:24:06newest errors
- 1:24:08the newest five errors um out of my
- 1:24:11system log
- 1:24:11oh yeah so i need to be able to look at
- 1:24:13my event the log file
- 1:24:14yeah the log file so i'm thinking i need
- 1:24:16to look at my event logs i wonder if
- 1:24:19powershell
- 1:24:20has a commandlet that can help me with
- 1:24:23my event logs so get help
- 1:24:24star well let's see do you have anything
- 1:24:27with event logs
- 1:24:28oh and lo and behold there are plenty
- 1:24:32as a matter of fact this is a great time
- 1:24:33now you can take a look at the verbs
- 1:24:36you can just guess what what do you
- 1:24:37think clear event log's going to do
- 1:24:39would you
- 1:24:40clear it i i i bet it would clear it too
- 1:24:42you know what do you think get event log
- 1:24:44is going to do
- 1:24:46ta-da it's going to i know it seems
- 1:24:48ridiculous but this is the point is
- 1:24:50you're looking at the verbs and figuring
- 1:24:52out what they're going to do and it's
- 1:24:53not that difficult at this point
- 1:24:55now what we're going to do is i want to
- 1:24:57get an event lock now i can just try to
- 1:24:59run this but
- 1:24:59i want to take a look at the help file
- 1:25:01first so i'm going to do get help on get
- 1:25:03event log and i want to take a look at
- 1:25:06the syntax
- 1:25:07and i also if i have questions about the
- 1:25:09parameters i want to be able to see the
- 1:25:10definitions of those parameters so i'm
- 1:25:12going to do dash detailed right now
- 1:25:14and i'm going to go up here and go hey
- 1:25:17here's git event log
- 1:25:20take a look at the syntax look get event
- 1:25:22log look at all of these parameters see
- 1:25:24the dashes
- 1:25:26see the arguments that they can have
- 1:25:27whether they can have multiple values
- 1:25:29and if you don't know what something is
- 1:25:31like
- 1:25:32i wonder what newest means you can
- 1:25:34scroll down and you can take a look down
- 1:25:36here and the reason i'm going through
- 1:25:37this is
- 1:25:38this is what we all have end up doing is
- 1:25:40i don't know necessarily what all the
- 1:25:42parameters mean so a lot of times i go
- 1:25:43to the list and i
- 1:25:44read the list of parameters first
- 1:25:47just to find out what capabilities i
- 1:25:49have i know that seems like it may take
- 1:25:51a few extra minutes but it's worth it
- 1:25:53because i found
- 1:25:54that newest means i can get the newest
- 1:25:57entries in the log but also take a look
- 1:26:00at something else in this syntax
- 1:26:01oops where'd he go look at all of the
- 1:26:04things that are
- 1:26:05optional but i want you to notice
- 1:26:07something looking up here
- 1:26:09i want you to notice that dash log name
- 1:26:12isn't required but
- 1:26:14this guy is i want you to see what
- 1:26:16happens when
- 1:26:18something is mandatory and you try to
- 1:26:20run it so if i just tried to run get
- 1:26:22event like i want you to think about
- 1:26:23this if this worked just like this
- 1:26:25think about all of the it's going to go
- 1:26:27through all the logs and spit all of the
- 1:26:29logs out on my screen
- 1:26:31could that be a little performance issue
- 1:26:34especially if you're doing it
- 1:26:36to 50 machines at once that's now called
- 1:26:38big data
- 1:26:39yeah that's right big data
- 1:26:45so watch i'm going to strike enter and
- 1:26:48powershell smart enough to go hey look
- 1:26:51you need to know what log you want to
- 1:26:52look in so we're going to
- 1:26:54make you tell us what log so i'm going
- 1:26:56to say system now of course it's now
- 1:26:58going to give me the entire system log
- 1:27:00but let me just show you by using the
- 1:27:03help file
- 1:27:04looking at the examples reading the
- 1:27:05parameters you can start to make
- 1:27:07solutions
- 1:27:08like this get event log i know once a
- 1:27:11log name
- 1:27:11i want the log name system i also know
- 1:27:13that i want the newest i think you can
- 1:27:15tab complete that too
- 1:27:18i think you can now too yeah wait a
- 1:27:19minute let's try it didn't used to be
- 1:27:21able to do that let's see
- 1:27:23oh look is that cool that is totally
- 1:27:25cool
- 1:27:26i noticed that a lot in v3 that you can
- 1:27:28now tab complete on a lot of the things
- 1:27:29that the system has i think
- 1:27:31another reason you should be using v3
- 1:27:32yeah um yeah right that's a v3 is on
- 1:27:35not on v2 ism yeah so i know that by
- 1:27:38looking at the help file the newest will
- 1:27:40let me get the newest i'm just going to
- 1:27:41say
- 1:27:41three entries but here's the thing you
- 1:27:43guys know this in a log file there's a
- 1:27:45lot of that information
- 1:27:46stuff and i don't want that just so
- 1:27:48happens if you look at the help file
- 1:27:50you'll find that entry type error
- 1:27:53that's going to give me the three latest
- 1:27:56errors now you might be thinking to
- 1:27:58yourself
- 1:27:59well that's not you know that's cool but
- 1:28:01you know i had to do a lot of reading i
- 1:28:02could have just
- 1:28:03opened up you know the graphical for
- 1:28:05this
- 1:28:06oh yeah but watch this
- 1:28:10thing is this there's a parameter here
- 1:28:13called computer name
- 1:28:14i want the latest three errors from
- 1:28:18three different computers um
- 1:28:21here's the thing i i you need to kind of
- 1:28:24get from all of this you can't open the
- 1:28:27graphical
- 1:28:28fast enough more or less get that data
- 1:28:31that quick
- 1:28:33so in this one command that i figured
- 1:28:36out
- 1:28:37i can get errors from multiple computers
- 1:28:41on my display now it's on my display
- 1:28:45and we're going to fix that here in this
- 1:28:46next section because maybe i don't want
- 1:28:48it on my display
- 1:28:49maybe i want it i don't know in a web
- 1:28:52page
- 1:28:53or a csv or something like that but
- 1:28:56they missed the look show that again a
- 1:28:59web page
- 1:29:00that's why i turned it differently
- 1:29:03so so i've used the help file to build
- 1:29:07one great command
- 1:29:08and now we want to start doing more with
- 1:29:10it so
- 1:29:11to kind of wrap this up here i've got
- 1:29:13some slides in here and like i said
- 1:29:15everything that we've been doing is
- 1:29:16is in the slide deck so let me just kind
- 1:29:18of thumb through here the slides again
- 1:29:20questions you missed something crucial
- 1:29:22did i yeah what are you going to go back
- 1:29:24to that uh
- 1:29:25the wild card help go interactive
- 1:29:28all right would you which good lord here
- 1:29:30go to mine
- 1:29:33he said get help help star
- 1:29:36event log okay and pointed out oh look
- 1:29:39here you got clear you got get
- 1:29:41limit but look here about oh i forgot to
- 1:29:45talk about the about hell yeah no this
- 1:29:47is like one of the most important things
- 1:29:49it's about event logs okay
- 1:29:51so these are what we call conceptual
- 1:29:53topics okay
- 1:29:54so you say okay clear screen and then by
- 1:29:57the way here's a trick i do right so if
- 1:29:59i did
- 1:29:59clear here's thing so now i want to see
- 1:30:01this if i do clear screen
- 1:30:03and then what was it i was going to do
- 1:30:05oh shoot so what you do
- 1:30:07all right because again i'm flawed right
- 1:30:09now it's about
- 1:30:10something okay so here so what you do is
- 1:30:13you do clear screen
- 1:30:14and then semicolon semicolon is a
- 1:30:16statement separator that says
- 1:30:18do this and then do something else so
- 1:30:21it's a way to do two things at once then
- 1:30:23we say
- 1:30:24get let's just say help about
- 1:30:28event by the way tab return event logs
- 1:30:31so then it clears the screen
- 1:30:33and shows me about and so here notice it
- 1:30:35gives me a short description
- 1:30:37describes things viewing the event logs
- 1:30:40goes through the
- 1:30:41the discussion about the topic tells you
- 1:30:44about the commands etc and so there's
- 1:30:46quite a bit here and then
- 1:30:48clear screen if you just say help about
- 1:30:51underscore star yeah that's there you go
- 1:30:55you'll see lots of about topics i mean
- 1:30:58look at them
- 1:30:58there's a and there's just a ton of
- 1:31:00really good stuff here like
- 1:31:02wild cards hey about wild card
- 1:31:06about wild cards about powershell
- 1:31:08version four guess which one i'm using
- 1:31:10about the isc about wmi and there's the
- 1:31:13one i mentioned remember
- 1:31:14remember about wql yeah so so i got to
- 1:31:18tell you this is one of the best
- 1:31:19investments you can make is to go and do
- 1:31:22this
- 1:31:22help about and spend some time reading
- 1:31:25them i mean
- 1:31:25there's really great great stuff there
- 1:31:27yeah and i think i think the
- 1:31:29the important side to this is that
- 1:31:30there's actually two help systems the
- 1:31:31help
- 1:31:32the help will help you discover out of
- 1:31:34both of them
- 1:31:35you've got help system for the
- 1:31:36commandlets and then you have this about
- 1:31:38underscore help system which as
- 1:31:40jeffrey just said is a conceptual stuff
- 1:31:42as we go through today we're going to be
- 1:31:44pointing out oh yeah you need more
- 1:31:45information go to the about underscore
- 1:31:47blah blah blah blah
- 1:31:48oh no there's more information in it no
- 1:31:50there's more than that what's more than
- 1:31:52that oh so you don't know about category
- 1:31:54category yeah so get help last category
- 1:31:59and here here's a trick right so you say
- 1:32:01um
- 1:32:02i know that category takes a value but i
- 1:32:04don't know what value it is right and so
- 1:32:06sometimes we have to have completion
- 1:32:07sometimes we don't here's what i have to
- 1:32:09do
- 1:32:09i just like give a bad value and then
- 1:32:12often what it'll do
- 1:32:13is it'll tell you what categories the
- 1:32:15argument blah blah blah
- 1:32:17does not belong to the set and it tells
- 1:32:20you the set of things that you can type
- 1:32:22oh so you can get specifically for like
- 1:32:24the providers
- 1:32:26that's the key now i'll tell you here we
- 1:32:28we did this and set this up and we had
- 1:32:30quite ambitious things for the help
- 1:32:32subsystem and we haven't fully
- 1:32:33implemented all of them
- 1:32:35some of our partners have implemented
- 1:32:36some of them but we didn't like we were
- 1:32:38going to have
- 1:32:38faqs and glossary terms so so if you say
- 1:32:41help faq it's not there
- 1:32:43okay i'd like to get around to that but
- 1:32:45in particular
- 1:32:46notice here it says where it is
- 1:32:49provider right so what you can do is you
- 1:32:52can say
- 1:32:55by the way tab works
- 1:32:58and tells you oh look here are the
- 1:33:00various providers now we're going to
- 1:33:02talk about this topic
- 1:33:03later but if you did that and you said
- 1:33:06oh get help
- 1:33:09certificate certificate
- 1:33:13certificate okay
- 1:33:18it'll give you information about a
- 1:33:19provider when we get to the topic about
- 1:33:20providers this will make more sense
- 1:33:22but it's a very very rich health system
- 1:33:24yeah very rich help system
- 1:33:42[Music]
- 1:33:50so our third topic for the day is
- 1:33:52getting connected with the pipeline
- 1:33:54and the first thing is is um yeah we're
- 1:33:56going to go through all of this so
- 1:33:57there's the cute module overview
- 1:33:59but take a look at this what's the
- 1:34:01pipeline first of all look at the
- 1:34:02character here
- 1:34:03see this character okay this is located
- 1:34:06above like it says right here located
- 1:34:07above your enter key
- 1:34:09and the reason i say it like that is
- 1:34:11because a lot of folks don't even know
- 1:34:13where this character is let me give you
- 1:34:14an example
- 1:34:17so get service
- 1:34:21pipe what's going to happen is is get
- 1:34:24service is going to go out and get
- 1:34:26a collection of service objects they're
- 1:34:29technically called service controllers
- 1:34:30and you're going to see what all that is
- 1:34:32later but it's going to grab all of
- 1:34:34those services
- 1:34:36and then it's going to send them and i'm
- 1:34:39i'm not talking about a text
- 1:34:40representation
- 1:34:41i'm talking about the actual service
- 1:34:43objects themselves it's going to send
- 1:34:45them
- 1:34:45one at a time across this pipeline what
- 1:34:48do you want to do
- 1:34:50next to these services well let's narrow
- 1:34:53this down a little bit let's just do
- 1:34:55the name bits take a look it's running
- 1:35:00take a guess what i could do if i wanted
- 1:35:01to stop this service you probably
- 1:35:03could guess that there's a commandlet
- 1:35:05called stop service and you would be
- 1:35:07correct
- 1:35:07there is there's one called stop service
- 1:35:09and you can specify a name but
- 1:35:11here's the interesting thing
- 1:35:15i can pipe it to stop service
- 1:35:18if i could type it here's what's going
- 1:35:21to happen
- 1:35:22we're going to take that bit service
- 1:35:23we're going to send it across that
- 1:35:24pipeline stop service is going to grab
- 1:35:26hold of that
- 1:35:27and do exactly what it says it's going
- 1:35:29to do it's going to stop the service now
- 1:35:30we're going to talk
- 1:35:31a little bit later in more detail about
- 1:35:33how this pipeline works because it's
- 1:35:35crucially important in troubleshooting
- 1:35:37but just take a look
- 1:35:39well i wonder what it did well let's run
- 1:35:42ah i stopped it
- 1:35:43now i can pipe and i can even say start
- 1:35:46service and
- 1:35:46i'm going to use a pass through on here
- 1:35:49that will show me the results of what
- 1:35:50i'm doing
- 1:35:52and now it started again now i know
- 1:35:53that's a simple pipeline
- 1:35:55but that concept of taking something
- 1:35:57sending across the pipeline
- 1:35:59to have something else act on it is very
- 1:36:02important and we can continue we can
- 1:36:04pipe from one thing to the next thing to
- 1:36:06the next thing
- 1:36:07so as an example let's start out with a
- 1:36:10couple of cool things
- 1:36:11oh hey first of all jeffy what do you
- 1:36:12think i just love to ask people this oh
- 1:36:15don't be careful with the inner key
- 1:36:19what do you think jeffrey is that going
- 1:36:22to do what i think it's going to do
- 1:36:24yeah don't you want you don't want to do
- 1:36:25that i don't don't want to do that
- 1:36:27guys we we're going to show you the
- 1:36:29pipeline is very powerful
- 1:36:30it can also allow you to make silly
- 1:36:33mistakes
- 1:36:34so it's worth pointing out powershell is
- 1:36:37a powerful tool a powerful tool like a
- 1:36:40really sharp knife um if really sharp
- 1:36:43knife is super super useful
- 1:36:45probably don't want to give it to your
- 1:36:46kids right or or you want
- 1:36:48you know you want to be thoughtful about
- 1:36:50this stuff powershell you can do some
- 1:36:53damaging things and so often we you know
- 1:36:55give you techniques to deal with that
- 1:36:57but
- 1:36:58indeed you know don't complain if if you
- 1:37:00say oh well geez i
- 1:37:01removed all the files from my file
- 1:37:02system power darn
- 1:37:05by the way i did that actually i was i
- 1:37:07was i was i was giving an example of how
- 1:37:09to do this
- 1:37:10and and the guards that we have and i
- 1:37:12forgot to put that in and i hit carriage
- 1:37:14turn
- 1:37:14and it turns out if you kill lsass bad
- 1:37:17things happen
- 1:37:17bad things bad things especially when
- 1:37:19you're in front of like 700 people
- 1:37:21doing a demo very bad things happen
- 1:37:24strongly
- 1:37:25not recommended because i've hit the
- 1:37:26inter on the get service stop service
- 1:37:28and it's just not cool powershell
- 1:37:30doesn't ask you are you sure
- 1:37:32until later when we show you how you can
- 1:37:34get it to but it doesn't so
- 1:37:35it assumes you know what you're doing um
- 1:37:38let me do an
- 1:37:39example here of another pipeline thing
- 1:37:41let's talk about csvs for a second a lot
- 1:37:43of times
- 1:37:44export here's a command export csv guess
- 1:37:47what export
- 1:37:48csv is going to do it's going to take
- 1:37:49this information and
- 1:37:51export it to a csv and so i'm going to
- 1:37:54put in a path of c
- 1:37:55colon let's just call it service dot csv
- 1:37:58you guys know what a csv is comma
- 1:38:00separated file and yes
- 1:38:02you can change the delimiters if you
- 1:38:03look at the help file for export csv
- 1:38:05you can change the delimiters and modify
- 1:38:07how it works but
- 1:38:08let's take a look at this csv i'm going
- 1:38:10to open this up in notepad
- 1:38:12not the correct tool for looking at a
- 1:38:14csv
- 1:38:15because it's going to look at this text
- 1:38:17bob but i just want you to see see all
- 1:38:18that yep it's all comma
- 1:38:19comma separated but here's here's one of
- 1:38:21the interesting rules about powershell
- 1:38:23is
- 1:38:23if you can export it you're going to
- 1:38:25want to import it at some point
- 1:38:27you're going to want to work with that
- 1:38:28data again so if you can export it
- 1:38:32you can import the csv so import
- 1:38:36csv
- 1:38:39i forgot what i called it but not that
- 1:38:41there we go
- 1:38:42and now all that data comes back and
- 1:38:44it's formatted correctly and it's
- 1:38:46attached correctly so i can actually
- 1:38:47work with it now
- 1:38:48now these are simple examples of the
- 1:38:50pipeline but we're also showing you some
- 1:38:52some great export stuff so besides
- 1:38:55exporting
- 1:38:57like to a csv there's my favorite
- 1:39:02oops command line xml
- 1:39:05i love xml xml is greatest thing since
- 1:39:07the automation is sliced bread
- 1:39:10great example you guys used to do online
- 1:39:12banking years ago
- 1:39:14you go to the uh you buy something swipe
- 1:39:16your credit card
- 1:39:17three days later it would show up in
- 1:39:19your account today you swipe it when's
- 1:39:21it show up in your account
- 1:39:22just as it finishes swiping it's xml
- 1:39:25baby it's xml um so let's
- 1:39:28uh export to xml and here's what i'm
- 1:39:30gonna do instead of doing uh get service
- 1:39:34i'm gonna do get process i like that
- 1:39:37and i'm gonna make a little i'm going to
- 1:39:39pretend i'm going to do this call this
- 1:39:41good xml i want you to pretend something
- 1:39:45for a second i want you to pretend that
- 1:39:47i've just taken a snapshot of a
- 1:39:49perfectly running a perfectly good
- 1:39:51running machine
- 1:39:52runs perfectly and i've just
- 1:39:55snapshotted its processes now if you
- 1:39:58blink your eyes
- 1:40:00pretend for a moment that now i'm
- 1:40:01working on a non-perfectly running
- 1:40:03machine
- 1:40:07and what i'd like to do is i'd like to
- 1:40:09compare
- 1:40:12the good machine to the non-good machine
- 1:40:16yeah imagine those instead of notepad
- 1:40:17and calc imagine that was some malware
- 1:40:20yeah exactly i'm just using notepad
- 1:40:23now the the compare object i'm just
- 1:40:26giving an example of how
- 1:40:27the pipeline and how using commandlets
- 1:40:29can can
- 1:40:30be very useful to you so i've got a
- 1:40:32reference object now i want you to
- 1:40:33notice i'm going to use
- 1:40:34uh parentheses we're going to talk more
- 1:40:36about parentheticals but this means
- 1:40:38do this first and what i need to do is i
- 1:40:40need to import
- 1:40:41the good xml file that represents the
- 1:40:44good machine
- 1:40:47and then i want to compare that to
- 1:40:51this currently running machine now when
- 1:40:53you run get process
- 1:40:54there's a lot of information that comes
- 1:40:56up what i want is i just wanted to
- 1:40:58compare
- 1:40:59the names of the processes right now and
- 1:41:01see if there's a difference
- 1:41:03so what i've done is i've exported my
- 1:41:05process information with the pipeline
- 1:41:07and now i'm just going to compare it
- 1:41:10notice the site indicator points to the
- 1:41:13bad machine
- 1:41:14and is saying hey look calc and notepad
- 1:41:17are running on that
- 1:41:18and as opposed to what's on the good
- 1:41:19machine this is an example of how you're
- 1:41:22going to start to be able to build
- 1:41:23commands
- 1:41:24with the pipeline to do something and
- 1:41:26then
- 1:41:27use other commands to achieve your
- 1:41:28results imagine comparing two machines
- 1:41:32the software that's installed on them
- 1:41:33and making you want to make one machine
- 1:41:35look
- 1:41:35just like another so there's a lot of
- 1:41:37things that we can do with building a
- 1:41:39pipeline
- 1:41:40one last example and then we'll take a
- 1:41:41shortcut oh yeah you know so what jason
- 1:41:43just showed you
- 1:41:44is freakishly powerful and we're going
- 1:41:46to drill into it
- 1:41:47in in the future so what we did was we
- 1:41:50took a set of live
- 1:41:51objects and we compared them against an
- 1:41:54xml
- 1:41:54file like how do you do that and the
- 1:41:57answer is
- 1:41:58the magic of powershell and the things
- 1:42:00we call objects and object adapters
- 1:42:02and of course if you just try to compare
- 1:42:04these things it would say they're
- 1:42:05completely different so he didn't he
- 1:42:07said
- 1:42:07i just want to compare them based upon
- 1:42:09their name and so what you've done
- 1:42:12okay we've really kind of led you to is
- 1:42:14again you
- 1:42:15think about what you want to do you type
- 1:42:17it and the magic of powershell is able
- 1:42:19to take these
- 1:42:20incredibly complex stuff and present it
- 1:42:24to you in a very simple world
- 1:42:26so let me show you a couple other
- 1:42:27command line things and and jeffrey will
- 1:42:29be
- 1:42:29adding in um stuff here just so you can
- 1:42:31get the idea of kind of what's going on
- 1:42:34besides exporting out to like csvs and
- 1:42:37xml there's some other things you can do
- 1:42:39so get service
- 1:42:40everybody always wants to know how do i
- 1:42:42put something into
- 1:42:44just a text file well you know first of
- 1:42:46all you could have found
- 1:42:47out file by looking for get help star
- 1:42:50file or
- 1:42:51something like that which is totally
- 1:42:53awesome and you'll find out file out
- 1:42:55file has
- 1:42:56if you look at the help file for it
- 1:42:57wants you to give it a path
- 1:42:59and um and you give it a path to what
- 1:43:02you want to use as
- 1:43:03a for your text file so test dot
- 1:43:07text and you can get the content
- 1:43:11did i say get the content you can get
- 1:43:13the content from a text file
- 1:43:15you know i wonder if there's anything
- 1:43:17that could help me
- 1:43:18with getting content from a text
- 1:43:22file oh lookie get content the help
- 1:43:25system
- 1:43:26help systems your friend so you can get
- 1:43:28the content
- 1:43:30from a text file by just using get
- 1:43:32content
- 1:43:35and and i think i call that test.text
- 1:43:38and there's all that get service content
- 1:43:40that i just put in a text file but
- 1:43:42wait there's more you can send stuff out
- 1:43:45to a printer
- 1:43:46out to a printer out printer out
- 1:43:49printer so there's a set of things you
- 1:43:51could set it out to
- 1:43:52there's i wonder i wonder how we could
- 1:43:55find
- 1:43:56a list of the things that we could
- 1:43:59send stuff out to
- 1:44:02yeah no just out just start without
- 1:44:05start without
- 1:44:06yeah well but here look there's a ton of
- 1:44:08stuff that we can send for
- 1:44:10out um so again the help file
- 1:44:14is your friend besides sending stuff out
- 1:44:16there's also creative
- 1:44:18ways to do stuff so get service i love
- 1:44:21this
- 1:44:21this is one of my favorite things we
- 1:44:22also have convert to commandlets
- 1:44:25convert to csv now this is gonna make
- 1:44:28more sense later but
- 1:44:29well you just had an export csv yeah
- 1:44:32and we have a convert to csv the
- 1:44:34difference being for right now
- 1:44:36when you do an export csv you're done
- 1:44:39you're you're done when you do a convert
- 1:44:41to csv we're going to leave that stuff
- 1:44:43in the pipeline in case you want to
- 1:44:44pipeline it and do other things to it so
- 1:44:47the way i think about it yeah is uh
- 1:44:49export is convert
- 1:44:50coupled with output it to a file yeah i
- 1:44:53uh
- 1:44:54excellent excellent because if you do an
- 1:44:57export csv
- 1:44:58you have a mandatory where you have to
- 1:44:59send it to a file so think of it as
- 1:45:01a convert with an out file already built
- 1:45:05right in
- 1:45:05so we have the converts but i want to
- 1:45:07show you one of my favorite ones
- 1:45:10he he he
- 1:45:15um did i mention as a web guide uh
- 1:45:16anyways the uh
- 1:45:18and i want to pick just a couple of
- 1:45:19properties for this i'm going to take
- 1:45:21name
- 1:45:21and status the reason i knew that
- 1:45:23convert to html has a dash property
- 1:45:25parameter
- 1:45:26and it had chihuahuas that would take
- 1:45:29multiple arguments is because i
- 1:45:30looked at the help file so it's going to
- 1:45:32convert it to as you would expect html
- 1:45:35and at this point
- 1:45:36there it did it it's the cleanest html
- 1:45:38by the way
- 1:45:40it did exactly what i asked it to do but
- 1:45:42here's an example of me saying look
- 1:45:44i i don't want it to my screen i now
- 1:45:47want it in a
- 1:45:48file i want it out to a file so let's
- 1:45:50pipe it out
- 1:45:52file and let's call this just test.htm
- 1:45:56and you guys know if you haven't
- 1:45:58can you reduce your go down a little bit
- 1:46:00more oh yeah yeah yeah yeah
- 1:46:02yeah thanks guys for telling us about
- 1:46:03that in the discussion thing i want to
- 1:46:04lower my
- 1:46:05command down so that's that's picture in
- 1:46:07all its glory in all of its
- 1:46:09beautiful glory and you guys know that
- 1:46:11if you double click
- 1:46:13did i say double click yes i said double
- 1:46:15click on an htm it'll pop we'll see
- 1:46:17no more double clicking no more mouse no
- 1:46:19more mouse so what i'm going to do is
- 1:46:20just say
- 1:46:21c colon test htm and powershell will
- 1:46:25launch it up there for me do you get i
- 1:46:28just
- 1:46:28made a web page how many developers did
- 1:46:32that take
- 1:46:33and if you look at the help for
- 1:46:37convert to html you're going to find
- 1:46:40that you have a lot of options to make
- 1:46:43this pretty
- 1:46:44there's a lot of ways to make this very
- 1:46:46pretty with tables and all kinds of
- 1:46:48using style sheets and so forth so
- 1:46:50it pays to look at the help but this is
- 1:46:51a good example of piping
- 1:46:54from one command to another to achieve a
- 1:46:56certain result
- 1:46:58so let's take a look at what else we got
- 1:47:00going we got
- 1:47:01to the web page and you know these are
- 1:47:03just some examples of piping some stuff
- 1:47:06oh we're going to have to talk about
- 1:47:08stuff that kills because we almost i
- 1:47:10almost screwed up earlier yeah
- 1:47:12it's fun this is fun so let me and
- 1:47:14jeffrey you can help me out here with
- 1:47:16this one because i'm going to
- 1:47:17get service and i'm going to do stop
- 1:47:20service
- 1:47:22and i want to know if this works or not
- 1:47:24but seems kind of risky to me
- 1:47:26yeah what can i do when in trouble fear
- 1:47:30or doubt run in circles scream and shout
- 1:47:33so no that's what they juiced
- 1:47:38that's what they used to teach kids at
- 1:47:39boy scouts when you go on a trip
- 1:47:42oh so no here's the thing when you're
- 1:47:44ever
- 1:47:45so i once dealt with an admin who said
- 1:47:47you know every now and again
- 1:47:49it's late and doing something and i
- 1:47:50realize i'm about to hit the carriage
- 1:47:52return or enter key
- 1:47:53and i realize if i get it wrong like
- 1:47:55that's the end
- 1:47:56right i'm i'm going to be fired muffy
- 1:47:58and buffy are not going to go to college
- 1:48:03what are we doing that we create an
- 1:48:05environment where somebody that's the
- 1:48:06world that they have to live with
- 1:48:08and so in powershell if you ever have
- 1:48:11something that you're uncertain of
- 1:48:13you can always type minus what if like
- 1:48:16what if i did this what would actually
- 1:48:17happen
- 1:48:18and you would get
- 1:48:22[Music]
- 1:48:23and it tells you what it would do but it
- 1:48:25doesn't actually do it
- 1:48:26now the the best part is that it tells
- 1:48:30you what it would do
- 1:48:31but it didn't actually do it and if you
- 1:48:33look at my screen
- 1:48:34it says yep i would have stopped these
- 1:48:36services now
- 1:48:37if you're thinking to yourself that oh
- 1:48:39well this is a nice fast way to shut
- 1:48:40down my computer
- 1:48:41no no no no this is going to blue screen
- 1:48:43way before
- 1:48:44it gets shut down so it won't blue
- 1:48:46screen but it's going to stop somewhere
- 1:48:48around
- 1:48:49power shell service host somewhere in
- 1:48:51there muffy and buffy would not be going
- 1:48:52to college after this one
- 1:48:55so you're not going to want to do that
- 1:48:56but something to keep in mind we also
- 1:48:58besides what if and i use what if all
- 1:49:00the time because you know
- 1:49:02things can be dangerous that you're
- 1:49:03trying out we also have dash
- 1:49:06confirm and dash confirm is a what if
- 1:49:10with do you actually want to do this now
- 1:49:13i'm obviously not going to say yes to
- 1:49:15anything and certainly not yes to all
- 1:49:17so let's just i'm going to put my finger
- 1:49:19on the l right now so that
- 1:49:21nothing happens but i want you to notice
- 1:49:23it is showing you both what it will do
- 1:49:25and then asking you do you want me to do
- 1:49:27this so people ask all the time
- 1:49:29powershell doesn't ask me are you sure
- 1:49:30yeah because powershell's not for
- 1:49:31sissies but
- 1:49:32sometimes you need that capability
- 1:49:36so i'm going to hit l and please don't
- 1:49:39don't actually do anything yeah that'd
- 1:49:40be good hey can i show them something
- 1:49:42yeah
- 1:49:42okay so remember so at some level this
- 1:49:45isn't that interesting right get
- 1:49:47service pipe to stop service right
- 1:49:50uh what if i mean okay but who is gonna
- 1:49:53do that right you're just not gonna do
- 1:49:55that right
- 1:49:56but remember what i said earlier right
- 1:49:58about this like
- 1:49:59programming with hand grenades thing
- 1:50:01what i said was
- 1:50:02okay so let's see there's this bits
- 1:50:05thing
- 1:50:05and i i don't remember what the heck it
- 1:50:07was so what i'm gonna say is display
- 1:50:09name
- 1:50:10something to do with bits and or maybe
- 1:50:12it was something to do with bi
- 1:50:14right and then and then stop service
- 1:50:18service now did i get that one right now
- 1:50:20this is the more
- 1:50:21realistic thing did i get that one right
- 1:50:23because maybe bi star
- 1:50:25maps to bipp's service and maybe it
- 1:50:27doesn't so what you do here is you say
- 1:50:29what if
- 1:50:30and you're like yeah oh oh oh no
- 1:50:33good thing i didn't do that now at this
- 1:50:36point you could go and say okay
- 1:50:38why did that match oh i see biometric
- 1:50:41and then oh i see compatibility
- 1:50:43now if you wanted to you could go in
- 1:50:44here and try and like tweak this thing
- 1:50:46right and do this but instead you can
- 1:50:49just say no
- 1:50:49you know what it's close enough confirm
- 1:50:53and you say bitlocker yep that's the one
- 1:50:55i want to do it to so you you stop that
- 1:50:57and then this one you say no that was
- 1:50:59the only one so you say
- 1:51:01no to the rest and now i've stopped
- 1:51:05g s v b i oh
- 1:51:08oh i got the wrong one oh you know what
- 1:51:11i shouldn't stop that locker that was a
- 1:51:12bad thing yeah i think that might have
- 1:51:13been
- 1:51:16well great example of a practical use of
- 1:51:20that's confirmed i know that's perfect
- 1:51:22i'm now out of compliance with corporate
- 1:51:24policy there you are
- 1:51:25these doors might come bursting open but
- 1:51:28well so hopefully they will not burst
- 1:51:31open
- 1:51:32so guys this is our first introduction
- 1:51:34to the pipeline we're going to go much
- 1:51:36deeper into this pipeline but the
- 1:51:37concept again
- 1:51:38is you have a commandlet you're going to
- 1:51:41pipe the results of that commandlet to
- 1:51:43the next one so
- 1:51:44do this then do this then do this then
- 1:51:47do this
- 1:51:48until your needs are done and what
- 1:51:49you're going to notice is as we go
- 1:51:50through this and you get more and more
- 1:51:52commandlets
- 1:51:53you're going to see that the way you're
- 1:51:54thinking about the solving the problem
- 1:51:57is the way that you'll actually be
- 1:51:58building the commands in the pipeline
- 1:52:01now you don't have to do everything as a
- 1:52:03one-liner and one-liners are great we're
- 1:52:05going to do a lot of them in here
- 1:52:06but we're also going to do scripting
- 1:52:08where you know a one-liner is you know
- 1:52:10when it's when it's half the page
- 1:52:12you're probably a little out of control
- 1:52:13at that point but
- 1:52:15you can is the idea now
- 1:52:18before we go too much further into the
- 1:52:21pipeline
- 1:52:22jeffrey let's let's do this uh you know
- 1:52:24i've got a slide here so let me show
- 1:52:26everybody where we're at
- 1:52:28so guys again make sure you're asking
- 1:52:30questions all that kind of stuff and and
- 1:52:31for all the people out in the support
- 1:52:32the mvps and everybody who's
- 1:52:34contributing
- 1:52:35thank you so much for helping us out and
- 1:52:37answering all of these questions
- 1:52:39uh that are out there um let's go into
- 1:52:42extending the shell a little bit and
- 1:52:43there's i
- 1:52:44this is a fascinating conversation for
- 1:52:45me because
- 1:52:47i can't remember the exact number but i
- 1:52:48think when powershell 100 came out i
- 1:52:50think there's like 192 commandlets
- 1:52:53that's right that's all we could do was
- 1:52:54like 190 things yeah yeah then
- 1:52:56powershell v2 came out and there was 236
- 1:52:59well there's only 236 things
- 1:53:01that we could do but we need to do more
- 1:53:05than that
- 1:53:05i mean we we need something that's
- 1:53:08extensible so that we can do
- 1:53:09so how do we get more than just the core
- 1:53:12powershell command lines who's
- 1:53:13responsible for all of that kind of
- 1:53:15stuff
- 1:53:15it takes a village my friend it takes a
- 1:53:17village it's a village
- 1:53:20that's exactly the point so the
- 1:53:22powershell team is responsible for the
- 1:53:24core powershell
- 1:53:25environment the language etc and then
- 1:53:28you have plug-ins
- 1:53:29right or snap-ins or we now call modules
- 1:53:32and this is where you know like trust me
- 1:53:35you don't want me writing the link
- 1:53:36commandlets right that's not
- 1:53:39that doesn't end well and so we do is we
- 1:53:41create an
- 1:53:42environment where it's very easy for the
- 1:53:44individual feature teams to write their
- 1:53:46stuff and ship their stuff and that's
- 1:53:48why when you say
- 1:53:49oh well i i want to do some stuff with
- 1:53:52powershell
- 1:53:53uh where are the link commandlets well
- 1:53:55do you have link installed because you
- 1:53:56don't have link installed you're not
- 1:53:57going to get the link commandlets
- 1:53:59so the idea is that the commandlets ship
- 1:54:02with the thing that needs to be managed
- 1:54:04okay so we do this through modules also
- 1:54:07in the
- 1:54:08originally they were snap-ends right so
- 1:54:10snap-ins and if you've got powershell
- 1:54:12version one or powershell version two
- 1:54:14you have this thing called snap-ins it
- 1:54:16turns out there were a number of
- 1:54:18limitations with snap-ins
- 1:54:19the biggest you had to be administrator
- 1:54:21to get them installed
- 1:54:23and there's something else well oh you
- 1:54:26couldn't xcopy deploy them
- 1:54:28yeah and modules now modules is
- 1:54:31basically uh
- 1:54:32kind of conceptually modeled after the
- 1:54:34module or
- 1:54:35package modules of pearl and python and
- 1:54:38ruby
- 1:54:39but actually it's much richer than those
- 1:54:41much richer than those
- 1:54:42but the idea is you'll be able to
- 1:54:44package up your stuff and then
- 1:54:46x copy deploy it and then you import
- 1:54:48your modules
- 1:54:50so let's take a look first of all on
- 1:54:52what jeffrey is saying is and i think
- 1:54:54this is
- 1:54:55it's a you guys all of you guys have run
- 1:54:57the mmc before
- 1:54:59and you know the mmc you can file
- 1:55:02add remove snap in and you get a list of
- 1:55:05stuff here that you can add in i want
- 1:55:06you to notice on mine
- 1:55:08i happen to have some of the active
- 1:55:09directory snap-ins you guys know that
- 1:55:12in order to get those i had to install
- 1:55:15something and in this case i'd install
- 1:55:17the remote server administration tools
- 1:55:18to get the active directory ones
- 1:55:20well it's the same concept when you're
- 1:55:22working with powershell
- 1:55:24do you have the product installed well i
- 1:55:26have the remote server administration
- 1:55:28tools installed and so
- 1:55:30i'm going to get those modules let me
- 1:55:33show you powershell
- 1:55:35has a command called get module
- 1:55:38this will show you what's currently
- 1:55:40loaded up however
- 1:55:41list available will show you the modules
- 1:55:43that are available now i need to just
- 1:55:44tell you right now i
- 1:55:46this is very confusing in v2
- 1:55:49yeah yeah in v2 first of all you're not
- 1:55:52going to see what you're going to see on
- 1:55:53my screen
- 1:55:54in v2 you're not going to see it in
- 1:55:57windows 7
- 1:55:58either what you're seeing here is
- 1:56:00windows 8 running the windows 8 remote
- 1:56:02server administration tools and i get
- 1:56:04more modules than you do
- 1:56:06because he's cool well not because i'm
- 1:56:08cool because i've
- 1:56:10upgraded um so on i know your corporate
- 1:56:13standard
- 1:56:14you may not be doing it yet but your
- 1:56:16admin box
- 1:56:17needs to be running v3 and as you're
- 1:56:20going to want
- 1:56:20it needs to be running windows 8 okay so
- 1:56:23but at any rate let me just show you
- 1:56:26god i i'm not the guy that works for
- 1:56:28microsoft and i'm the one over here
- 1:56:30um so you can see i get this giant list
- 1:56:34of modules and
- 1:56:35notice one of the modules at the very
- 1:56:36top here is called active directory the
- 1:56:38reason i have that module
- 1:56:40is because i installed the remote server
- 1:56:41administration tools here's what that
- 1:56:43module contains
- 1:56:45commandlets commandlets that let me
- 1:56:47manage active directory
- 1:56:50and what and providers but we didn't
- 1:56:52provide us we don't talk about providers
- 1:56:53yet but yes and providers
- 1:56:56if you have a module with commandlets
- 1:56:58here's the beautiful thing about
- 1:56:59powershell v3
- 1:57:01you're going to love this when you use
- 1:57:02get help
- 1:57:04get help knows how to look through those
- 1:57:06modules even if they're not loaded
- 1:57:08so get help i want you to show me do i
- 1:57:10have any
- 1:57:11active directory commandlets
- 1:57:15i want you to notice that yes there's a
- 1:57:17lot of things with a.d in it and i could
- 1:57:18have refined the search better but
- 1:57:20that's kind of my point is i want you to
- 1:57:21see that
- 1:57:22there's a whole bunch of ad commandlets
- 1:57:25here you'll recognize
- 1:57:26ad computer as this will give me active
- 1:57:29directory computers
- 1:57:31that helps that help get help knows how
- 1:57:33to look into these modules
- 1:57:35find these commandments to show them so
- 1:57:37you still have complete discoverability
- 1:57:40and when you want help on the command
- 1:57:42that you found
- 1:57:43get help get ad computer
- 1:57:47it'll give you the help for it when you
- 1:57:50try to use the commandlet
- 1:57:52this is one of the biggest features for
- 1:57:54me personally in v3
- 1:57:56is when you try to use the commandlet
- 1:57:59and i think i may have used this one
- 1:58:00earlier so you may not see it flash on
- 1:58:02my screen but
- 1:58:03take a look up it just ran but let me do
- 1:58:07this i'm going to close my console and
- 1:58:09reopen it because i i want you to see
- 1:58:10this if you can catch it on my screen
- 1:58:12real quick
- 1:58:13let me the other way to do this is do it
- 1:58:15do a get module
- 1:58:18we'll show it yeah get module okay let's
- 1:58:20do that we're gonna do
- 1:58:22get module yeah character turn
- 1:58:26so these are the currently loaded
- 1:58:28modules right these are the currently
- 1:58:29loaded
- 1:58:30yes now do it and then and now yes thank
- 1:58:32you thank you so these are the currently
- 1:58:34loaded ones now watch what i'm going to
- 1:58:35do i'm going to do get
- 1:58:36ad computer and watch what flashes
- 1:58:38across my screen real quick just
- 1:58:40boy that was real quick i don't know if
- 1:58:41you caught it it actually
- 1:58:43dynamically loaded the module for me so
- 1:58:46that i had the commandments and notice
- 1:58:47the commandlet ran
- 1:58:49i didn't have to do anything special the
- 1:58:51reason i'm making a big deal about this
- 1:58:53and here i'll show you and get module
- 1:58:54get module now you'll see that
- 1:58:56it automatically loaded the active
- 1:58:58directory module for me
- 1:59:00reason i'm making a big deal about this
- 1:59:01in v2 your life sucks because it doesn't
- 1:59:04work that way
- 1:59:05let me tell you and i'm i'm sorry sir
- 1:59:07but this
- 1:59:08in v2 this was painful because in v2 get
- 1:59:12help would not find the commandments
- 1:59:13unless the module was
- 1:59:14imported yes so you had to know what the
- 1:59:17module was
- 1:59:18first then import it then you could
- 1:59:21discover
- 1:59:22see it didn't quite work they fixed all
- 1:59:24that with b3
- 1:59:25now it works just like i need it to work
- 1:59:28and when i run the command the module
- 1:59:29loads
- 1:59:30so i'm not loading modules unnecessarily
- 1:59:33and
- 1:59:33i'm um if i'm writing scripts that are
- 1:59:36using the commands it just loads what it
- 1:59:37needs
- 1:59:38and i don't have to worry about it it's
- 1:59:40a beautiful world
- 1:59:41it's a beautiful world it's a beaut you
- 1:59:43got any more on modules because that's
- 1:59:45about all i got on modules
- 1:59:46well you can do but would we get to this
- 1:59:49now
- 1:59:50what do what do you want to do modules
- 1:59:51on other machines implicit remote
- 1:59:53no oh no we'll do implicit oh boy we're
- 1:59:55going to talk about the
- 1:59:56we'll get to that later yeah it's so
- 1:59:58cool it's so cool it's so cool so let me
- 2:00:00show you the slides guys we've got all
- 2:00:01this
- 2:00:02so that's an after lunch thing they'll
- 2:00:03need like high energy
- 2:00:05and let me just warn you right now
- 2:00:06because we're only about 30 minutes or
- 2:00:08so away from
- 2:00:09taking a meal break meal break that's
- 2:00:11the international term for lunch
- 2:00:13yeah meal because we're we're taking
- 2:00:15lunch um is is that don't
- 2:00:17don't eat a lot because you don't want
- 2:00:19to fall asleep yeah
- 2:00:20after lunch absolutely it's have some
- 2:00:23coffee so we've got everything in the
- 2:00:24slides and powershell three dynamically
- 2:00:26uh
- 2:00:27loads the modules for you and you can
- 2:00:29you can discover all of your commands
- 2:00:31thank god for v3 makes this
- 2:00:33much easier and so uh you can work with
- 2:00:36your commands
- 2:00:37and off you go
- 2:00:41[Music]
- 2:00:55[Music]
- 2:01:04now's when the fun starts to begin
- 2:01:07before lunch i'm sorry to do this to you
- 2:01:09no this is good yeah this is great i
- 2:01:10know this is they can handle this this
- 2:01:12is great all right
- 2:01:14we're gonna we gotta talk about objects
- 2:01:16we're gonna talk about objects
- 2:01:17and what objects are and i'm gonna let
- 2:01:20jeffrey talk as much about objects as he
- 2:01:21wants to talk about
- 2:01:22yeah so let me just show you something
- 2:01:24here so so
- 2:01:25so we've been lying to you
- 2:01:31i'm leaving so here we've been saying
- 2:01:35get
- 2:01:35service services
- 2:01:39star okay and and what do you see right
- 2:01:42and what you see
- 2:01:43is text okay but that's not what's
- 2:01:46really going on
- 2:01:47what's really going on is when i do get
- 2:01:49service notice i didn't say get
- 2:01:51service text i just said get service so
- 2:01:53what i'm actually getting is
- 2:01:55i'm getting service objects or service
- 2:01:57controller objects okay
- 2:01:58and and the point of that now don't
- 2:02:00freak out when you hear the word object
- 2:02:02right some people hear the word object
- 2:02:03and they're like oh my
- 2:02:04god you're like i'm not a developer i'm
- 2:02:06not a developer no
- 2:02:07no my friends no no no objects
- 2:02:09dramatically
- 2:02:10simplify your life okay uh now what is
- 2:02:13an
- 2:02:14object okay let's just try to deal with
- 2:02:16that right simple because i'm over here
- 2:02:17freaking out going no no no no no
- 2:02:20but they're going to simplify my life
- 2:02:21okay i'm good so uh one of the
- 2:02:23uh i think it was an mvp or someone at
- 2:02:25tech ed did a great explanation of
- 2:02:27objects they said
- 2:02:27look an object is just a thing right
- 2:02:30it's a noun
- 2:02:31that has properties and methods so think
- 2:02:33about a bicycle
- 2:02:34right a bicycle is an object and it has
- 2:02:38properties it has handlebars it has
- 2:02:42pedals it has wheels
- 2:02:43okay and then there are things you can
- 2:02:45do to it so
- 2:02:47an object has things it has we call
- 2:02:50those
- 2:02:50properties it has a handlebar it has a
- 2:02:52wheel it has a
- 2:02:54um a frame and there are things it can
- 2:02:56do
- 2:02:57you can pedal you can steer and we call
- 2:02:59those things
- 2:03:00methods so objects are merely
- 2:03:03things that have properties and things
- 2:03:06you can do things too
- 2:03:07okay i like that so far i like that i
- 2:03:09like that
- 2:03:10so here we show this thing and what
- 2:03:12actually happens is i
- 2:03:14got a set of objects now the trick is
- 2:03:16and here's the magic
- 2:03:17is that we spew these objects out and we
- 2:03:20can then
- 2:03:21work on them and when they finally get
- 2:03:23to the display the display says oh i got
- 2:03:26an object
- 2:03:26what the hell am i going to do with that
- 2:03:28like there's no way i'm going to
- 2:03:30burp out this like binary stuff and
- 2:03:32people are going to figure it out
- 2:03:33so what the display does it says oh well
- 2:03:36now
- 2:03:36now i'll convert it to an object or
- 2:03:39convert it to text
- 2:03:41and the whole point about that is you
- 2:03:42want to delay the conversion of text
- 2:03:45as far as possible as long as possible
- 2:03:47because once you have text
- 2:03:49it's really hard to operate with now you
- 2:03:52unix guys anybody with a unix background
- 2:03:54you know what i'm talking about right
- 2:03:56because imagine now let's go back to get
- 2:03:57process i like get process so
- 2:03:59get process star ss okay
- 2:04:02now imagine you want to get all those
- 2:04:05things where
- 2:04:06the handles were greater than let's say
- 2:04:09700 let's do this
- 2:04:10get process okay so you see there's a
- 2:04:13bunch of these things and some of them
- 2:04:15are high so say you want to get all
- 2:04:16those that were greater than a thousand
- 2:04:18how would you do it
- 2:04:19well in unix if this is text gets taxed
- 2:04:23how do you do that well let's see you
- 2:04:24got to cut off one
- 2:04:26two three lines and then you got to go
- 2:04:29and you say well i'm going to cut off
- 2:04:30from zero to
- 2:04:31let's see that's one two
- 2:04:34three four five six
- 2:04:38seven seven k i gotta cut off these
- 2:04:40first seven characters
- 2:04:41and then what do you get and the answer
- 2:04:43is a string and so how do you do a
- 2:04:45string comparison that's greater than a
- 2:04:47thousand
- 2:04:48well you could thousands actually easy
- 2:04:49you could say well if the string
- 2:04:51truncate all the spaces and then if the
- 2:04:54length is greater than
- 2:04:55three right then it's greater than a
- 2:04:57thousand but if you wanted to do it
- 2:04:59greater than 900
- 2:05:00well then you got a sum okay so you get
- 2:05:02where i'm going you unix guys
- 2:05:04you know hats off to you i don't know
- 2:05:05how the heck you've been coping all
- 2:05:07these years
- 2:05:08i mean it really is we call this
- 2:05:09prayer-based parsing right
- 2:05:12please work exactly and oddly you know
- 2:05:15it sort of worked fine but in our world
- 2:05:17you don't have to do that in our world
- 2:05:19you have these objects okay now the
- 2:05:22thing is
- 2:05:22when i do get process i'm displaying an
- 2:05:25object
- 2:05:26each row is the object itself
- 2:05:29and each one of these displays here each
- 2:05:33one of the columns
- 2:05:35reflects the properties okay
- 2:05:38so what did i tell you i told you we're
- 2:05:41trying to create a world
- 2:05:42where you think about what you want you
- 2:05:45type it
- 2:05:45and you get it and the way that works is
- 2:05:48because of objects
- 2:05:49okay so what did i say i said i wanted
- 2:05:52to get
- 2:05:53the processes i wanted to get those
- 2:05:56where the handle count was greater than
- 2:05:595 or 900 or yeah some number so you pick
- 2:06:02you pick your favorite number okay
- 2:06:03so i want to say where the handles okay
- 2:06:06remember where did i get handles
- 2:06:09right there handles okay so where
- 2:06:12handles
- 2:06:15r greater than greater than equal
- 2:06:17greater than
- 2:06:18uh 900. and voila
- 2:06:22it worked why did it work because of
- 2:06:24objects
- 2:06:25objects objects are so cool now wait not
- 2:06:27like so this is still a little bit messy
- 2:06:29here right
- 2:06:30because these handles i mean look at
- 2:06:32them they're all kind of like
- 2:06:33all over the place right so really what
- 2:06:35i want to do is i want to sort them by
- 2:06:37now how are they going again you cut off
- 2:06:40three lines and you do this and again
- 2:06:42it's strings
- 2:06:42so so but no no it's an object
- 2:06:46so what you could do is again think
- 2:06:48about what you want
- 2:06:49type it and you get it you would say
- 2:06:51well i want to sort it by handles
- 2:06:56and then you get it okay which is
- 2:06:59this if you're starting to get the
- 2:07:01concept here this is
- 2:07:02starting to become totally awesome look
- 2:07:04at the difference of working with
- 2:07:05objects
- 2:07:06one thing that you can do to start off
- 2:07:09is to show that
- 2:07:10that these are objects is i'm just going
- 2:07:12to grab a service real quick
- 2:07:15and if you want to take a look at what
- 2:07:18properties and notice when i run
- 2:07:19just get service name bits notice that
- 2:07:22there
- 2:07:22are three what appear to be properties
- 2:07:25displayed about this server but you know
- 2:07:27what
- 2:07:27i i'm pretty sure there's more
- 2:07:30properties than just these three on a
- 2:07:32service
- 2:07:32and you know i'm not seeing any methods
- 2:07:34here um but jeffrey just said that
- 2:07:37objects have properties
- 2:07:38and and they have methods well there's a
- 2:07:41way
- 2:07:42to show you everything that an object
- 2:07:44has and it's going to become a crucial
- 2:07:46part to working with powershell
- 2:07:48so how do you find out what properties
- 2:07:51and methods an object has
- 2:07:53you pipe it to a very special command
- 2:07:55and i'm going to
- 2:07:57get member now i got to be honest with
- 2:07:59you get member
- 2:08:01we usually use the alias for this so i'm
- 2:08:04just going to use the alias
- 2:08:05pipe gm and you'll just hear me say pipe
- 2:08:08gm
- 2:08:08when you pipe something to get member it
- 2:08:10takes the object and it
- 2:08:11shows you all the meth so think of it
- 2:08:15this way it's kind of like if i were to
- 2:08:16walk in front of a mirror the mirror
- 2:08:18shows me things like well you're six
- 2:08:19foot two you're blonde you've got blue
- 2:08:21eyes you're built
- 2:08:22really well and you and you have methods
- 2:08:25you have methods like you
- 2:08:26you surf and you like karate what do you
- 2:08:28think of my mirror
- 2:08:29that's awesome i need one of those yeah
- 2:08:32obviously my mirror does not work well
- 2:08:34but
- 2:08:35the powershell mirror being get member
- 2:08:37works
- 2:08:38very well so let me just show you if you
- 2:08:40take a look here there's
- 2:08:41a couple of pieces of information you're
- 2:08:43going to want to pull out from get
- 2:08:44member first of all
- 2:08:45what kind of object it is this is going
- 2:08:47to become very important to us
- 2:08:48after lunch what kind of object is
- 2:08:51your screen over a little bit it's
- 2:08:53getting truncated a little bit oh yeah
- 2:08:54let me get this
- 2:08:56does that look better here we go so
- 2:09:00system dot uh service process what you
- 2:09:02really are interested in right now is
- 2:09:03this period and what comes after its
- 2:09:05service controller that's what kind of
- 2:09:07object is being sent across that
- 2:09:08pipeline
- 2:09:09and then look at this list anything with
- 2:09:11the word property in it i don't care if
- 2:09:13it has some other word in front of it or
- 2:09:15something anything with a property
- 2:09:17is a property that you can use and look
- 2:09:20at specifically
- 2:09:21like jeffrey was doing handles on get
- 2:09:23process i'm you know look at all these
- 2:09:25properties down through here
- 2:09:27we're going to start off working quite a
- 2:09:28bit with properties but you also have
- 2:09:30methods methods like oh look start
- 2:09:34and stop getservice has a method to
- 2:09:37start and stop a service we don't
- 2:09:39need a commandlet necessarily because we
- 2:09:41have a method
- 2:09:42that we could use and we'll show you how
- 2:09:43to do that too so get member is your
- 2:09:46friend to show you the truth or what an
- 2:09:48object actually contains
- 2:09:50for its properties and its methods let
- 2:09:52me give you an example using kind of off
- 2:09:54of
- 2:09:54jeffrey's example i'm going to do get
- 2:09:56service
- 2:09:57and here's what i want to do i want to
- 2:10:00just select a couple of properties
- 2:10:04the properties that i want to see right
- 2:10:05now are name and status
- 2:10:08we have a commandlet called select
- 2:10:10object
- 2:10:11now you usually see this as its alias of
- 2:10:15select let me just show you it has a
- 2:10:17parameter called property and you can
- 2:10:19tell me
- 2:10:20what properties you now want to see well
- 2:10:23if i've gone to get member and i've
- 2:10:24looked at the list of properties and
- 2:10:26i've chosen the ones that i wanted i
- 2:10:27just type them in i just want name
- 2:10:30status so i've selected those particular
- 2:10:33properties
- 2:10:34now i also want you to notice and
- 2:10:37jeffrey just did an example of this
- 2:10:39i'm going to get child item or the alias
- 2:10:41der is a great example
- 2:10:42here's a list of files out of the out of
- 2:10:45my c drive
- 2:10:46files and folders right now look at how
- 2:10:49it's sorting them
- 2:10:50sorting them by name and it's sorting
- 2:10:52them well looks to be alphabetically to
- 2:10:54me
- 2:10:54well i want to change the sort i'd like
- 2:10:56to sort them by length
- 2:10:58and the only thing i want displayed is
- 2:11:00name and length so here's what i'm going
- 2:11:02to do
- 2:11:03i'm going to do get child item
- 2:11:08i'm going to uh select
- 2:11:11that the properties i want to see are
- 2:11:13name and
- 2:11:14length and this is right off of the
- 2:11:16example that jeffrey was doing
- 2:11:17i want to sort that by the property
- 2:11:22length
- 2:11:24this pipeline and the fact that objects
- 2:11:27are crossing the pipeline and i can work
- 2:11:28with
- 2:11:29these properties and methods making my
- 2:11:31life a lot easier look at that it's it's
- 2:11:33folders first and then it's the files
- 2:11:34but you know what notice
- 2:11:35on my files it's small z's to big z's i
- 2:11:39want it big z's to smallzies in other
- 2:11:41words i want it descending
- 2:11:43so let me hit my up arrow key and the
- 2:11:46sort object
- 2:11:47has a descending so now i can change the
- 2:11:49sort order
- 2:11:50and make it descending is that kind of
- 2:11:52cool that's good that's that's kind of
- 2:11:53cool that's kind of cool
- 2:11:54that's kind of cool that's you know
- 2:11:57working with the object so
- 2:11:59working with objects is all about using
- 2:12:02get member and we've shown you that you
- 2:12:04can do sort
- 2:12:06and you can do a select and we're going
- 2:12:08to do these quite a bit of selecting and
- 2:12:10sorting
- 2:12:11but there's some other examples let's
- 2:12:12see here
- 2:12:14keep in mind get process
- 2:12:17when you need to know more about an
- 2:12:19object this is very important when you
- 2:12:20need to know more about an object
- 2:12:22because this afternoon we're going to
- 2:12:23need to know more about an object
- 2:12:24you pipe to gm which is get member
- 2:12:28you'll get
- 2:12:31the type of object it is which we're
- 2:12:32going to need this later and you get
- 2:12:35all of its properties and its methods
- 2:12:36and it if it has the word property in it
- 2:12:39you can use it with sword and select
- 2:12:41like we just showed you
- 2:12:42that you could use it with in fact it's
- 2:12:45it's kind of interesting there's all
- 2:12:46kinds of stuff you can do
- 2:12:48so back to an earlier example get event
- 2:12:50log
- 2:12:53log name system and we're going to do
- 2:12:55newest
- 2:12:57let's just do new toolboost 5 and i want
- 2:13:00to
- 2:13:01if i just run this you can see i'm
- 2:13:02getting all this information across here
- 2:13:04i'd like to take a look at the object
- 2:13:06itself so what i'm going to do
- 2:13:08is because i want to see what all the
- 2:13:10properties are
- 2:13:11i'm going to pipe it to gm wow there's a
- 2:13:13lot more properties out here
- 2:13:15than i was seeing in the original
- 2:13:17display time generated time written so
- 2:13:20you know what i think i'd like i think
- 2:13:21i'd like
- 2:13:22um event id and time generated
- 2:13:26and i think i would like oh
- 2:13:29what else would be a good property maybe
- 2:13:31um
- 2:13:33a message that would be perfect that
- 2:13:35would be perfect
- 2:13:36so i'm going to up arrow
- 2:13:40select the property event
- 2:13:44id yup comma
- 2:13:47and if you take a look at the help file
- 2:13:48you'll see that dash property takes
- 2:13:50multiple values so
- 2:13:52i can do time generated or time written
- 2:13:54let's do time written i think i can type
- 2:13:56that one
- 2:13:57you can hit tab version three
- 2:14:00version three version three
- 2:14:03see i just hit tab and it made my life
- 2:14:05much easier in typing
- 2:14:06so now i've selected those there we go
- 2:14:09and now i'd actually like to sort them
- 2:14:11on the on the time written
- 2:14:13now guys this is a vm so there's not a
- 2:14:16whole lot of stuff out here but you get
- 2:14:18the idea i'm going to sort
- 2:14:20on the property of okay now i'm not
- 2:14:22getting my tab
- 2:14:23time written and voila
- 2:14:27and if i want to sort it descending i
- 2:14:28can sort it descending but now
- 2:14:31that i'm understanding the pipeline i
- 2:14:33know how to find
- 2:14:34the properties that i want not just the
- 2:14:36ones that i saw on the display but
- 2:14:38i can find all of the properties and
- 2:14:40then just select the ones i want and
- 2:14:42sort the ones i want
- 2:14:44now that i have what i want well i don't
- 2:14:46want it on the screen
- 2:14:48i want it converted to an html file and
- 2:14:54i just love this sql
- 2:14:58errors dot htm and actually this will
- 2:15:01take a unc
- 2:15:02out file will take a unc so you just
- 2:15:04throw it to a web server
- 2:15:06dimension as a web guy that's uh anyways
- 2:15:08uh and so here's the deal
- 2:15:10so i've got this this this great
- 2:15:13one-liner right now
- 2:15:14that's grabbing the errors and right now
- 2:15:16it's from the local machine but i can
- 2:15:18throw a dash computer we get it from
- 2:15:19multiple machines
- 2:15:20it's selecting out just the information
- 2:15:22i want it's sorting it the way that i
- 2:15:23want it's stuffing it into a web file
- 2:15:26i can now tell the other admins hey when
- 2:15:28you get up in the morning
- 2:15:29go check the web page and if there's any
- 2:15:31errors in there
- 2:15:33start trying to fix them because as
- 2:15:35you're going to see later
- 2:15:36we're going to automate this and
- 2:15:38schedule this
- 2:15:39and make this go for us so i don't have
- 2:15:41to type it again so once i figured it
- 2:15:43out
- 2:15:43but you can see it's like figuring out a
- 2:15:45puzzle and just to show you that it
- 2:15:46actually worked
- 2:15:47what did i call it error hdm
- 2:15:53there's a woohoo even from the guys in
- 2:15:55the back so you must
- 2:15:56it's all good you must be a little
- 2:15:58impressed with that what else should we
- 2:16:00show them with
- 2:16:00subjects right now okay so here's the
- 2:16:02thing about objects i mentioned to you
- 2:16:03that
- 2:16:04objects dramatically simplify your life
- 2:16:06it's true
- 2:16:07okay so here's the thing what we've been
- 2:16:09showing you
- 2:16:10are net objects now these.net objects
- 2:16:12are actually
- 2:16:13very well behaved objects but you know
- 2:16:15the world
- 2:16:16the world is a messy place and not
- 2:16:18everybody has your best interests in
- 2:16:20mind
- 2:16:21and so in particular there's a lot of
- 2:16:23people who use net in a way
- 2:16:25that is good for them but not good for
- 2:16:27you
- 2:16:28okay and in particular what they do is
- 2:16:29they hide things
- 2:16:31and this is ubiquitous right this
- 2:16:32happens in wmi it happens in adsi
- 2:16:35active directory happens in xml etc
- 2:16:38now powershell we got exactly one
- 2:16:41customer that's
- 2:16:41you okay so i am focused in on making
- 2:16:44your life
- 2:16:45great okay and so what we do is we go
- 2:16:47and we say
- 2:16:48these guys didn't help you we'll help
- 2:16:50you right we will take their stuff
- 2:16:52and we'll adapt it for your needs now
- 2:16:55let me just give you an example of this
- 2:16:56okay
- 2:16:57so here i have i've got this xml file
- 2:17:01okay so r d dot j so let's see if i can
- 2:17:05actually bring that up
- 2:17:07so can i do this open can do an open
- 2:17:11powershell.org yeah we'll talk about
- 2:17:13that that's cool we are but
- 2:17:14let's see can i do an open okay yeah so
- 2:17:16i want to say c
- 2:17:18uh jumpstart
- 2:17:21slash r and here's my xml
- 2:17:25and it is the tragedy of romeo and
- 2:17:29juliet
- 2:17:30oh it's beautiful and look here so you
- 2:17:32got personas
- 2:17:34you got you got ax and in the acts
- 2:17:37you've got
- 2:17:38speeches and you got oops sorry and you
- 2:17:40got and you got speakers and you got
- 2:17:42lines okay now by the way this next
- 2:17:44thing i'm going to show you
- 2:17:45i'm going to show you the way to do it
- 2:17:47in powershell version
- 2:17:493. okay in powershell version 2 you can
- 2:17:51do it but it's
- 2:17:52harder and and the stuff i'm going to
- 2:17:54show you requires version three
- 2:17:56okay so we have this thing we'll call it
- 2:17:58dollar sign it's also an
- 2:18:00x um and what we're going to do is we're
- 2:18:03going to
- 2:18:04cap that file a cat is the same as get
- 2:18:06content but
- 2:18:07remember i said i'm an old linux guy old
- 2:18:10unix guy
- 2:18:10so i'm going to say cat r d and what i'm
- 2:18:13going to do here
- 2:18:15is i'm going to cast it something called
- 2:18:17casting it
- 2:18:18as xml so i'm going to copy this file
- 2:18:21and i'm going to cast it as xml and now
- 2:18:24i have this
- 2:18:25object dollar sign x which contains
- 2:18:29the xml okay now this is really xml
- 2:18:32right so
- 2:18:32if i did the way you can tell that is
- 2:18:35you can type get type
- 2:18:37and you can see it's an xml document
- 2:18:39okay so this is xml
- 2:18:41now have you ever worked with xml not in
- 2:18:44its raw form
- 2:18:46it's hideous it is like kicking a dead
- 2:18:49whale along the beach you know
- 2:18:50all sorts of effort and it seems little
- 2:18:53result
- 2:18:54nothing ever ever happens it's just
- 2:18:55hideous but not in powershell right so
- 2:18:57in powershell
- 2:18:58again i map this hideous world to your
- 2:19:00world right so remember what does this
- 2:19:02thing look like
- 2:19:05blah like right okay well here when i
- 2:19:07said oh i see dallas on x dot play
- 2:19:10dot play okay oh look at that
- 2:19:14so then here are the the x
- 2:19:18oh look at that and so i could say well
- 2:19:20hey give me act 0
- 2:19:22and give me the scene and hear all the
- 2:19:26scenes
- 2:19:27and then i can say hey scene 0
- 2:19:30give me the speech and there are all the
- 2:19:34speeches
- 2:19:35okay okay look at that is that cool or
- 2:19:38what now wait wait wait it gets better
- 2:19:39here if i get rid of this index so
- 2:19:42remember
- 2:19:43it gave me a set of of things and i
- 2:19:46selected the first one
- 2:19:47so now what i'm gonna do and because
- 2:19:48powershell version three
- 2:19:50i can go and i say hey i want all the
- 2:19:52scenes and i want
- 2:19:53all the acts and it gives you to them
- 2:19:57all
- 2:19:58okay now if you remember let's let me
- 2:19:59just do something to select
- 2:20:01first one okay so
- 2:20:04now what i can do is i can say hey i
- 2:20:06would like to group them
- 2:20:08by the speaker and i would like to sort
- 2:20:11them
- 2:20:12by count and if you're gonna
- 2:20:15if you're in theater you definitely want
- 2:20:17to be romeo
- 2:20:19right right that's not the third
- 2:20:20musician because the third musician has
- 2:20:22exactly one speech
- 2:20:24whereas romeo has 163. now let's just
- 2:20:28think about this a second
- 2:20:30let's just think about this a second so
- 2:20:32here i have this xml and the point is
- 2:20:34that there's a bunch of xml in the world
- 2:20:36right
- 2:20:36like you didn't ask for it but somebody
- 2:20:38decided hey i'm going to give you some
- 2:20:40xml
- 2:20:41thank you thank you so much but and so
- 2:20:44it's like
- 2:20:44uh like what what what what what this
- 2:20:47hideous horrible world and again if
- 2:20:49you've ever dealt with xml you know
- 2:20:51exactly what i'm
- 2:20:52talking about but what we do is we're
- 2:20:54able to
- 2:20:55by the way by the way if i wanted to get
- 2:20:57the history of things that i
- 2:20:59typed you would type get
- 2:21:02history okay
- 2:21:05and so here are the things that i typed
- 2:21:07so what i did
- 2:21:09was i
- 2:21:12[Music]
- 2:21:14okay so first was i got the content of
- 2:21:17that file
- 2:21:17and i cast it to xml here somewhere
- 2:21:21somewhere somewhere here
- 2:21:24right and then i showed you that it was
- 2:21:27an xml document
- 2:21:28here and then you're able to ask for the
- 2:21:30play
- 2:21:31we were able to see that it had an act i
- 2:21:33drilled into act
- 2:21:34one i saw that it had scenes i drilled
- 2:21:37into scene one
- 2:21:38and saw that it had speeches and i got
- 2:21:40that speech and then
- 2:21:41i removed all those and i got all the
- 2:21:43speeches
- 2:21:45and then i selected the first one to
- 2:21:48find out what the properties of that
- 2:21:49speech were
- 2:21:50i saw that it had a speaker and so i
- 2:21:53grouped it by speaker and sorted it by
- 2:21:54count
- 2:21:55and it's that simple and what's really
- 2:21:58amazing about this is is notice that
- 2:22:00we're utilizing the pipeline
- 2:22:02and we're building these results as we
- 2:22:04move along we're utilizing the objects
- 2:22:06because it's an
- 2:22:06object-based pipeline and so even
- 2:22:10you know what he's right if you're in
- 2:22:11version two we didn't use the pipeline
- 2:22:13but that is actually the point
- 2:22:14in version two you would have had to use
- 2:22:16the pipeline back from
- 2:22:18from this when we did this right
- 2:22:21to get everything what you would have
- 2:22:23had to have done was something like
- 2:22:25because we fixed it right you would have
- 2:22:27done something like
- 2:22:28let's see i think it was this you would
- 2:22:30have to say
- 2:22:32through select minus expand
- 2:22:39scene no
- 2:22:42i think i even got that wrong through
- 2:22:44select minus expand
- 2:22:47speech and i did get this wrong anyway
- 2:22:49so a bunch of pipelines very very
- 2:22:51powerful stuff and in version three
- 2:22:53we simplified it with the dot syntax and
- 2:22:56the dot syntax you're going to see quite
- 2:22:57a bit today as we start utilizing it but
- 2:22:59combining that along with the pipeline
- 2:23:02really makes it very powerful now a
- 2:23:04couple of other things that jeffrey was
- 2:23:05showing you that i want to highlight and
- 2:23:07we're going to need this information for
- 2:23:09this afternoon
- 2:23:10so along with working with objects
- 2:23:12jeffrey also showed
- 2:23:13you showed you a filter so let me give
- 2:23:16you an example get
- 2:23:17service we have a commandlet called
- 2:23:20where
- 2:23:20object now where object is a way for you
- 2:23:23to filter out only the data that you
- 2:23:25want to see
- 2:23:26usually you'll see it abbreviated down
- 2:23:28to where it's
- 2:23:29that's using the alias that way now
- 2:23:32there is a parameter called
- 2:23:34filter script that has a couple of
- 2:23:37squigglies
- 2:23:39squigglies whatever happens in the
- 2:23:42squigglies
- 2:23:43is your filter now i'm going to show you
- 2:23:44a couple of ways to write a filter
- 2:23:46because this is what you're going to see
- 2:23:47on the internet
- 2:23:48first of all almost nobody uses the
- 2:23:51parameter name
- 2:23:52filter script so it's the squigglies i
- 2:23:55want you to see something
- 2:23:56this is a special symbol now we're going
- 2:23:58to talk about variables later but the
- 2:23:59dollar
- 2:24:00sign is a special indicator for you and
- 2:24:02in this case
- 2:24:03dollar sign underscore means
- 2:24:06the current object crossing the pipeline
- 2:24:09now
- 2:24:10notice i've got get service that's got a
- 2:24:12whole bunch of objects we're going to
- 2:24:13send
- 2:24:14one at a time across the pipeline i want
- 2:24:16to grab hold of that for a second
- 2:24:17because i want to do something to it
- 2:24:20it's stored in dollar sign underscore
- 2:24:22now in v3 there's another way that we
- 2:24:26can show you to do this but hang on a
- 2:24:27sec let me show you
- 2:24:28i want to look at the property
- 2:24:32status and if it's equal to
- 2:24:36running as a filter i want you to think
- 2:24:38about this
- 2:24:39this is going to filter out only the
- 2:24:41things that equal to running now i know
- 2:24:44you might be saying
- 2:24:45what the devil is this eq over here why
- 2:24:47isn't it
- 2:24:48why isn't it equals why isn't it equals
- 2:24:52yeah so here's the thing bruce payette
- 2:24:53superstar rockstar wrote this great book
- 2:24:55powershell in action
- 2:24:56where he goes and describes all the
- 2:24:58reasons why we made the language choices
- 2:25:01so if you ever get to the point where
- 2:25:02you're asking deep questions like this
- 2:25:05bruce's book powershell in action is the
- 2:25:07book to answer it
- 2:25:08here's the thing we struggled with this
- 2:25:10one over and over and over again
- 2:25:11honestly
- 2:25:12as as we started and designed the
- 2:25:14language in the system
- 2:25:15we struggled with saying hey we want to
- 2:25:17be interactive
- 2:25:19and programmatic see in in linux where
- 2:25:21we had all
- 2:25:22unix where we had come from you have
- 2:25:24these big separations right
- 2:25:26you start off with one tool and then
- 2:25:29that tool fails you and so you got to
- 2:25:30throw everything away and you got to
- 2:25:32pick up another tool right
- 2:25:33try and write it in the shell script
- 2:25:34it's not powerful enough so you throw
- 2:25:36that away and start writing in
- 2:25:37awk and grep and said that's not
- 2:25:39powerful enough so you throw that away
- 2:25:41and then you use it in pearl
- 2:25:42and that's powerful enough but it's too
- 2:25:44slow so then you throw it away and you
- 2:25:46pick up
- 2:25:47and write it in c right so that's my
- 2:25:49joke right unix is a
- 2:25:51sequence of failed tools what we wanted
- 2:25:53to do is to have one tool
- 2:25:55that would work whether you wanted to do
- 2:25:57it interactively
- 2:25:59or you want to do this rich systems
- 2:26:01programming level
- 2:26:02and it turns out that's hard never been
- 2:26:04done before never been done before
- 2:26:07and we did it and honestly we just
- 2:26:09struggled with this
- 2:26:10hey turns out there's a reason why
- 2:26:12interactive shells have an interac have
- 2:26:14a syntax the way they do
- 2:26:15there's a reason why programming
- 2:26:17languages have the language
- 2:26:19the syntax that they do and so we
- 2:26:21struggled with this
- 2:26:22and uh and so we were able to finally
- 2:26:24get this nice match between those two
- 2:26:27and part of the ramification of that was
- 2:26:29or part one of the ramifications of that
- 2:26:31was
- 2:26:32that we needed to use uh well by the way
- 2:26:34when we chose a programming language
- 2:26:35we chose the c style so there's c c
- 2:26:39plus plus c sharp so we chose that style
- 2:26:42of things
- 2:26:42that's why you have squiggle brackets
- 2:26:44versus begin and end or
- 2:26:46do and done or do and od
- 2:26:49always confuse me yeah exactly i like
- 2:26:50the terse kind of language exactly
- 2:26:52um and programmers do too and by going
- 2:26:54guess who's going to write most of your
- 2:26:56commandlets it's the programmers so you
- 2:26:58want a world that's friendly to them
- 2:27:00so um so that's what we did and it
- 2:27:02turned out that uh
- 2:27:03from the grammar from the parser uh if
- 2:27:06you had equals there uh it got ambiguous
- 2:27:08and we tried and tried to try it and you
- 2:27:10couldn't resolve that one thing
- 2:27:12and so that's why we have dash eq and
- 2:27:14let me show you guys
- 2:27:16it so let me i'll show this to you a
- 2:27:18couple of ways dash eq means equals
- 2:27:21and so as you can see i'm just getting
- 2:27:22the services that are
- 2:27:24i filtered out the ones that are stopped
- 2:27:26just the ones that are equal
- 2:27:27but here's the important thing you know
- 2:27:30these are redirect characters
- 2:27:32like file redirect at a in a shell in a
- 2:27:35console you can't use them so
- 2:27:37they created and you can find these by
- 2:27:39doing get help
- 2:27:40they're comparison operators so you can
- 2:27:43either do it by
- 2:27:44looking for comparison you'll find the
- 2:27:45help file for it which is about
- 2:27:47underscore comparison operators that
- 2:27:49lists all of these and you're going to
- 2:27:51see a lot of them in here
- 2:27:53or to see all the operators get help
- 2:27:56on operators because
- 2:27:59this you're going to see us use these
- 2:28:01you've got arithmetic assignment
- 2:28:03comparison operators
- 2:28:04let me just show you a couple of quick
- 2:28:06examples with this
- 2:28:08on this on this filter
- 2:28:11so i've got status equals running let me
- 2:28:14show you the v3 way to write this now
- 2:28:16it's important that you get used to
- 2:28:17seeing it as dollar sign underscore
- 2:28:19because you can see it on the internet
- 2:28:20this way
- 2:28:22and guys like me still use it that way
- 2:28:23but there's a new way to write this
- 2:28:27called ps item
- 2:28:30which makes a little bit more sense to a
- 2:28:33lot of folks that this is current
- 2:28:34holding the current item crossing that
- 2:28:36pipeline so
- 2:28:38get used to seeing it it works the same
- 2:28:39way as dollar sign underscore as you can
- 2:28:41see it'll come across
- 2:28:44you're going to notice that i'm probably
- 2:28:45going to use dollar sign underscore
- 2:28:46because that's
- 2:28:47just what i'm used to using but ps item
- 2:28:49works but we can extend this filter even
- 2:28:52further i want it that it is
- 2:28:54equal to running and
- 2:28:58dollar sign underscore and the name
- 2:29:01is like and when you use like
- 2:29:04now you can use wildcard so i want it
- 2:29:06like
- 2:29:09beast b star and i think i have some
- 2:29:11services that ah
- 2:29:13so this filter now lets me filter down
- 2:29:16data now
- 2:29:17i need you to think about something i'm
- 2:29:18going to do some pseudo code somebody's
- 2:29:20going to yell at me when i do this
- 2:29:22the pseudo code means it's not really
- 2:29:24doing anything so get stuff
- 2:29:28sort then where
- 2:29:33i just want some stuff
- 2:29:36and then out to a file now i i let me
- 2:29:39write this another way get stuff
- 2:29:43by the way don't try that coming out it
- 2:29:44doesn't work
- 2:29:47where which i can't spell some stuff
- 2:29:52sort and then out file which do you
- 2:29:55think is going to be the best
- 2:29:58performing way to write this if you
- 2:30:01think about it think about what's
- 2:30:02actually happening here i'm getting
- 2:30:03stuff
- 2:30:04and then in the first one i am sorting
- 2:30:06it i'm sorting all of it
- 2:30:10it's all sorted and then i'm handing it
- 2:30:12to a filter that goes yeah but i just
- 2:30:13wanted this
- 2:30:14throw the rest of it away thanks for all
- 2:30:16your hard work have a nice day
- 2:30:18as opposed to the second one which is
- 2:30:20get stuff well i just want this
- 2:30:22uh-huh and now sort it done
- 2:30:25so it does matter where you filter and
- 2:30:28where you sort refer to this
- 2:30:29as you filter as far left
- 2:30:33as you possibly can and you can see
- 2:30:35examples today where
- 2:30:37the where object may not be the filter
- 2:30:40that's furthest left as a matter of fact
- 2:30:41you see some cool examples today where
- 2:30:44you want to keep in mind filters far
- 2:30:45left and sometimes that's with the
- 2:30:46commandlet that's starting the process
- 2:30:49so um you know jeffrey i think we're at
- 2:30:51about
- 2:30:52meal time yeah you know so by the way so
- 2:30:54this where
- 2:30:55command is someone you're going to want
- 2:30:56to spend some time with
- 2:30:58that is one of the most powerful things
- 2:31:00like on the
- 2:31:01face of the planet you guys are going to
- 2:31:03have questions after this now i'm going
- 2:31:05to give you some references to go to as
- 2:31:07a matter of fact
- 2:31:07don's got a great book out there that
- 2:31:10you're really going to want to take a
- 2:31:11look at and i'm going to mention a
- 2:31:12little bit later on
- 2:31:13but when you have questions when you
- 2:31:15have things that um you are burning
- 2:31:17desires for powershell
- 2:31:19i have a place for you to go and i and
- 2:31:20since don is here let me just show it to
- 2:31:22you if i can figure out how to work
- 2:31:25windows here here we go i'm so used to
- 2:31:28the powershell stuff i forget the
- 2:31:30so there's this place called
- 2:31:33powershell.org.org
- 2:31:35and look this is a centralized place for
- 2:31:37you to find a ton of resources but one
- 2:31:39of the most important things out there
- 2:31:41is when you go out here you'll see the
- 2:31:43forums you can go out there and you can
- 2:31:44ask
- 2:31:45questions and you can get answers and a
- 2:31:47lot of mvps and a lot of super gurus are
- 2:31:49out there
- 2:31:49and it'd be even be great if someday you
- 2:31:52decide to help answer some questions but
- 2:31:54we've got forums we've got free e-books
- 2:31:56out there to help you with some of the
- 2:31:58specialized topics that we're going to
- 2:31:59be getting into today
- 2:32:00free powershell people's favorite word
- 2:32:03in the world
- 2:32:04free also i want to point out that we've
- 2:32:08got
- 2:32:08articles um there is a powershell summit
- 2:32:11so there's information on the summit we
- 2:32:12got a new summit coming up and tickets
- 2:32:14are going to go on sale and
- 2:32:16i'm not trying to be a sales guy or
- 2:32:17anything just letting you know and also
- 2:32:19one of the the podcast uh the
- 2:32:21powerscripting podcast
- 2:32:23it has a ton of information especially
- 2:32:25over the last five years
- 2:32:27of powershell and the power scripting
- 2:32:28podcast is out there and an entire
- 2:32:31script repository so go to
- 2:32:32powershell.org
- 2:32:33and ask questions after this event we'll
- 2:32:36be happy to help you out and don's
- 2:32:38the guy in charge of this and one of the
- 2:32:40people responsible for this so
- 2:32:42thanks don glad you're helping us out
- 2:32:44today um before we get started into
- 2:32:47uh chapter six there were some things
- 2:32:49that we were noticing in chat
- 2:32:51that we'd like to kind of talk about in
- 2:32:52the next exactly yeah so one of the
- 2:32:54questions had come up around case
- 2:32:56sensitivity
- 2:32:57and again whatever you yeah so whenever
- 2:33:00you wonder hey
- 2:33:01how does powershell do things think hey
- 2:33:03what would somebody who's severely
- 2:33:05flawed due
- 2:33:06right and of course that's that's your
- 2:33:09best predictor
- 2:33:10and so we try and be as case insensitive
- 2:33:13as possible right
- 2:33:14so wherever we have the opportunity we
- 2:33:17make things case insensitive
- 2:33:18there are however uh certain you know
- 2:33:21powershell commandlets you know other
- 2:33:24teams that require case sensitivity if
- 2:33:26that ever happens
- 2:33:28uh it'll be highlighted in the
- 2:33:29documentation but if it's not
- 2:33:30highlighted in the documentation
- 2:33:33you can assume case insensitivity that's
- 2:33:35what my wife says she says you
- 2:33:36you're very case insensitive i said no
- 2:33:38i'm very case sensitive very case
- 2:33:39sensitive and she says no
- 2:33:40very case insensitive very case and then
- 2:33:42i have to show her comparison operators
- 2:33:44where you can
- 2:33:45specify but yeah no i'm very sensitive
- 2:33:48anyways that doesn't
- 2:33:49anyways that almost worked it almost
- 2:33:51worked so back to you though you wanted
- 2:33:53to do some more stuff on wednesday yeah
- 2:33:54i want to party on wear okay so
- 2:33:56so here's the thing with wear right so
- 2:33:58originally we uh uh tried to design
- 2:34:00this where right so let's refresh our
- 2:34:02memory so we had we have
- 2:34:04get process right that's too many things
- 2:34:08and so then what we said was we want to
- 2:34:10filter this and so we pipe this to where
- 2:34:13right and we have the squiggle brackets
- 2:34:15now originally the way this worked was
- 2:34:18um we hired we hired some smart guys and
- 2:34:22we said hey
- 2:34:22we need sql against objects against
- 2:34:26live.net objects and they said uh-huh
- 2:34:30i said go at it my friend this will be
- 2:34:32straightforward
- 2:34:33and like three months later they came
- 2:34:35back and it was like and
- 2:34:37they had only done a small subset and
- 2:34:39the syntax was wonky
- 2:34:41and it's just clear oh that's why
- 2:34:44sql has like a couple hundred guys
- 2:34:46working on this turns out it's a
- 2:34:48hard problem and so we
- 2:34:51we took a different approach and what we
- 2:34:52did was we threw all that code away like
- 2:34:54three months ago just threw it away
- 2:34:56and literally literally we replaced it
- 2:34:59with
- 2:35:00three lines code three lines of code and
- 2:35:03and here's the kicker does that mean we
- 2:35:04can replace all the sql guys now too
- 2:35:06and it's far more powerful than sql
- 2:35:09basically three lines of code far more
- 2:35:11powerful than sql i'm going to prove it
- 2:35:13to you that's pretty bold right
- 2:35:14so here's here are the three lines of
- 2:35:16code okay so
- 2:35:18where basically takes each object that
- 2:35:21comes in the pipeline
- 2:35:22it assigns it to a variable step number
- 2:35:25one assign it to a variable
- 2:35:26dollar sign under bar now it's dollar
- 2:35:28sign under bar and dollar sign ps
- 2:35:30item we assign it to a variable the
- 2:35:33second
- 2:35:34is we evaluate the code within the
- 2:35:36squiggle brackets
- 2:35:37we run the code and three
- 2:35:41if the code returns true
- 2:35:45we pass the object on and if it doesn't
- 2:35:49we throw it away okay so it's that
- 2:35:51simple it's truman's code
- 2:35:53okay so now notice so that's why you're
- 2:35:56able to do things like
- 2:35:57hey um uh handles
- 2:36:01greater than 1000 1000
- 2:36:04okay so we grab the current object as
- 2:36:07you notice here the first object here is
- 2:36:10oh let's see
- 2:36:11this thing and its handles is 82.
- 2:36:14so we take this object which is the row
- 2:36:17we assign it to dollar sign under bar
- 2:36:20and then we
- 2:36:20evaluate this hey is are the handles
- 2:36:23greater than 1000. the answer is
- 2:36:25false so you're going to see that object
- 2:36:27doesn't get passed on
- 2:36:29if ever it's true we then pass on the
- 2:36:32object
- 2:36:32as it is and you see
- 2:36:36that all the things are greater than
- 2:36:37hundred now remember the algorithm
- 2:36:40it's important to memorize the algorithm
- 2:36:42there are very few things that you
- 2:36:43memorize in powershell
- 2:36:44this is one of them assign the object to
- 2:36:47dallas and underbar
- 2:36:48evaluate the code if the code evaluates
- 2:36:51to true
- 2:36:52pass the object on if it evaluates to
- 2:36:54false don't do that okay now
- 2:36:58notice i never said that you had to use
- 2:36:59the object in the expression
- 2:37:01right so what's that mean so i could
- 2:37:04have said
- 2:37:05now here i'm going to limit this right
- 2:37:06i'm going to say star ss
- 2:37:08okay so we're going to do a subset
- 2:37:09because it makes it a little easier
- 2:37:11i can say where
- 2:37:14dollar sign falls notice i didn't use
- 2:37:17dollar sign under bar
- 2:37:19nothing passed on because it always
- 2:37:21evaluates to false
- 2:37:22notice i can say dollar sign true
- 2:37:26and it always succeeds okay so what i'm
- 2:37:28really talking about so that's literally
- 2:37:30how it works this isn't a joke that's
- 2:37:32literally how it works now the point is
- 2:37:34these are not very useful
- 2:37:36and this is useful but the thing i want
- 2:37:38to point out here is that you just run
- 2:37:40the code the code can do
- 2:37:41anything in this example it's a simple
- 2:37:44expression
- 2:37:45but you could have put a very complex
- 2:37:47expression you could have put
- 2:37:49a script you could have put 10 pages
- 2:37:51worth of code here
- 2:37:52you know calling up your mother to ask
- 2:37:54her opinion on things looking things up
- 2:37:56in active directory checking things in
- 2:37:58sql you can do anything you want
- 2:38:00at the end it has to evaluate to true or
- 2:38:01evaluate to false and that's how it
- 2:38:02works
- 2:38:03so it is incredibly powerful now there's
- 2:38:05one other thing i want to say about
- 2:38:06where
- 2:38:07and that is a lot of people who begin
- 2:38:10with powershell look at these squiggle
- 2:38:11brackets and they said
- 2:38:12ah you know it's like mouse and so we
- 2:38:16have
- 2:38:16a very simplified version of wear now
- 2:38:19this
- 2:38:20isn't as rich as this wear you use with
- 2:38:22the squiggle brackets you can do
- 2:38:24anything
- 2:38:24the simplified wear you can do very
- 2:38:26subset of things you can do
- 2:38:28things where a property operator value
- 2:38:31so what you do and you don't have to
- 2:38:33have the squiggle brackets so there you
- 2:38:34go there's a deal
- 2:38:35and you don't have dollar sign under bar
- 2:38:38right so you get rid of that
- 2:38:39and you can just say where handles
- 2:38:42greater than
- 2:38:431000 and voila it works
- 2:38:47and i think for a lot of admins just
- 2:38:48getting started especially with
- 2:38:49filtering because filtering is going to
- 2:38:51be one of the most important things that
- 2:38:52you do
- 2:38:53this simplified syntax can be really
- 2:38:55helpful at first until you get more
- 2:38:57used to the squiggly brackets now like
- 2:39:00jeffrey said though
- 2:39:01there are limitations there as soon as
- 2:39:02you want to start doing
- 2:39:04multiple criteria and as soon as you
- 2:39:05wanted to call up your mother and check
- 2:39:07with her first
- 2:39:08that's going to require the squiggly
- 2:39:10brackets but i really like the
- 2:39:11simplified
- 2:39:12yeah can i tell you i use this thing all
- 2:39:13the time the simplified one
- 2:39:15yeah so matter of fact when we look at
- 2:39:17doing um some remoting stuff with
- 2:39:18software and that i'll
- 2:39:19i'll just do where installed yeah
- 2:39:21exactly yeah make it real short and
- 2:39:23sweet so
- 2:39:24it's going to get really cool guys
- 2:39:27that was awesome yeah okay
- 2:39:30let's get serious for a moment no maybe
- 2:39:33you ought to keep us both on screen
- 2:39:34because we both have to have this
- 2:39:36serious look on our face
- 2:39:39we're going to go into the pipeline now
- 2:39:41and but deeper
- 2:39:43deep deeper deeper you were committing
- 2:39:45all sorts h violated hr violations
- 2:39:47today you were just like it was
- 2:39:50inappropriate
- 2:39:51whose is a pacman no inappropriate
- 2:39:54so here's the deal what we're going to
- 2:39:56show you is something that is very
- 2:39:58advanced
- 2:39:59and you you need to know this you you
- 2:40:02need to know this but
- 2:40:03what's going to happen is that you're
- 2:40:04going to see the concept here and it's
- 2:40:06going to happen really quick
- 2:40:07and then you're going to need to
- 2:40:08practice this and you're going to have
- 2:40:09problems practicing this so i'm going to
- 2:40:11give you a couple of references
- 2:40:12right now before we get started first of
- 2:40:15all you're going to want
- 2:40:16chapter 9 out of don jones's book
- 2:40:19lunches
- 2:40:20uh uh sorry powershell in a month of
- 2:40:23lunches yes learn windows powershell in
- 2:40:25a month of lunches
- 2:40:27you chapter nine you're going to want
- 2:40:29that chapter and it'll take you through
- 2:40:31everything that we're gonna do and you
- 2:40:33will get a chance to try it now let me
- 2:40:35tell you how important this was
- 2:40:36i was sitting if you guys have been to a
- 2:40:37conference before i'm sure you have been
- 2:40:40i was sitting in a conference and you
- 2:40:41know they they have the
- 2:40:43the con you know like tech ed i mean
- 2:40:45they're enormous
- 2:40:46they put speaker they put the speaker
- 2:40:48they put the rooms over there and rooms
- 2:40:50over here and a football field
- 2:40:51in the middle now that's where all the
- 2:40:54sponsors go but
- 2:40:55there's this there's this giant football
- 2:40:57field and they don't put a lot of seats
- 2:40:58in there
- 2:40:59so you see all these people sitting up
- 2:41:00against the wall and working on stuff
- 2:41:03well i was sitting up against the wall
- 2:41:05working on a problem
- 2:41:06with getting two commandlets to work
- 2:41:08together in exchange and i couldn't get
- 2:41:10it to work
- 2:41:10together and i said to myself i said
- 2:41:15it it's it's a problem with the guys
- 2:41:18that wrote the commandlets it's a
- 2:41:19problem with powershell it just doesn't
- 2:41:21work i'll just
- 2:41:22i just can't solve that problem and not
- 2:41:24but a few moments later
- 2:41:26you and then shortly there after that
- 2:41:28don jones
- 2:41:30you taught me how to figure out how the
- 2:41:32pipeline works
- 2:41:33and suddenly by with this knowledge
- 2:41:36suddenly
- 2:41:37i could get that solution to work and i
- 2:41:39guess what the moral of the story is
- 2:41:41is that as soon as you understand this
- 2:41:43the answer is
- 2:41:44you can always get it to work so never
- 2:41:47give up
- 2:41:48it's just it's a little tricky at first
- 2:41:50yeah this is one of those things my i
- 2:41:52used to have a physics professor who
- 2:41:53would say
- 2:41:54this problem is simple once solved so
- 2:41:58we're gonna help you solve it when you
- 2:42:00first look at it you're like what the
- 2:42:01heck what the heck
- 2:42:02and then at some point there'll be this
- 2:42:04moment of clarity and that's just super
- 2:42:06super simple it really is
- 2:42:23[Music]
- 2:42:32here we go let me start you out with a
- 2:42:33concept and jeffrey and i are going to
- 2:42:35work through this we're going to talk
- 2:42:36about how the pipeline works
- 2:42:38and how things when objects get passed
- 2:42:41how does the receiving commandlet know
- 2:42:43what to do with them
- 2:42:44if anything at all i i'm not a good guy
- 2:42:47with sports analogies
- 2:42:48because i don't know anything about
- 2:42:49sports but as i understand it
- 2:42:51there's this thing with the small white
- 2:42:53balls where they have catcher's mitts
- 2:42:55so you know the sending command that's
- 2:42:58going to send some baseballs and we have
- 2:42:59to see what catcher's mitts they get
- 2:43:01caught on the receiving commandment
- 2:43:03you'll see what i mean we have a process
- 2:43:05of by value and by property name and
- 2:43:08if those don't work we have a last line
- 2:43:11of resorts so
- 2:43:12i'm just going to first of all point out
- 2:43:14that all of this is in the slides but
- 2:43:15i'm not going to use the slides
- 2:43:17so here we go let's get rid of the
- 2:43:19slides
- 2:43:21let's start with an idea get service if
- 2:43:24i can spell it
- 2:43:26stop service guys we showed you this
- 2:43:28earlier and you
- 2:43:29we did dash what if you know that it's
- 2:43:31going to work
- 2:43:33but the question that i have in my head
- 2:43:35is why well here's what's happening
- 2:43:38getservice has is getting a bunch of
- 2:43:41services a bunch of objects and we're
- 2:43:42going to send one object at a time
- 2:43:43across the pipeline
- 2:43:45my question is is the receiving command
- 2:43:47which in this case is stop service
- 2:43:51how is it grabbing hold of this object
- 2:43:52and how does it know what to do with it
- 2:43:54and
- 2:43:54as it turns out it has a lot to do with
- 2:43:57the parameters on the receiving
- 2:43:59commandlet and that's what i want to
- 2:44:01show you first of all one of the first
- 2:44:04things we need to know
- 2:44:05when we're looking at this is when we
- 2:44:08send
- 2:44:09we're sending objects we need to know
- 2:44:11what kind of objects
- 2:44:12they are so i piped it to get member
- 2:44:15because get member shows me what type of
- 2:44:18object
- 2:44:19is being sent across the pipeline this
- 2:44:21is a service controller object
- 2:44:23i need to know that right now now what i
- 2:44:26want to do is
- 2:44:26i want to see what the receiving
- 2:44:29commandlet is capable of receiving
- 2:44:32to do that we look at the help file for
- 2:44:34it the receiving command
- 2:44:36in this process you have a tendency to
- 2:44:38get confused between
- 2:44:39piping to get member and get help but
- 2:44:41it's pipe to get member to see
- 2:44:43the object what kind it is and then we
- 2:44:45look at the help file on the receiving
- 2:44:47commandlet so
- 2:44:48let me show you get help on stop service
- 2:44:51now
- 2:44:51i'm going to use dash full because i
- 2:44:53want you to see everything but jeffrey
- 2:44:54will show you a trick here in a second
- 2:44:57let me go in here and show you inside we
- 2:44:59now
- 2:45:00are very concerned with this information
- 2:45:02we already know how to look at the
- 2:45:04syntax i want to go down here and look
- 2:45:05at the parameters
- 2:45:06the parameters have a capability
- 2:45:09sometimes and that capability is
- 2:45:12do they accept pipeline input now think
- 2:45:15of these guys
- 2:45:16as the parameters are the things with or
- 2:45:18without the catchers met so
- 2:45:20what we're asking is is do you have a
- 2:45:21catcher's mitt or not where you could
- 2:45:23catch this object and do something with
- 2:45:25it
- 2:45:25well a lot of times you'll see like
- 2:45:27display name it it doesn't
- 2:45:29accept pipeline input so there's nothing
- 2:45:31going to cross
- 2:45:32but let's go down this list i often
- 2:45:34start at the bottom but let's go down
- 2:45:35this list
- 2:45:37and this is um stop service so let's see
- 2:45:39here dash what if well dash what if it
- 2:45:41doesn't even make sense to accept
- 2:45:43pipeline input dash confirm
- 2:45:45no that doesn't accept it pass through
- 2:45:48that doesn't accept it
- 2:45:49dash name that does accept it now here's
- 2:45:53what we're concerned about
- 2:45:54we have two ways of accepting pipeline
- 2:45:56input by value
- 2:45:58and by property name and if you're a dev
- 2:46:00out there we're not talking about by
- 2:46:01vowel by ref this is different
- 2:46:03but by value and by property name
- 2:46:06the first way we're going to try it is
- 2:46:08by value and what you're going to notice
- 2:46:10here is
- 2:46:10dash name it supports accepting pipeline
- 2:46:13input by value
- 2:46:14and it would like some kind of string
- 2:46:17well
- 2:46:17wait a second let me show this to you
- 2:46:19let me go up a little bit further
- 2:46:21see this parameter called input object
- 2:46:22i'm not exactly sure what it does but it
- 2:46:24accepts
- 2:46:26true by value look at the kind of
- 2:46:29object it would like a service
- 2:46:31controller wait a minute wait a minute
- 2:46:32wait a minute
- 2:46:33when i did get service what kind of
- 2:46:35object was i sending it
- 2:46:37i was sending a service controller so
- 2:46:39when a service controller comes
- 2:46:41cruising across that pipeline to stop
- 2:46:43service
- 2:46:45the catcher's mitt that's going to grab
- 2:46:46it is the
- 2:46:48input parameter catcher's mitt because
- 2:46:51this name
- 2:46:52is spelled exactly like service
- 2:46:55controller
- 2:46:55of the object type that i sent i know
- 2:46:58this is weird but
- 2:47:00they're spelled the same so since
- 2:47:02they're spelled the same
- 2:47:03this means we're actually passing it by
- 2:47:05value and this is the one of the most
- 2:47:06efficient ways
- 2:47:08to pass so that's how get service
- 2:47:11and stop service actually work we're
- 2:47:13passing by value
- 2:47:15into the parameter input object
- 2:47:18because the names match the type of
- 2:47:21object along with
- 2:47:22what the parameter expects
- 2:47:26here's where it gets a little tricky and
- 2:47:29please jump in
- 2:47:30as soon as you want to yell at me about
- 2:47:31something because you're doing great you
- 2:47:32think so because man this was this was
- 2:47:34hard on me at first but as soon as i got
- 2:47:36this this is
- 2:47:37you got it what made made the world rock
- 2:47:40let's try this notice that i did get
- 2:47:42service stop service and i want to point
- 2:47:44something out to you notice how the
- 2:47:45nouns match
- 2:47:46well if the nouns match it's likely
- 2:47:49that they're going to work together on a
- 2:47:50pipeline it's also
- 2:47:52likely that they'll probably pass by
- 2:47:54value but
- 2:47:56that's not always the case so you always
- 2:47:57want to check to make sure
- 2:47:59let me show you something where the
- 2:48:00nouns don't match
- 2:48:03get service stop process well these are
- 2:48:06two totally different things
- 2:48:07services processes they're not the same
- 2:48:10thing
- 2:48:11so i'll bet most of you are thinking the
- 2:48:13same thing that i am this
- 2:48:14isn't going to work it can't possibly
- 2:48:17work
- 2:48:18services processes let's go through this
- 2:48:21process and take a look
- 2:48:24i'm going to do get service and i'm
- 2:48:25going to pipe it to get member i know we
- 2:48:27know the answer to this but i just want
- 2:48:28to go through the process again
- 2:48:30what kind of object are we sending we're
- 2:48:32sending a service controller object
- 2:48:33across now the first thing i want to
- 2:48:35check
- 2:48:35is to see if there's something in stop
- 2:48:38process
- 2:48:38that supports pipeline input by value
- 2:48:42for this object that would be the first
- 2:48:44way we would hook up
- 2:48:45so i'm going to do get help on the
- 2:48:46receiving commandlet which in this case
- 2:48:48is stop process
- 2:48:53and let's take a quick look let me get
- 2:48:56up to the parameters
- 2:48:58now guys i'm going to shorten this down
- 2:48:59a little bit because i know some of
- 2:49:00these parameters just don't accept
- 2:49:02pipeline input like what if
- 2:49:03it doesn't accept pipeline input so i
- 2:49:05don't even need to look at it so every
- 2:49:06time it says false
- 2:49:07i'm not really that interested in it
- 2:49:09passthrough doesn't support it
- 2:49:11dash name it does support it but right
- 2:49:13now i'm checking for by value this is my
- 2:49:15property name so i'm looking for things
- 2:49:16by value
- 2:49:18up there we go input object it supports
- 2:49:20pipeline input it'll catch it
- 2:49:22and it's doing it by value the first way
- 2:49:24we're going to do it but look at what it
- 2:49:26wants
- 2:49:26a process object well i'm not sending it
- 2:49:30process isn't spelled the same way as
- 2:49:33service controller
- 2:49:36not even close so there's not going to
- 2:49:39be
- 2:49:39a hookup here so by value
- 2:49:43fails well now at this point you kind of
- 2:49:46go well if it fails it's just not going
- 2:49:47to work
- 2:49:48no now we move on to the next process
- 2:49:51which is by
- 2:49:51property name and this gets a little bit
- 2:49:54confusing i want you to notice while i'm
- 2:49:56in this help file
- 2:49:57see how the parameter dash name
- 2:50:01takes pipeline input by property name
- 2:50:05here's what that's saying the object
- 2:50:08that you're sending to me
- 2:50:10does it have a property that is spelled
- 2:50:14exactly like the parameter name that's
- 2:50:17what we mean by property name
- 2:50:18is it spelled the same and if so i might
- 2:50:21be able to hook up that way
- 2:50:22if by vowel fails i'll try this so
- 2:50:26here's what i'm going to do here's the
- 2:50:28catch phrase whenever you want to know
- 2:50:30everything there is to know about an
- 2:50:32object you pipe it to get members so
- 2:50:34get service and i'm going to pipe it to
- 2:50:39get member take a look at this list
- 2:50:43is there a property and remember we only
- 2:50:46all we need is the word property in it
- 2:50:48is there a property
- 2:50:49that is spelled the same way as the
- 2:50:51parameter name and if you look at the
- 2:50:53list
- 2:50:56there is if they're spelled the same
- 2:50:58we're going to have a hookup by property
- 2:51:00name
- 2:51:01but watch what's going to happen here
- 2:51:04so let's look i'm only going to take one
- 2:51:06service here
- 2:51:08service look at what its name is it's
- 2:51:10the name of the service
- 2:51:12okay wait a second when you look at
- 2:51:15processes let's look at processes
- 2:51:21uh process name is also name
- 2:51:25these are process names so when you
- 2:51:28use the commandlet oops clear the screen
- 2:51:31when you use the command
- 2:51:32hello clear the screen there we go when
- 2:51:34you use the commandlet stop
- 2:51:36process what it wants for its dash name
- 2:51:39is the name of a process what i'm
- 2:51:42sending it
- 2:51:44is the name of a service but here's the
- 2:51:48thing
- 2:51:48we do have a hookup this is going to
- 2:51:51work
- 2:51:52it's just your results may be a little
- 2:51:54unusual so let's try it get service
- 2:51:57pipe to stop process this should work
- 2:52:00and
- 2:52:00yeah i'm going to do a dash what if
- 2:52:02because you know why i'm doing a dash
- 2:52:04what if because it does
- 2:52:05actually work notice there's a lot of
- 2:52:07blood on my screen
- 2:52:09now what this means is is that yeah look
- 2:52:11cannot find the process with the name
- 2:52:14well yeah because that's a service name
- 2:52:15of course you can't find that but if you
- 2:52:17look here did you see anything
- 2:52:19white flyby cause that means
- 2:52:22it worked let me see if i can find
- 2:52:24something oh there's always something
- 2:52:27i didn't see anything really don't
- 2:52:28embarrass me in front of my friends
- 2:52:30it's only five thousand or two i know
- 2:52:32there's there's almost always something
- 2:52:34in here that's in white
- 2:52:36go to mine so let me show you guys
- 2:52:40okay so here's here's i'll do a
- 2:52:42different set
- 2:52:43okay cool so notice i started up
- 2:52:46calculator here
- 2:52:47right and so i can do get process
- 2:52:51calc and get calculator and i can pipe
- 2:52:55that
- 2:52:56to der and we see that calc
- 2:53:00is in this and why is that
- 2:53:03because der takes binds by name
- 2:53:07and so you take a look and we'll does
- 2:53:09dur take a process
- 2:53:10do it you know
- 2:53:12system.diagnostics.process
- 2:53:14no and it says oh well i bind anything
- 2:53:16by name
- 2:53:17do you have a name and get process does
- 2:53:20have a name
- 2:53:21and therefore it works that's an
- 2:53:24excellent example and so
- 2:53:25between his example in mind you get
- 2:53:27what's happening here is that
- 2:53:29the commandlets are working together but
- 2:53:31you have to look at what you're
- 2:53:33giving it the information that you're
- 2:53:35giving and what it's expecting in the
- 2:53:36case of my get service stop
- 2:53:38process if you have a process running
- 2:53:41that happens to have the same name as a
- 2:53:43service
- 2:53:44it's going to get killed off most of the
- 2:53:47time that's not the case
- 2:53:48in jeffrey's example i've got a process
- 2:53:50name that happens to be
- 2:53:52actually a file i could go looking for
- 2:53:54so that is a good result
- 2:53:55that works out can i show them uh
- 2:53:57actually you know i said that wrong
- 2:53:59it was actually the path the path that
- 2:54:01it was the dir yeah
- 2:54:02so dur takes a path and process uh
- 2:54:05object
- 2:54:06has a path now here notice in my screen
- 2:54:09uh we said oh you know by name well you
- 2:54:12were doing it by name
- 2:54:13right gsv b and and
- 2:54:16notice his name um what is it i want to
- 2:54:19show you
- 2:54:20um through
- 2:54:21[Music]
- 2:54:23do gm okay
- 2:54:26so notice this thing here yeah okay
- 2:54:30name alias property service name so
- 2:54:33unlike i remember i said that powershell
- 2:54:37we're focused in on making your life
- 2:54:39good because
- 2:54:40those people aren't focused in on that
- 2:54:42right they're focused in on
- 2:54:43i'm writing this for myself it's going
- 2:54:45to be cool or hey you're my developer
- 2:54:47buddy and we're going to talk developer
- 2:54:48talk to each other blah blah blah
- 2:54:50and and so it's pretty inconsistent
- 2:54:52world we're responsible for trying to
- 2:54:54make it a consistent world for you
- 2:54:56so whereas you know um you say
- 2:54:59server service name and process was
- 2:55:02process name
- 2:55:03we want to say no you don't care about
- 2:55:05all that crap you just want the name
- 2:55:07name okay and so what we do is we take
- 2:55:09the type system
- 2:55:10and remember how i showed you xml we
- 2:55:12tweaked the xml
- 2:55:13and we presented to you simpler one of
- 2:55:15the techniques we do for that is
- 2:55:17something called an
- 2:55:18alias property an alias property is with
- 2:55:20something here we say hey
- 2:55:22that we have this property name which is
- 2:55:25aliased
- 2:55:26to service name so the proper the object
- 2:55:29itself really only has this thing called
- 2:55:31service name but we say
- 2:55:33hey treat it as though it has a name um
- 2:55:36which and then when you ask for it given
- 2:55:38the service name and that makes
- 2:55:39that gives you a simplified uh
- 2:55:42consistent view of the world
- 2:55:44and it makes this interoperability stuff
- 2:55:46work because if it turns out that hey
- 2:55:48i want to send something to some command
- 2:55:51and uh it's accepting things by
- 2:55:53by gojar and i have one of those but i
- 2:55:56call it a
- 2:55:57foe right i just go and i say okay well
- 2:55:59on my foo
- 2:56:00you know i'm going to map its name to
- 2:56:02goojar
- 2:56:04i do that once and then i can send it to
- 2:56:06you as a matter of fact this is a
- 2:56:08perfect
- 2:56:08setup for the next stage in this and so
- 2:56:12understand what he's he's showing you is
- 2:56:13that they've done a lot of work to make
- 2:56:16powershell commands consistent in other
- 2:56:19words we had a service name on the
- 2:56:21object
- 2:56:21but they created an alias property
- 2:56:24called name
- 2:56:24so it could work with other commandlets
- 2:56:26that accept
- 2:56:28by property name so they they're making
- 2:56:31it consistent for us
- 2:56:33but there are times when the greatest
- 2:56:36minds all think alike but
- 2:56:38just haven't had a chance to get
- 2:56:39everything consistent yet
- 2:56:41let me give you an example where this is
- 2:56:42going to break down there's
- 2:56:44one of my favorite commandments is get
- 2:56:46ad computer and i need to tell you that
- 2:56:48one of the things you have to be kind of
- 2:56:49careful with is microsoft
- 2:56:51especially the product teams when they
- 2:56:52work with this they they try to help you
- 2:56:55by not
- 2:56:55doing dangerous things to yourself i
- 2:56:57think about the technology underneath
- 2:56:59what this commandlet's going to do
- 2:57:00if i run this who has this information a
- 2:57:03domain controller does so this command
- 2:57:05has to go out to a domain controller ask
- 2:57:08the domain controller for this
- 2:57:09information and then spit this
- 2:57:10information back
- 2:57:12look quite honestly that if you only
- 2:57:14have a couple dozen computers that's not
- 2:57:16a big deal
- 2:57:17but if you have 30 000 computers this
- 2:57:20could be a big deal this could
- 2:57:22make your domain controller not a domain
- 2:57:24controller for a while and then when it
- 2:57:25spits the data back
- 2:57:27you could have some performance issues
- 2:57:28for a while so when
- 2:57:30you're running commands you will notice
- 2:57:32you know a lot of times you'll do a get
- 2:57:33command and it'll
- 2:57:34just run commandlets that might be a
- 2:57:37little bit more dangerous that's not the
- 2:57:39case what they do
- 2:57:40is they put things in them that are
- 2:57:41mandatory we mentioned this with git
- 2:57:43event log earlier
- 2:57:44this is another great command that has
- 2:57:46an example so let me show you if i just
- 2:57:47strike enter on get ad computer
- 2:57:50uh-uh bro you got to give me a little
- 2:57:52bit more information about this
- 2:57:54you've got to be you i don't want to get
- 2:57:56you everything
- 2:57:58really so i'm just going to put in a
- 2:57:59star this will work
- 2:58:01it'll get me everything but notice what
- 2:58:03i've done i'm the one now that's made
- 2:58:05the decision
- 2:58:06to actually get everything so this is
- 2:58:08the commandment that i'm going to use
- 2:58:09for a second so let me do this get ad
- 2:58:11computer
- 2:58:13and i'm just going to put in the filter
- 2:58:15star which means i'm going to grab
- 2:58:17everything
- 2:58:18and i want to here's my business problem
- 2:58:20what i would like to do is get the
- 2:58:21status of the bit service on
- 2:58:23every computer in the network i know it
- 2:58:25doesn't sound that creative but it gets
- 2:58:27better later
- 2:58:28so get service name bits understand what
- 2:58:32i'm trying to do
- 2:58:33i'm trying to get a list of all the
- 2:58:34computers from active directory
- 2:58:37and i want them piped to get service
- 2:58:40and so that git service will then grab
- 2:58:42the bit service from all of them
- 2:58:43well here's the thing let's see if we
- 2:58:46can figure out how this is going to work
- 2:58:48or not work so first thing is that we do
- 2:58:52is i go through the whole process first
- 2:58:53of all pipe to gms to find out what kind
- 2:58:55of object am i working with
- 2:58:56i need to know this for by value in case
- 2:58:58it works for by value so
- 2:59:00ad computer object sounds great probably
- 2:59:03ain't going to happen because the nouns
- 2:59:04don't match but
- 2:59:0580 computer object great next thing i'm
- 2:59:08going to do is get help
- 2:59:10on git service and see if it did
- 2:59:14see if it supports um uh
- 2:59:1880 computer object by value
- 2:59:21and guys i'm going to make this a little
- 2:59:23bit briefer so rather than scrolling
- 2:59:24through
- 2:59:25every and stopping at every single one
- 2:59:27of them let me just scroll up
- 2:59:28to the things that say by value can i
- 2:59:30show them a trick yeah sure so
- 2:59:32do that again and do minus show window
- 2:59:35so do show window open window
- 2:59:39okay and so if you have full now now
- 2:59:41search by by value
- 2:59:42oh man see this whole this whole show
- 2:59:46this whole show window thing is just
- 2:59:48awesome yeah and then hit next oh wait a
- 2:59:49minute i have to hit next there we go oh
- 2:59:52boy there we go what objects see so now
- 2:59:55look look look we got it except pipeline
- 2:59:58input
- 2:59:58you have to watch me scroll true by
- 3:00:01value we're looking good
- 3:00:03what kind of object does input object
- 3:00:04want it wants a
- 3:00:06sir is that spelled exactly the same way
- 3:00:08as a d
- 3:00:09computer no so no hook
- 3:00:13up by value so close so yeah we're so
- 3:00:15close
- 3:00:17so what we're going to do then is check
- 3:00:19for by property name
- 3:00:21well i have to take a look at what the
- 3:00:23properties are and really the only
- 3:00:25property
- 3:00:25i care about that i'm trying to send
- 3:00:27across is whatever holds
- 3:00:29the computer name so let's take a look
- 3:00:31at that real quick
- 3:00:33um get ad computer
- 3:00:36filter star well gee whiz just take one
- 3:00:40of them there's a whole bunch of stuff
- 3:00:42that's
- 3:00:43being sent across the pipe the only
- 3:00:44thing i care about though is where the
- 3:00:46computer name is and that property is
- 3:00:48called
- 3:00:49name so let's go back to the show window
- 3:00:53and see if we have something that
- 3:00:54supports
- 3:00:56name so pipeline by property name
- 3:00:59and so let's do this trick by
- 3:01:03property name and watch what happens so
- 3:01:05we'll find him
- 3:01:07dash computer name hey that supports by
- 3:01:09prop by property name
- 3:01:11but but remember what the rule is this
- 3:01:15has to be spelled exactly like this for
- 3:01:18by property to hook up
- 3:01:20and it's not in fact it's not spelled
- 3:01:23the same
- 3:01:24but you know what is spelled the same if
- 3:01:26i go down here oops wait
- 3:01:27which way down in it lucky
- 3:01:30aim we do support by property name on
- 3:01:33something spelled exactly the same but
- 3:01:36look at what it says
- 3:01:37it wants a service name so here's what's
- 3:01:40going to happen if i try to run this
- 3:01:42i'm going to take a bunch of computer
- 3:01:43names and it's going to
- 3:01:45think that i'm giving it service names
- 3:01:47and unless you named your computers
- 3:01:49after services which would never be a
- 3:01:51good idea
- 3:01:52this is not going to work you know the
- 3:01:54thing is that
- 3:01:55it really gets me is god if there was
- 3:01:58only a way
- 3:01:59if there only was a way where i don't
- 3:02:02want
- 3:02:02this to be called name i want it to be
- 3:02:04called
- 3:02:05computer names because it was called
- 3:02:07computer name then it would
- 3:02:08it would match and everything would work
- 3:02:10if there was only a way i could change
- 3:02:13this property to say computer name
- 3:02:16and yet there is
- 3:02:20you are shown you want to show them
- 3:02:22you've got your computer
- 3:02:24oh that's you have a computer well let
- 3:02:25me show them that so
- 3:02:28let's do the concept so watch guys take
- 3:02:31a look
- 3:02:32get service and i'm just going to show
- 3:02:34you a quick concept
- 3:02:35i want you to see i'm just going to work
- 3:02:36with one service to keep it simple
- 3:02:38you guys have seen us select properties
- 3:02:41before by the way i don't think you've
- 3:02:42shown them computer name have you shown
- 3:02:44a computer name
- 3:02:45so you know get service works against
- 3:02:47computers
- 3:02:48yes oh yeah yeah i should have shown you
- 3:02:50in the help file you'll see
- 3:02:51it has dash computer name so i could use
- 3:02:53this against remote computers
- 3:02:55which is what i'm trying to get the
- 3:02:56active directory commandlet to do
- 3:02:58i'm going to grab name and status and i
- 3:03:00want you guys to see something yeah it's
- 3:03:01going to give me the name and the status
- 3:03:03that's what you would expect but how
- 3:03:05many of you would expect to get an error
- 3:03:07if this occurred and usually when i'm at
- 3:03:08a conference this is exactly what i type
- 3:03:10because i can't type very well so it
- 3:03:12usually comes out name
- 3:03:14status status
- 3:03:18watch what happens see that
- 3:03:22do you get what's going on here wait a
- 3:03:24minute a lot of people think that that
- 3:03:25should generate an error that shouldn't
- 3:03:26generate an error that's a feature
- 3:03:29let me show you i'm going to pipe that
- 3:03:30to get member
- 3:03:34look it just created
- 3:03:38new properties called nam and students
- 3:03:43so here's the idea i want you to think
- 3:03:45about this
- 3:03:46i wonder if i could take the existing
- 3:03:49property for ad computer called name
- 3:03:53and change it to computer name and the
- 3:03:55answer is yes
- 3:03:56however the answer is yes
- 3:04:01but let me show you how this is going to
- 3:04:02work
- 3:04:04first of all i'm going to select the
- 3:04:07property
- 3:04:08name just so you can see i'm not
- 3:04:11cheating
- 3:04:12and then i'm going to show you some
- 3:04:14special syntax and
- 3:04:15this syntax at first is a little chewy
- 3:04:18but it's in the help file for the select
- 3:04:20dash object and it's in the example so
- 3:04:22it's
- 3:04:23going to be one of the things you want
- 3:04:24to learn it's a hash table syntax and we
- 3:04:26use hash tables everywhere
- 3:04:28so you're going to spend the time you're
- 3:04:29going to learn the syntax this syntax
- 3:04:31you must
- 3:04:32you must you're just going to keep
- 3:04:34typing it till you learn it this is
- 3:04:35something you're going to have to
- 3:04:36keep in so it's an at sign with an open
- 3:04:38squiggly and what we have is the word
- 3:04:40called
- 3:04:40name equals and now you get to create
- 3:04:43your own
- 3:04:44property name what would i what would i
- 3:04:46like this to be called i want it to be
- 3:04:48called
- 3:04:48computer name so i'm going to put in
- 3:04:50computer name
- 3:04:53and at this point semicolon and then you
- 3:04:56specify
- 3:04:57the expression that will fill that
- 3:04:59column with data
- 3:05:01well let's do this expression equals
- 3:05:05and you're going to put that inside of
- 3:05:06squigglies and there's one squiggly left
- 3:05:09over
- 3:05:10so inside here we want the current
- 3:05:12object on the pipeline dollar sign
- 3:05:13underscore or you can use dollar sign ps
- 3:05:16item for with version three
- 3:05:18and what do i want from the object
- 3:05:20that's coming from get a d
- 3:05:22computer i want the original name
- 3:05:25property so watch
- 3:05:27name i'm gonna strike enter and watch
- 3:05:29what happens
- 3:05:32dudettes deuces oh
- 3:05:35i've got myself a computer name now
- 3:05:38property now let me just show you how
- 3:05:41you're going to see this on the internet
- 3:05:42a couple of
- 3:05:43just quickie things this is a you know
- 3:05:45here is custom columns
- 3:05:46calculated properties people use all
- 3:05:48these terms for
- 3:05:49for for this but you almost never see
- 3:05:52everybody type in
- 3:05:53this full syntax this way they're going
- 3:05:54to shorten this up to just an
- 3:05:56e and they're going to shorten this up
- 3:05:58to just an n
- 3:06:00and why because because i'm a flawed
- 3:06:03person
- 3:06:04i can't talk first and i can't type at
- 3:06:06all i'm going to figure out how to spell
- 3:06:08expressions expression i know i know
- 3:06:10but watch guys i want to i want you to
- 3:06:11see that this still works so
- 3:06:13you know i've changed it one other thing
- 3:06:15i want to show you you're going to see
- 3:06:16this a lot on the internet and you need
- 3:06:17to watch out for it
- 3:06:19used to be that instead of name this was
- 3:06:22called
- 3:06:23label and everybody would abbreviate
- 3:06:25this as
- 3:06:26an l well i don't know about you but
- 3:06:28when you see this on a blog post or in a
- 3:06:31book
- 3:06:31you can't tell the difference between an
- 3:06:34l and the number one
- 3:06:36so a lot of times you'll type it in
- 3:06:37wrong and you'll go it just doesn't work
- 3:06:39no if you ever see an l or what looks
- 3:06:42like to be a one
- 3:06:43always replace it with an n that way you
- 3:06:45get rid of
- 3:06:46all of those little ambiguity i can't
- 3:06:48say that word but all those little
- 3:06:50problems
- 3:06:50and big yeah all these wild cards for
- 3:06:54speech so
- 3:06:56let's do this i don't really need this
- 3:06:59name in here anymore because
- 3:07:01i've managed to create my own version
- 3:07:04and i want to show you if you pipe it to
- 3:07:05get member
- 3:07:08see it says computer name so lookie
- 3:07:11when we pass it to the the receiving
- 3:07:13commandlet
- 3:07:14computer name is going to match with
- 3:07:16computer name by property name
- 3:07:20and lo and behold donald trump
- 3:07:23drum roll drum roll drum roll and the
- 3:07:25command was get
- 3:07:26service name bits
- 3:07:34oh come on that is so wickedly cool so
- 3:07:39the guys in the back are going i don't
- 3:07:40know what the hell he just did but okay
- 3:07:42we'll go with it
- 3:07:43but here's the begging for the applause
- 3:07:45yeah pity applause golf clap
- 3:07:47um here's the thing is that
- 3:07:50you know they're working to try to you
- 3:07:52know give you alias properties to
- 3:07:54make some consistencies but that's not
- 3:07:56always going to be the case sometimes
- 3:07:58you're the one that has to do it in
- 3:07:59flight to make the consistency
- 3:08:02using a custom column or calculated
- 3:08:04property
- 3:08:05we use these a ton because there's so
- 3:08:08much we can do with this
- 3:08:10so much we can do with this and you'll
- 3:08:12see some more examples of us of us using
- 3:08:14it in here
- 3:08:15but we do have the last
- 3:08:19the last possibility
- 3:08:22it's my favorite one because everybody
- 3:08:26yells at me when i do this
- 3:08:27by the way it's really worth spending
- 3:08:29time on this stuff this
- 3:08:30is the heart of powershell this is the
- 3:08:33core
- 3:08:34concept it's the core power that's where
- 3:08:37you get all your magic
- 3:08:39so learning the stuff like spending some
- 3:08:41time understanding how it really works
- 3:08:43uh getting familiar with the wear the
- 3:08:45pipelining is
- 3:08:46is the heart of it it's worth an
- 3:08:47investment well and i just i just have
- 3:08:49to say
- 3:08:50and and and this is definitely um
- 3:08:53for me guys this is what changed my
- 3:08:55ability to
- 3:08:57be productive with powershell when i
- 3:08:59learned
- 3:09:00this this is what suddenly made
- 3:09:02powershell
- 3:09:03oh i got this because i could discover
- 3:09:05whatever it is i was looking for
- 3:09:07and now i knew how to put it together
- 3:09:09and if it didn't work i knew how to
- 3:09:10troubleshoot it that's the important
- 3:09:12thing
- 3:09:12i know we're going through it quickly
- 3:09:14here but again
- 3:09:16this is the most important thing and it
- 3:09:18does it changes it makes you totally
- 3:09:20productive now i've shown you three ways
- 3:09:22so far
- 3:09:23in this it's getting the stuff to work
- 3:09:25on multiple machines we're going to talk
- 3:09:26more about remoting
- 3:09:27but that's where you just become so
- 3:09:29productive the number of people who've
- 3:09:31come up to me at tech ad
- 3:09:32and had stories like there's remember
- 3:09:35this one guy who said oh well you know
- 3:09:36his boss brings everybody in on like a
- 3:09:38tuesday it's like oh we got to get this
- 3:09:40information from
- 3:09:41every single one of our servers it's top
- 3:09:43priority gotta have it by the end of the
- 3:09:45week
- 3:09:45call home tell folks you're gonna be
- 3:09:47working late doesn't matter
- 3:09:49we gotta get this done he's like uh
- 3:09:50everybody's like uh
- 3:09:52and so he goes back to his office he's
- 3:09:53like wait a minute wait
- 3:09:55i can do that with powershell he says
- 3:09:57ten minutes later i had all the
- 3:09:59information
- 3:10:00he said it took a couple more minutes to
- 3:10:01put in an excel spreadsheet
- 3:10:03yeah so in like 15 minutes i was done i
- 3:10:06said that's awesome
- 3:10:06what did you do he says well i went home
- 3:10:08i took the rest of the
- 3:10:11and then he year back in the morning and
- 3:10:12showed his boss this awesome report he's
- 3:10:14like oh you're a god
- 3:10:16and that's kind of the point is i want
- 3:10:18to go home so i want to get this stuff
- 3:10:20done right
- 3:10:21and this is a primary way for you to
- 3:10:23figure out how things work so
- 3:10:25three ways we've done it so far get
- 3:10:27service to stop service we matched by
- 3:10:30value and that's how we're going to try
- 3:10:31at the very beginning
- 3:10:33when the nouns don't match by value
- 3:10:35probably isn't going to happen not
- 3:10:37always but probably is not going to
- 3:10:38happen and we did get service
- 3:10:40stop process where we had to start to
- 3:10:42match by property name which means
- 3:10:44the name of the the the the the property
- 3:10:48coming across
- 3:10:49has to match the name of the parameter
- 3:10:51of the receiving commandlet
- 3:10:53but whenever you do that that's where
- 3:10:55what if is your friend
- 3:10:56oh yeah that is where what f is
- 3:10:58definitely your friend
- 3:11:00the third way is well
- 3:11:03there's a parameter that supports
- 3:11:05pipeline input and you want to use that
- 3:11:07parameter but what
- 3:11:08the property you're sending it doesn't
- 3:11:09have the right name so you can change it
- 3:11:12in flight using this syntax
- 3:11:15here's the fourth and final and believe
- 3:11:18me then we're ready for a break here in
- 3:11:20just a second so
- 3:11:22so get 80 computer i want you to
- 3:11:26understand my business problem
- 3:11:27first of all to show you there's a
- 3:11:29commitment we're not going to get a lot
- 3:11:30of time today to spend with this
- 3:11:32with the concept of wmi but wmi is one
- 3:11:35of the greatest things wmi and similar
- 3:11:36one of the greatest things in the world
- 3:11:37i'm hoping that a little bit later on
- 3:11:38jeffrey will be able to have a chance to
- 3:11:40talk about it
- 3:11:42but i just want to show you wmi is great
- 3:11:44for grabbing all kinds of wonderful
- 3:11:45information
- 3:11:47here's an example of wmi grabbing just
- 3:11:49some bios information
- 3:11:50i also want to point out that this
- 3:11:52commandlet supports
- 3:11:53computer name which means i could get it
- 3:11:55from multiple computers
- 3:11:57now if i could spell them correctly
- 3:12:00so understand that this could be really
- 3:12:02useful to me i might want to do a whole
- 3:12:04hardware inventory
- 3:12:05but i'm not going to want to sit here
- 3:12:07and hand type in a bunch of computer
- 3:12:09names instead i'm going to want to
- 3:12:11pipe a bunch of computer names from
- 3:12:12active directory so what i'm doing is
- 3:12:14i'm going to say get ad computer
- 3:12:17filter star
- 3:12:19[Music]
- 3:12:21pipe to get wmi object
- 3:12:24and i want the class for bios
- 3:12:28well here's the thing you can spend the
- 3:12:31next
- 3:12:32two days trying to get this to work
- 3:12:38ain't gonna happen if you know how to
- 3:12:39work this process that we're showing you
- 3:12:41right here
- 3:12:42here's what you would do and you're
- 3:12:44gonna solve this problem in seconds
- 3:12:46rather than days first of all you're
- 3:12:48going to pipe to gm to see what the
- 3:12:49object type is because we want to check
- 3:12:51for by value and i'm just going to tell
- 3:12:52you right now my value is not going to
- 3:12:54work
- 3:12:54i got ad computer but by value is not
- 3:12:57going to work you know how i know that
- 3:12:58because the next thing we do is we go
- 3:13:00look at parameters that support
- 3:13:02pipeline input well let's do that get
- 3:13:05help
- 3:13:06uh get wmi object
- 3:13:10dash full
- 3:13:13and guys i i know we could do this uh
- 3:13:15with the uh the show window but i just
- 3:13:17want you to see the beauty of this
- 3:13:19watch as it scrolls by when i get to the
- 3:13:21parameters
- 3:13:24throttle limit no recurse
- 3:13:28no query no property no
- 3:13:32name space no locale yeah denied
- 3:13:36um list no uh impersonation fun on a
- 3:13:40friday night but no
- 3:13:41it's um filter no every computer says
- 3:13:45no every parameter says
- 3:13:49no no pipeline input
- 3:13:52it will not take any pipeline input stop
- 3:13:55trying
- 3:13:56it won't take any pipeline input so i
- 3:13:57see guys all the time that go
- 3:14:00okay well then you can't do it it's
- 3:14:02broke they need to fix that with
- 3:14:03powershell
- 3:14:04well no you can do it you just have to
- 3:14:07know how
- 3:14:08let me show you you know i was showing
- 3:14:10you that
- 3:14:11how this commandlet get help and i'm
- 3:14:14going to do the short help for it
- 3:14:16this guy supports dash computer name
- 3:14:19well here i want you to take notice here
- 3:14:20let's look at dash computer name see
- 3:14:22dash computer name
- 3:14:23and what he wants is a bunch of strings
- 3:14:26that's what he wants
- 3:14:27as an object strings he'll take dash
- 3:14:30computer name i just have to figure out
- 3:14:31how to get it
- 3:14:32in there get those computer names in
- 3:14:34there so
- 3:14:35here's what i'd like to do get wmi
- 3:14:39object whatever class i want
- 3:14:44and i would like to do dash computer
- 3:14:47name and
- 3:14:48get the computer names in there i'd like
- 3:14:49to do like get ad computer
- 3:14:52filter star well you can't do that
- 3:14:55because it
- 3:14:55screws up the argument so you have to
- 3:14:57put them in parentheses because remember
- 3:14:59what parentheses means i wasn't a big
- 3:15:01math fan
- 3:15:02but they those things are like order of
- 3:15:04operands or
- 3:15:06you're a smart guy you know all that
- 3:15:07stuff it's it's it means
- 3:15:09do this first before we do anything else
- 3:15:12so what's going to happen is
- 3:15:13what's ever in those parens is
- 3:15:15parenthetical it's going to do that
- 3:15:17first
- 3:15:18and that becomes the argument on this
- 3:15:20dash computer name
- 3:15:21but there's a small problem remember
- 3:15:23dash computer name wants
- 3:15:25a bunch of string objects i wonder what
- 3:15:28this is providing me as a matter of fact
- 3:15:30let me show you get
- 3:15:32ad computer and you know how to do this
- 3:15:33now filter star
- 3:15:35what kind of object is this producing
- 3:15:37pipe it to gm
- 3:15:39it's giving me ad computer
- 3:15:42that doesn't say string watch
- 3:15:45also it's giving me way too much
- 3:15:48information
- 3:15:50this is giving me all kinds of stuff i
- 3:15:52don't want i just want name i just want
- 3:15:54to select
- 3:15:55i just want to select name so get ad
- 3:16:00computer
- 3:16:03filter star select the property
- 3:16:07name awesome i've got the names this is
- 3:16:10what i want to throw into dash computer
- 3:16:12but
- 3:16:13before we try this check it with get
- 3:16:16member
- 3:16:17look at what the object type is 80
- 3:16:20computer
- 3:16:20it doesn't say string here
- 3:16:24so it's going to break well they thought
- 3:16:26of this they solved this what i really
- 3:16:28want
- 3:16:29is i want to
- 3:16:32extract those names and put them in that
- 3:16:35dash computer name argument in between
- 3:16:37the two of
- 3:16:38us i want to extract or extract
- 3:16:41extract isn't the right word i want to
- 3:16:45expand this property now we can only
- 3:16:48expand one
- 3:16:49but look at the difference on my screen
- 3:16:51how this looks
- 3:16:53see how you don't have this anymore
- 3:16:56it's just the names of the computers
- 3:17:00let's pipe it to get member
- 3:17:05lookie string
- 3:17:08string happy happy happy happy so
- 3:17:12what we do is we and i'm going to try to
- 3:17:14do this i'm going to try to right click
- 3:17:16on this
- 3:17:18and here's what we're going to do right
- 3:17:21yeah right click i i think i did that
- 3:17:22right so
- 3:17:24get wmi object whatever class i wanted
- 3:17:28win32 underscore bios
- 3:17:30dash computer name and here's what i
- 3:17:32want to put inside of the parentheses
- 3:17:34that whole thing now you might be saying
- 3:17:38gee whiz
- 3:17:38that's an awful lot of work but as soon
- 3:17:40as you do this like two or three times
- 3:17:42it's not a lot of work because now what
- 3:17:45you couldn't solve
- 3:17:46before or you were spending days banging
- 3:17:48your head on
- 3:17:50now just works and it just works because
- 3:17:53we couldn't pipeline to this commandlet
- 3:17:55darn okay forget about it that's fine
- 3:17:58what do you want to use i want to use
- 3:18:00dash computer name what does it want it
- 3:18:01wants a string so i want to grab all the
- 3:18:03aed computers i just want the property
- 3:18:05name
- 3:18:06i don't want all the other properties i
- 3:18:07just want name send it to get
- 3:18:09member it's not a string oh i need to
- 3:18:11expand that
- 3:18:13think extract that those values out
- 3:18:17and i get the string now it's going to
- 3:18:19work
- 3:18:20this is your last line of resort now
- 3:18:23don't use this as your first line of
- 3:18:24resort
- 3:18:25that's not the point because you want
- 3:18:26the power of the pipeline
- 3:18:28so don't do this first do this last and
- 3:18:32let me show you and we're going to let
- 3:18:33jeffrey talk about this for a second is
- 3:18:34that
- 3:18:35before we take a break let me show you
- 3:18:37what i found out microsoft's kind of
- 3:18:39doing to help us out
- 3:18:41you know how the the get wmi thing
- 3:18:45it doesn't take any pipeline input well
- 3:18:48i happen to know that there's wait
- 3:18:50before you go there okay
- 3:18:52up arrow up arrow because this works
- 3:18:55perfectly this works perfectly
- 3:18:57but this works in powershell version two
- 3:19:00powershell version three we made it
- 3:19:02simpler
- 3:19:04oh let's make it simpler hit delete
- 3:19:07uh delete the select
- 3:19:11oh no no all the way from the end of the
- 3:19:13line to the slide away from the other
- 3:19:15one
- 3:19:16get rid of that get rid of all that yeah
- 3:19:19more
- 3:19:19more line okay now in paren
- 3:19:22and parentheses that's again prin
- 3:19:27oh end parent yeah okay space oh i see
- 3:19:30what you're doing oh
- 3:19:33[Music]
- 3:19:36basically is shorthand uh
- 3:19:40syntax to do that selects which is what
- 3:19:42you were showing earlier with
- 3:19:44casting to xml and guys one of the
- 3:19:46things is we're going to start showing
- 3:19:48you as we get close to scripting
- 3:19:49we're going to be showing you working
- 3:19:50with variables and using this dot syntax
- 3:19:53this dot
- 3:19:54syntax so you get more and more
- 3:19:56comfortable with it because now
- 3:19:58that was a lot easier to type as soon as
- 3:20:00you know more about that dot syntax so
- 3:20:02this is
- 3:20:03awesome see it still worked and as
- 3:20:06i just showed oh let me show you again
- 3:20:08because i don't think the thing was on
- 3:20:10there let me show you
- 3:20:11that oh what's going on is this hard for
- 3:20:13you
- 3:20:17i could go over there well no it's it's
- 3:20:20it's it's
- 3:20:21something has gone awry and i think my
- 3:20:24ah there we go something computer we
- 3:20:26were waiting on so
- 3:20:28this syntax if you can see it is it
- 3:20:29works the exact same way um so i can
- 3:20:32execute it but i don't want to do it
- 3:20:33again because
- 3:20:34it was holding up on one of the machines
- 3:20:35oh was it one last thing to show you and
- 3:20:37then we'll take a break
- 3:20:39is get wmi object doesn't support any
- 3:20:42input but
- 3:20:43there's an if you're working with wmi
- 3:20:45there's a whole new way of doing this
- 3:20:48and if you were to do get help on
- 3:20:50something called
- 3:20:51get sem instance and you were to take a
- 3:20:55look at the parameters and what they
- 3:20:57what parameters accepted pipeline input
- 3:20:59you would see that
- 3:21:00this is now the replacement for
- 3:21:04this because the new one
- 3:21:07now supports pipeline input in the
- 3:21:09places where you want it to support
- 3:21:10pipeline input so
- 3:21:13the idea is that going forward some of
- 3:21:15the commands that you may run across
- 3:21:16especially if they're four or five years
- 3:21:18old that didn't support pipeline input
- 3:21:20may start to support it but if it
- 3:21:22doesn't you do have this last
- 3:21:24line of resort now as a final note
- 3:21:27make sure this is so very important well
- 3:21:29you got
- 3:21:30i was going to show them one more thing
- 3:21:31oh go ahead show them one more thing i'm
- 3:21:33going to take over your machine
- 3:21:34okay it's all yours man okay just did
- 3:21:36that work yeah right of course
- 3:21:38okay here we go where are you
- 3:21:41okay i'm taking over his machine he's
- 3:21:42gonna take over my machine while he's
- 3:21:44taking it over
- 3:21:45get don jones's book uh learn windows
- 3:21:49powershell in a month of lunches
- 3:21:51chapter nine you've got to know that
- 3:21:53that's the most important thing that's
- 3:21:54what we just did in here
- 3:21:57okay so now i'm gonna show you something
- 3:22:00crazy freaky
- 3:22:01freaky freaky freaky powerful oh let's
- 3:22:03get freaky yeah we're gonna get freaky
- 3:22:05freaking
- 3:22:06okay sorry
- 3:22:10okay so so now this is this is pretty
- 3:22:12advanced stuff
- 3:22:13um but why not end
- 3:22:16on something really powerful okay and
- 3:22:19this is something
- 3:22:20called um what do we call these we call
- 3:22:22these script parameters
- 3:22:24i think it's the term form so now what
- 3:22:26we're going to do is remember the
- 3:22:28original problem was
- 3:22:29get ad computer must filter
- 3:22:34star pipe to get wmi object
- 3:22:39win32 bios and it was this computer name
- 3:22:43that we couldn't get a value for right
- 3:22:45darn
- 3:22:46okay so here's the deal
- 3:22:49script block whenever you see the what
- 3:22:51do you call them the the squigglies
- 3:22:53squigglies
- 3:22:54i like to see my hips myself but for
- 3:22:56those who see the squigglies
- 3:22:57that's called a script block that
- 3:22:59represents code
- 3:23:01if you give a script block
- 3:23:04to a property to a parameter which
- 3:23:07doesn't take a script block
- 3:23:09then what it is is oh that you must be
- 3:23:12asking for a
- 3:23:13script parameter and what it does
- 3:23:16is it takes the value of the current
- 3:23:19object
- 3:23:20assigns it to dollar sign under bar and
- 3:23:23runs the script
- 3:23:24and takes the value and puts it in there
- 3:23:27oh this could be totally awesome and so
- 3:23:29what you do is you say
- 3:23:30dollar sign under bar dot was it was it
- 3:23:32name it was name
- 3:23:33name okay by the way you can do anything
- 3:23:35you want here you could say two upper
- 3:23:37or you know anything but here we just do
- 3:23:40this
- 3:23:40so again what's gonna happen is you're
- 3:23:42going to run this
- 3:23:44you're going to take the current object
- 3:23:46you're going to assign it to
- 3:23:47this and then you're going to run this
- 3:23:50code
- 3:23:50and so each object you're going to get
- 3:23:52the value of the name
- 3:23:54and then you're going to run this with
- 3:23:57the value
- 3:23:58was that crazy powerful you know you
- 3:24:00realize that you've made that so much
- 3:24:02easier that
- 3:24:03there everybody's going to like you
- 3:24:04better than they like me now because i
- 3:24:06i drug them through this plan okay well
- 3:24:09it worked because i took them through
- 3:24:10that long thing
- 3:24:11and then you just made it really short
- 3:24:13and sweet so congratulations very nice
- 3:24:15there you go so have fun with that so
- 3:24:19folks
- 3:24:19we're going to go ahead and take a 10
- 3:24:20minute break when we come back we can
- 3:24:22get some coffee
- 3:24:23yeah oh yeah yeah give me some coffee
- 3:24:24because i need more and um
- 3:24:26we're going to go into something that is
- 3:24:28going to change the way you manage
- 3:24:30now you're going to take the tools that
- 3:24:31you started to learn today and we're
- 3:24:33going to get into
- 3:24:34one of the most powerful things in the
- 3:24:35world remoting and we want to talk to
- 3:24:38jeffrey about remoting before we get
- 3:24:39into it this is
- 3:24:40totally awesome stuff so see you guys in
- 3:24:4210 minutes
- 3:25:00[Music]
- 3:25:09we're back and i have to tell you we're
- 3:25:11here to talk and this
- 3:25:12now we're going to talk about one of my
- 3:25:13most favorite things and you get to talk
- 3:25:16about it
- 3:25:17and we're going to do this twice guys
- 3:25:18we're going to do kind of a short
- 3:25:20section of this to get you started then
- 3:25:21we're going to get into scripting
- 3:25:23teach you about variables and stuff and
- 3:25:24then hit remoting this topic
- 3:25:27again with something called sessions
- 3:25:29that'll be outstanding but
- 3:25:31remoting this changed how i manage
- 3:25:35in scale when it comes to the entire
- 3:25:37windows uh
- 3:25:38all the products the platform everything
- 3:25:41this when it released with version two
- 3:25:43literally made me a hero overnight so
- 3:25:45you have to tell us about
- 3:25:47what were you trying to solve with this
- 3:25:49what does this thing do this is
- 3:25:51unbelievable stuff yeah so in in
- 3:25:53powershell we have this idea we called
- 3:25:55it
- 3:25:55we talked a lot about in the past we
- 3:25:56don't talk so much about it now because
- 3:25:58because we already delivered it
- 3:26:00this notion of universal code execution
- 3:26:02right which is to say that you have
- 3:26:04code and sometimes you want to run the
- 3:26:06code here
- 3:26:07yeah that's what we do everything we've
- 3:26:09been showing you today
- 3:26:10we bring up a console window and we type
- 3:26:13the code
- 3:26:14and the code runs here but actually it's
- 3:26:17a generalization
- 3:26:18like here is a generalization or a
- 3:26:20specialization of
- 3:26:22anywhere like sometimes i want to run
- 3:26:23the code there and sometimes i want to
- 3:26:25run the code
- 3:26:26there and sometimes i want to run the
- 3:26:28code on those machines
- 3:26:31and sometimes i want to run the code on
- 3:26:32those machines as
- 3:26:34myself and sometimes i want to give a
- 3:26:36different set of credentials
- 3:26:38and sometimes i want to run it and get
- 3:26:40the results back immediately
- 3:26:41and sometimes i want to run it and i'll
- 3:26:43get the results back later
- 3:26:45and sometimes i want to run it in a way
- 3:26:46that uh um
- 3:26:48i can do anything and sometimes i want
- 3:26:50to run in an environment where
- 3:26:52no no no these are and only these
- 3:26:54commands you can run
- 3:26:55secure environments and so there's this
- 3:26:57notion of this
- 3:26:58universal code execution model oh by the
- 3:27:01way sorry the last one was
- 3:27:02sometimes i want to run it i'm going to
- 3:27:04run it for such a long time
- 3:27:06that i might want to like shut down the
- 3:27:07machine and bring it back up and have it
- 3:27:10continue to run
- 3:27:11right go somewhere else and maybe check
- 3:27:13on it or something exactly
- 3:27:14so this is the notion of the universal
- 3:27:17uh
- 3:27:18code execution model and remoting of
- 3:27:20course is intrinsic to that
- 3:27:22coupled with that are notions like jobs
- 3:27:25jobs are things that run in the
- 3:27:27background and then workflow which we
- 3:27:29added in powershell version three which
- 3:27:30is the idea that says hey i'm going to
- 3:27:32run this
- 3:27:33and at any stage after any command i can
- 3:27:35suspend things
- 3:27:37shut down the machine bring it back up
- 3:27:40and continue
- 3:27:41from where i started now see this sounds
- 3:27:43awesome now what we had before is like
- 3:27:45um
- 3:27:45with like the remote server
- 3:27:47administration tools i have a graphical
- 3:27:48like active directory users and
- 3:27:50computers
- 3:27:50it will connect to a domain controller
- 3:27:52over dcom using rpc
- 3:27:54right and there's there's a lot of
- 3:27:56challenges and problems with that
- 3:27:57firewall challenges right
- 3:27:59and all kinds of a mess but what you may
- 3:28:02which
- 3:28:02what you guys created though solves all
- 3:28:05those
- 3:28:06all those problems exactly so here's
- 3:28:07what we did was first was we wanted to
- 3:28:09solve all those problems so http
- 3:28:11super important next was we already had
- 3:28:14a pro protocol that went over http
- 3:28:16our standards-based management so you
- 3:28:18probably heard we talk a lot these days
- 3:28:20about standards-based management
- 3:28:22in fact you know what at tech heads and
- 3:28:24such i'll show up i'll i'll bring up a
- 3:28:26linux box
- 3:28:27and i'll show how on a linux box i can
- 3:28:29enumerate all the roles on a remote
- 3:28:31windows server
- 3:28:32and then install roles on a remote
- 3:28:35windows server from a linux box i mean
- 3:28:37just
- 3:28:38crazy stuff right yeah i saw you do that
- 3:28:41demonstration for the first time i think
- 3:28:42it was like a year and a half ago and i
- 3:28:43just went
- 3:28:45just explode so this is because of this
- 3:28:48standards and uh and when rm
- 3:28:50the winram or ws management protocol
- 3:28:52winner is our implementation of that
- 3:28:54and so for powershell remote we leverage
- 3:28:56winram
- 3:28:58and we added streaming extensions to it
- 3:29:01so that's how it works and when rm is
- 3:29:03the service that you're going to see
- 3:29:04that's that's running underneath all
- 3:29:05that as a matter of fact i got a a
- 3:29:07couple of slides
- 3:29:08uh here and then we'll talk some more
- 3:29:10about this if you take a look at the
- 3:29:12slide here as an overview of remoting
- 3:29:13basically what this comes down to
- 3:29:15is you can go and touch
- 3:29:18just as jeffrey went through the
- 3:29:20scenarios using what you've already been
- 3:29:22typing in at the console
- 3:29:24locally you can pick that up and now
- 3:29:26fire that
- 3:29:27at whatever it is you want to fire it at
- 3:29:29and it's over remoting which is going to
- 3:29:31give us a lot of cool characteristics
- 3:29:33it's going to be fast it's going to be
- 3:29:35easy to cross
- 3:29:36firewalls because we only have one port
- 3:29:37to deal with and we're dealing with a
- 3:29:39secured port so here's the idea if your
- 3:29:41machines are in a domain
- 3:29:43this isn't going over just http plain
- 3:29:45text it's getting all encrypted
- 3:29:47all encrypted with kerberos and then of
- 3:29:49course if you're going across
- 3:29:51the internet or across firewalls and you
- 3:29:53want to put on ssl or if
- 3:29:54you even want to do ssl internally you
- 3:29:57can put on ssl you want that full
- 3:30:00encrypted tunnel so well just be clear
- 3:30:01we'll encrypt it twice we'll encrypt it
- 3:30:03twice at that point yeah
- 3:30:05if you really need it twice the
- 3:30:06encrypted we'll do it twice um
- 3:30:08but here's the idea is that you're
- 3:30:10hitting whatever machines you want
- 3:30:13securely and with what credentials you
- 3:30:15want
- 3:30:16and nobody can tell i mean nobody can
- 3:30:18read it nobody can use a protocol
- 3:30:20sniffer and sniff out what's going on so
- 3:30:22this is actually
- 3:30:23really cool stuff so you know there's
- 3:30:25there's
- 3:30:26enabling remoting is definitely
- 3:30:30one of these things that that comes up
- 3:30:31first of all we we just you know we just
- 3:30:33need to tell everybody that
- 3:30:35that you have to turn remoting on kind
- 3:30:37of sort of maybe
- 3:30:39kind of sort of maybe because um in
- 3:30:42prior versions
- 3:30:43not server 2012 but in prior versions
- 3:30:45remoting had to be turned on and this
- 3:30:46can actually be
- 3:30:48kind of a hard conversation for some
- 3:30:49security people to have or
- 3:30:51some admins to have with their security
- 3:30:52people in
- 3:30:54in that i'm going to turn on this really
- 3:30:55cool thing that lets me do whatever i
- 3:30:57want to whatever i want the security guy
- 3:30:59goes
- 3:30:59no which is exactly what they should say
- 3:31:02but as soon as they understand remoting
- 3:31:05and how it works
- 3:31:06all of a sudden it's like oh well this
- 3:31:07is yeah this is perfectly fine yes
- 3:31:09so there's this conversation that has to
- 3:31:11have to get it turned on
- 3:31:13if you guys take a look at the the slide
- 3:31:15here
- 3:31:16what i've done is i've shown you a basic
- 3:31:18way to turn it on i'm actually going to
- 3:31:20demonstrate this on one of my machines
- 3:31:22here
- 3:31:22but there's a commandlet that you can
- 3:31:24you can turn that you can use called
- 3:31:25enable dash ps remoting
- 3:31:28and now you can you want to walk around
- 3:31:30to all of your servers and type enable
- 3:31:32ps remoting
- 3:31:33knock yourself out but there's a group
- 3:31:36policy and i have it written down here
- 3:31:37for you
- 3:31:38it's much easier if you use the group
- 3:31:40policy to enable remoting
- 3:31:42but here's the deal you have to turn
- 3:31:45this on let me say it again
- 3:31:49you have to turn this on
- 3:31:53i'm we're going to show you all these
- 3:31:54great features but none of it's going to
- 3:31:56work until you turn on remoting
- 3:31:58it's not necessarily an easy
- 3:31:59conversation there's a free ebook
- 3:32:01on powershell.org secrets about remoting
- 3:32:04yeah great book which will take give you
- 3:32:07not only take you through every possible
- 3:32:08scenario
- 3:32:09but will is the information that your
- 3:32:11security guys need to know
- 3:32:13so that they understand that it's
- 3:32:14secured and what ports it uses
- 3:32:18this has to be turned on it's not
- 3:32:20because i'm just saying it it's because
- 3:32:21you're running out of options now
- 3:32:23a lot of the new administrative
- 3:32:25graphical tools are made
- 3:32:27to use powershell and powershell
- 3:32:29remoting server 2012 is a great example
- 3:32:32of the new server manager right it's
- 3:32:33using
- 3:32:34all of these capabilities that are built
- 3:32:36in and if you don't have it turned on
- 3:32:38you can't manage anything with anything
- 3:32:41so you've got to get it turned on and as
- 3:32:43a side note
- 3:32:44server 2012 it's turned on by default
- 3:32:48oh yeah so it's gonna get turned on just
- 3:32:51to be clear on that one
- 3:32:52so as you know uh uh we are secure by
- 3:32:55default and released by release
- 3:32:57we continue to shut things off by
- 3:32:59default and
- 3:33:00you have to turn them on uh in the
- 3:33:02course this has been going on for quite
- 3:33:04a number of years
- 3:33:05been exactly to my knowledge one time
- 3:33:08where we went the other direction
- 3:33:09where we turned something on by default
- 3:33:11instead of off by default
- 3:33:13and that was uh power it's got to be
- 3:33:15powershell remote
- 3:33:16shell remoting that's right so for
- 3:33:17windows server 2012 we turned on
- 3:33:20powershell remoting
- 3:33:21it was a big issue the security security
- 3:33:23guys are like
- 3:33:24what are you talking about maybe you
- 3:33:26didn't get the memo we're going the
- 3:33:27other direction
- 3:33:28it's like okay well let's talk about
- 3:33:30that why is that and the answer is of
- 3:33:32course windows server 2012
- 3:33:34right it is a cloud operating system a
- 3:33:36cloud operating system says hey it's not
- 3:33:38about this server it's about
- 3:33:40these servers i need to be able to
- 3:33:42manage things and therefore remoting of
- 3:33:44large numbers of systems is critical
- 3:33:46function it is the core
- 3:33:47of a cloud os and so they said okay well
- 3:33:50i'm willing to entertain that i mean
- 3:33:52that makes sense
- 3:33:53but we got to be sure and say okay well
- 3:33:54let's walk through it and we showed them
- 3:33:56all the things that we had done
- 3:33:57actually they've been involved all along
- 3:33:59uh and step by step by step we went and
- 3:34:01did the threat analysis and they were
- 3:34:02convinced yeah
- 3:34:03this is safe to do and so when you have
- 3:34:06that conversation with your security
- 3:34:07guys
- 3:34:08you just point to that and the history
- 3:34:10of this environment this
- 3:34:12server one time we switch and turn
- 3:34:14things on by default it is
- 3:34:16powershell remoting so go for it yeah
- 3:34:19and i think that's a really great
- 3:34:20concept because microsoft's not going to
- 3:34:21turn on something
- 3:34:22that is a an easy to use attack surface
- 3:34:25it's just not going to happen so we put
- 3:34:27an extraordinary amount into the
- 3:34:29security of making sure that this is
- 3:34:31going to be secure environment
- 3:34:32we've got pen testers who've been
- 3:34:34evaluating the design
- 3:34:36the code etc we spent a lot
- 3:34:39look we started powershell after bill
- 3:34:42gates
- 3:34:43his famous um security memo yeah
- 3:34:46right so and and what started that
- 3:34:48security member what started that whole
- 3:34:50bufferama
- 3:34:51i love you i love you man.vbs oh you're
- 3:34:54talking about that i was just saying i
- 3:34:56love you man i'm
- 3:34:57sorry oh that's special okay okay
- 3:35:00there's anything wrong with that no it
- 3:35:03was
- 3:35:03it was scripting scripting had caused
- 3:35:05that big i love you
- 3:35:06mass and so we knew that scripting was
- 3:35:09going to be a key
- 3:35:10vector so we just spent a ton of time
- 3:35:13making sure we were secure secure secure
- 3:35:16so now that we've jumped up and down
- 3:35:18enough that you not only have to turn
- 3:35:20this on but it's secured to have it
- 3:35:21turned on
- 3:35:22get it turned on let's start to show you
- 3:35:24some of the cool things that you can do
- 3:35:25now like i said we're going to hit this
- 3:35:26topic twice
- 3:35:27as we learn more and more about it so we
- 3:35:29this is all in the slides but
- 3:35:31um let me take you through here and as
- 3:35:33soon as i can
- 3:35:35there we go
- 3:35:38well maybe not quite i can do something
- 3:35:42i think you have control of my machine
- 3:35:44no i keep it up
- 3:35:46okay my machine is just moving slow for
- 3:35:48a second i don't oh here we go okay
- 3:35:50so let me do something real quick and
- 3:35:52jeffrey please jump in
- 3:35:53first of all i'm going to do what's
- 3:35:54called a one-to-one connection this is
- 3:35:56in
- 3:35:56you'll see exactly watch i'm going to
- 3:35:58type in enter it's a commandment
- 3:36:00ps session powershell session and i'm
- 3:36:03going to put in a computer name that i
- 3:36:05want to go to
- 3:36:06i'm just going to say dc it's one of the
- 3:36:07vms that i have running
- 3:36:09watch what happens to my prompt here you
- 3:36:12see what happened
- 3:36:14guess guess where i'm sitting right now
- 3:36:17guess
- 3:36:18where i am right now i'm on the dc
- 3:36:22i'm on the dc you don't believe me watch
- 3:36:25i i'm going to clean up this path a
- 3:36:27little bit
- 3:36:28watch host name
- 3:36:32and i'll do ipconfig that information is
- 3:36:35coming from the dc
- 3:36:37so i can actually do a one-to-one
- 3:36:39connection and i can troubleshoot and i
- 3:36:40can manage
- 3:36:42a single system this way as if i was
- 3:36:44sitting on there as a matter of fact
- 3:36:46think of this as a secure telnet a
- 3:36:48secured telnet i love that and
- 3:36:50and here's let me show you why i think
- 3:36:52that this is also so important
- 3:36:54that you just get used to managing
- 3:36:56servers when you just need to do one
- 3:36:57thing to one server this is a great way
- 3:36:59to do it
- 3:37:00get used to this because i have you guys
- 3:37:02seen um server 2012 let me exit out of
- 3:37:05this and let me just show you
- 3:37:06um i'm going to go out to uh
- 3:37:10my domain controller and we're going to
- 3:37:11show you uh server 2012. um
- 3:37:14this is uh to me fascinating um
- 3:37:18welcome aboard there it is by the way
- 3:37:22what you guys did with the color scheme
- 3:37:23on here is awesome
- 3:37:25yeah the background the color scheme
- 3:37:27this is totally
- 3:37:28totally awesome like in its simplicity
- 3:37:30it's very zen like in its simplicity
- 3:37:32yep you guys probably figured out that
- 3:37:34this is definitely this is
- 3:37:36you know we used to call refer to this
- 3:37:38as the core installation and yeah with
- 3:37:40server 2012 this is now the
- 3:37:42default installation so and for a good
- 3:37:45reason
- 3:37:46performance security all that kind of
- 3:37:49stuff so
- 3:37:51let me show you you would be managing
- 3:37:53the server that way
- 3:37:54anyways and i don't want to screw this
- 3:37:56up so let me get rid of him
- 3:37:58there we go so doing that single session
- 3:38:02that enter ps session to a machine that
- 3:38:04you want to do work on it gives you that
- 3:38:06one-to-one connection and you can now do
- 3:38:08whatever you want on that machine
- 3:38:10but here's the big one and so let me
- 3:38:13exit this
- 3:38:15you guys been watching all day long and
- 3:38:16you know you're going to be doing a lot
- 3:38:18of good hard work on stuff like this i
- 3:38:19want to do get event log
- 3:38:21log name system
- 3:38:24and i'm just going to do newest three
- 3:38:27now i could do entry type
- 3:38:28and all this other stuff but i just want
- 3:38:30to keep it short and simple because
- 3:38:32let me just show you i'm going to take
- 3:38:33this and i'm going to copy this what i
- 3:38:35can get to work
- 3:38:36here and what jeffrey was saying is the
- 3:38:39whole point is
- 3:38:40we'll work anywhere so here's what i'm
- 3:38:42going to do
- 3:38:43i'm going to invoke
- 3:38:47command this is a remoting command
- 3:38:50what computers when you use this dash
- 3:38:53computer name
- 3:38:54it's using powershell remoting not the
- 3:38:56old dcom rpc stuff which is what a lot
- 3:38:59of the older commandlets use so this
- 3:39:00one's using the good stuff
- 3:39:02and then whatever you put in the
- 3:39:05squigglies is exactly what we're going
- 3:39:06to do
- 3:39:07oops sorry wait a minute put in some
- 3:39:10computer names and i'm going to be brave
- 3:39:12and risky whatever you put in the
- 3:39:15squigglies
- 3:39:16is exactly what we're going to do and in
- 3:39:18this case
- 3:39:20watch boom
- 3:39:23so over remoting we've was that was that
- 3:39:26was that approval back there that we
- 3:39:27heard a knock or something uh
- 3:39:30that i want you to get that what just
- 3:39:32happened is by using powershell remoting
- 3:39:34i just hit
- 3:39:35three different systems all at the same
- 3:39:37time and said give me this information i
- 3:39:39can now
- 3:39:40convert this i can put it to a file i
- 3:39:42can put it to a web page whatever it is
- 3:39:43i want to do with it
- 3:39:45but i just used powershell remoting and
- 3:39:47i and
- 3:39:48and and jeffrey this is actually so
- 3:39:50powerful that
- 3:39:51admins need to be a little careful right
- 3:39:53because things like
- 3:39:55um uh computer oh yeah that's a good one
- 3:39:58um
- 3:39:59restart computer all of a sudden take on
- 3:40:02a whole new dimension
- 3:40:04because whatever you fill that with
- 3:40:06that's what it's going to do
- 3:40:08dash computer name i can be grabbing the
- 3:40:09computers from active directory a csv
- 3:40:11file a text file making me nervous man i
- 3:40:14know at the moment i'm actually very
- 3:40:15nervous too i need to get rid of that so
- 3:40:17that's
- 3:40:17actually nice and so it's going to
- 3:40:20restart those machines
- 3:40:22so this is a one-to-many connection now
- 3:40:25jeffrey one of the
- 3:40:25things that comes up all the time is if
- 3:40:27i do get service i'll do name bits
- 3:40:30how's this working i mean it's it's
- 3:40:32actually sending the commands to the
- 3:40:34machine
- 3:40:34and then how am i getting this data back
- 3:40:36yeah so literally what happens is we go
- 3:40:38and we create a connection to that
- 3:40:40remote machine
- 3:40:41right so there's a tcp connection we
- 3:40:44then
- 3:40:45fire up a powershell connection we
- 3:40:48load.net we load powershell
- 3:40:50we take that code and we squirt it
- 3:40:53across the wire
- 3:40:54we then execute it you know we logged
- 3:40:56you in
- 3:40:57use your credentials to log you in we
- 3:40:59then execute the code there
- 3:41:01and then we get those objects and we
- 3:41:03serialize those objects
- 3:41:06we move them across the wire and then we
- 3:41:08reconstitute them we deserialize them
- 3:41:11and emit them as though they happen here
- 3:41:13okay okay so let me see if i get this
- 3:41:14straight because you're gonna have to
- 3:41:15explain the serialization
- 3:41:16yes let me see if i can get this
- 3:41:18straight so we're connecting to these
- 3:41:19remote
- 3:41:19machines and we're actually starting a
- 3:41:21power shell session
- 3:41:22on those machines and having the command
- 3:41:25run
- 3:41:26on those machines so it's not my
- 3:41:28computer working harder it's those
- 3:41:29machines that are doing the work
- 3:41:31yep now the serialization you're
- 3:41:33squirting this stuff back
- 3:41:34serializes serialize deserialize
- 3:41:38what does this mean exactly so what we
- 3:41:40do is we we take the object
- 3:41:42and we transform it into something that
- 3:41:45can be moved around
- 3:41:46and reconstructed anywhere okay okay so
- 3:41:49concretely i mean anywhere like i'm over
- 3:41:52here
- 3:41:53i go talk to your machine and it's
- 3:41:55windows talking.net
- 3:41:56and then i could bring it over here and
- 3:41:58it could be linux now there's no
- 3:42:00net on linux so how's that going to work
- 3:42:02right and so i've got to serialize it
- 3:42:04into something that can work
- 3:42:05anywhere now imagine i go and i say well
- 3:42:08hey i
- 3:42:08talk to exchange version whatever
- 3:42:12and i get the objects here but i don't
- 3:42:14have exchange here
- 3:42:16so how do i recreate exchange objects
- 3:42:18again that's the problem so what we do
- 3:42:20is we take these objects
- 3:42:22and we turn them into essentially a
- 3:42:23property bag you know just a bag
- 3:42:26of properties and then we take them and
- 3:42:28you know the properties have names
- 3:42:30and values and the values have types now
- 3:42:32here's the trick
- 3:42:34the types are not the infinite set of
- 3:42:36types
- 3:42:37there right if you tried to do that it
- 3:42:39would never work
- 3:42:40so what we do is we render it down to a
- 3:42:42set of i think 26 or so
- 3:42:44types which you know i put my badge on
- 3:42:46the table and i say if this
- 3:42:48i guarantee that these will always work
- 3:42:50if these don't work
- 3:42:51fire me well there you go forever
- 3:42:54forever because you know what
- 3:42:55um a uh an exchange
- 3:42:59uh mailbox 30 years from now probably
- 3:43:02going to change
- 3:43:03but i'll guarantee you this a 64-bit
- 3:43:05integer isn't going to change
- 3:43:0630 years from now yeah right so it's
- 3:43:08those type of things
- 3:43:10integers strings uh ins guides
- 3:43:13things like that are going to be yeah
- 3:43:16the same
- 3:43:17exactly so then i take that property bag
- 3:43:19and i just uh
- 3:43:20uh turn it into xml i then bring it over
- 3:43:23here and then i reconstruct the property
- 3:43:24back
- 3:43:25and so in fact here do do the by the way
- 3:43:28uh let me correct something
- 3:43:29show your screen okay okay so you said
- 3:43:32that this was
- 3:43:33remoting in fact invoke command is not
- 3:43:35remoting
- 3:43:36well what is it command is the way we do
- 3:43:39everything
- 3:43:40remember we have this kind of underlying
- 3:43:42system and then we've got
- 3:43:43we've got a great syntactic syntax
- 3:43:45syntax
- 3:43:46sugar on top of it so go remove the
- 3:43:48minus computer name
- 3:43:50so let's do this yeah well that whole dc
- 3:43:54one two three
- 3:43:55dc get rid of that
- 3:43:59okay and hit care to turn okay okay
- 3:44:02so that worked locally and that's the
- 3:44:04same as is if you hadn't typed
- 3:44:06invoke command and squiggle brackets or
- 3:44:08rather say when you just type get
- 3:44:10service minus name
- 3:44:11bits we transform it into this and then
- 3:44:14we run it
- 3:44:15and then we run it and that's that
- 3:44:17universe this is the universal code
- 3:44:19execution
- 3:44:20and this is this is what makes it so
- 3:44:22easy for especially if you're an
- 3:44:23administrator
- 3:44:24you work out what you want first
- 3:44:28then you can just put it in the
- 3:44:30squigglies and it's going to work at the
- 3:44:31other side
- 3:44:32exactly so from here pipe that to
- 3:44:34[Music]
- 3:44:36put that to get member okay and scroll
- 3:44:40up
- 3:44:42and what do we have we've got a service
- 3:44:45no look at the beginning
- 3:44:47system system dot service process that's
- 3:44:50service control
- 3:44:52now add a computer name to that line
- 3:44:55oh yeah so let's do this let's have it
- 3:44:58go to
- 3:44:59uh let's do uh dash comp and
- 3:45:02dc one okay this one yeah whatever
- 3:45:05now go on look at the beginning
- 3:45:09it's seriously serialized ding ding ding
- 3:45:11ding ding now
- 3:45:12a de-serialized object is incredibly
- 3:45:15powerful
- 3:45:16but it's different okay so if you scroll
- 3:45:18up a bit
- 3:45:20oh i'm scroll down did you did you just
- 3:45:22clear
- 3:45:23you didn't clear i did a clear okay
- 3:45:26don't do it clear and and do it again do
- 3:45:28the local command
- 3:45:32okay notice see these methods right okay
- 3:45:35see the start and the stop method top
- 3:45:37yeah okay
- 3:45:38that's because it's a live object and
- 3:45:41you can do methods on it
- 3:45:42go up to the deserialized one yeah it's
- 3:45:45it's it's there's there's just one
- 3:45:47method two strength or two strings
- 3:45:49exactly because the object itself is
- 3:45:51gone and what you have is a represent
- 3:45:54representation of the object now it
- 3:45:56turns out that that's
- 3:45:57extraordinarily powerful now some people
- 3:45:59say oh well it should be the same
- 3:46:00everywhere no
- 3:46:01no no my friends it shouldn't be the
- 3:46:03point is that because we have this
- 3:46:05this live deserialized
- 3:46:09concept what it means is that when i'm
- 3:46:11over there i'm able to take advantage of
- 3:46:13the
- 3:46:13remote i'm able to take advantage of the
- 3:46:16full richness of the object system
- 3:46:18be able to do everything in a very
- 3:46:20lightweight way
- 3:46:21very high performance low latency way
- 3:46:24and then
- 3:46:25when i bring it over here i can still do
- 3:46:27a ton of stuff but i can't do that so
- 3:46:28the way we refer to this is
- 3:46:32islands of optimization in a sea
- 3:46:35of interoperability okay let's islands
- 3:46:38of
- 3:46:38optimization in a sea of
- 3:46:41interoperability of interoperability
- 3:46:43which is to say
- 3:46:44it's it's it's poetic
- 3:46:45[Laughter]
- 3:46:47so what that means is i can go to any of
- 3:46:49the machines and i can interoperate i'm
- 3:46:50guaranteed to do that
- 3:46:52and then there are times however when
- 3:46:54i'm doing all the code on one machine
- 3:46:57that i can optimize i have the live
- 3:46:59objects i can do things etc
- 3:47:01and that by the way is what allows us to
- 3:47:02do the gui layering guise on top of
- 3:47:05powershell
- 3:47:06because we can have these nice high
- 3:47:09speed low latency
- 3:47:12activities if you tried to layer
- 3:47:14everything on top of a deserialized
- 3:47:16object
- 3:47:17you got a lot of recreating objects a
- 3:47:20lot of inefficiency
- 3:47:21right right yeah well guys this is our
- 3:47:24first hit into remoting so we did
- 3:47:27one-to-one
- 3:47:28we did one-to-many now we've got more
- 3:47:30remoting to do because
- 3:47:32we're just getting started with the
- 3:47:33remoting but now
- 3:47:35it's getting for that time for us to
- 3:47:38oh you know before we get into scripting
- 3:47:41i just oh no we gotta show more here
- 3:47:43no yeah i know there's a problem i have
- 3:47:46yeah
- 3:47:46this is cool but you know one of the
- 3:47:49problems i have
- 3:47:50i know a few of the problems
- 3:47:54one of the one of the things i run into
- 3:47:56is
- 3:47:58wouldn't it be cool if you know when i
- 3:48:01go on vacation i don't know about you
- 3:48:03but i like to go places with beaches
- 3:48:04oh yeah that have they have the the the
- 3:48:07little drinks with the little umbrellas
- 3:48:09in them
- 3:48:09and when i'm sitting on the beach the
- 3:48:11last thing that i'm gonna have is a
- 3:48:13laptop
- 3:48:14yeah right that's something not not cool
- 3:48:16not cool at all
- 3:48:17but things still do go wrong back at the
- 3:48:20office and so
- 3:48:21i am going to have a phone yep
- 3:48:25ah i see where you're going wouldn't it
- 3:48:29be
- 3:48:29you know it'd be so cool if i could
- 3:48:33maybe have powershell here
- 3:48:37and i could launch a script which we're
- 3:48:40going to be doing this afternoon or i
- 3:48:41could
- 3:48:42type in these commands and i could do
- 3:48:43all of this
- 3:48:45kind of cool stuff it would be so cool
- 3:48:48if i had powershell here or on a tablet
- 3:48:50if if only if only you had powershell
- 3:48:53version 3.
- 3:48:54if only you had powershell version three
- 3:48:56and
- 3:48:57at least one server 2012 box yeah it
- 3:49:00could be a vm
- 3:49:01but i want to show you something kind of
- 3:49:02cool have you picked up on the fact that
- 3:49:04we're big fans of powershell version
- 3:49:05three
- 3:49:06yeah we're huge fans of powershell v3 so
- 3:49:09guys i want you to watch something i'm
- 3:49:10actually going to take you through this
- 3:49:11is kind of a cute review not a cute
- 3:49:13review i can't believe i said the word
- 3:49:14cute this is a review
- 3:49:15over what we started off with today
- 3:49:18discovering
- 3:49:19and utilizing commandlets and in this
- 3:49:21case
- 3:49:22using a feature that i think is just
- 3:49:23wickedly awesome so here's what i'm
- 3:49:25going to do
- 3:49:26i'm going to use powershell remote or
- 3:49:28i'm going to enter a ps session to
- 3:49:30a server i have out there called pwa now
- 3:49:32this server
- 3:49:33doesn't really have anything on it it's
- 3:49:34just a generic server 2012
- 3:49:37box key is 2012. it could be a vm
- 3:49:40somewhere but it's
- 3:49:41got to be 2012. what i'm going to do is
- 3:49:44there's commandlet out there called get
- 3:49:46windows feature
- 3:49:48get windows feature is part of the
- 3:49:49server manager module
- 3:49:51what it does is it lists for you all of
- 3:49:54your roles and features for your server
- 3:49:56and if there are x's in it i know i love
- 3:49:58it when
- 3:49:59if there's an x that means it's
- 3:50:01installed if there's not an x
- 3:50:03it's not installed well i'm going to use
- 3:50:05this commandlet to
- 3:50:06see if there's a feature
- 3:50:10what features are available for
- 3:50:12powershell and in server 2012 we have
- 3:50:15something down here at the bottom called
- 3:50:17powershell web access i'm about to
- 3:50:19change
- 3:50:22the world as well and it's not me who
- 3:50:24i'm
- 3:50:25the only thing that i'm changing is i'm
- 3:50:26showing you how to set it up
- 3:50:28you're the one that changed the world so
- 3:50:30the team the team the team
- 3:50:31so yeah the team the team um so it's
- 3:50:34called windows powershell web access
- 3:50:36and this is pretty cool so i want to
- 3:50:38install this
- 3:50:39so we have this install windows feature
- 3:50:42commandlet that'll let me install
- 3:50:43windows powershell web
- 3:50:47access i've used git help i can
- 3:50:50the install windows feature will let me
- 3:50:52choose whatever thing i want to install
- 3:50:53and away it goes now here's what it's
- 3:50:55going to do
- 3:50:56[Music]
- 3:50:58it's going to install iis because this
- 3:51:02is going to be a web
- 3:51:03thing so it's going to install iis we
- 3:51:05have net 45 on here and its server 2012.
- 3:51:10when it gets this installed we'll also
- 3:51:12get a new module
- 3:51:13with some additional commands six
- 3:51:16additional command lines so what we're
- 3:51:17gonna do is use get help to find them
- 3:51:19and then use them because in like three
- 3:51:22steps i'm gonna have one of these
- 3:51:23coolest features in the world turned on
- 3:51:25so watch i'm gonna clear my screen this
- 3:51:27is just let me know they have my updates
- 3:51:29turned off which
- 3:51:30it's a vm right now it does but it was
- 3:51:31it exited with success
- 3:51:33no restart needed awesome so
- 3:51:36clear my screen and guys notice i'm
- 3:51:38doing this all on a different server
- 3:51:39right so
- 3:51:40how cool is that yeah i know this is
- 3:51:42totally wickedly cool
- 3:51:43so um i'm going to do github it's not
- 3:51:46your dad's server
- 3:51:47this is not your daddy i love that
- 3:51:50so it's it's called powershell web
- 3:51:52access so pswa a lot of us just refer to
- 3:51:55it as pwa powershell web access but
- 3:51:58pswa and you can see there's six
- 3:52:00commandlets by looking at the verbs you
- 3:52:02could probably figure out
- 3:52:03the first place i'm gonna go is to
- 3:52:05install
- 3:52:07a powershell web access application
- 3:52:09technically what's gonna happen is we're
- 3:52:11going to create
- 3:52:12a a a web application by default off of
- 3:52:16the default website
- 3:52:18when we installed iis now we didn't need
- 3:52:20to install it that happened for us
- 3:52:22automatically
- 3:52:23you can alter these defaults but i'm
- 3:52:25just going to take the defaults
- 3:52:26for right now now so install
- 3:52:30pswa and i'm going to
- 3:52:33you've got to use https for this because
- 3:52:36this is going to be something that you
- 3:52:37hit from
- 3:52:38anywhere in the world back to your home
- 3:52:42so we're going to need https you can't
- 3:52:44do this with http
- 3:52:46now if you don't have a good certificate
- 3:52:48to put on
- 3:52:49your web box right now for testing
- 3:52:52purposes
- 3:52:53they have this option of use a test
- 3:52:55certificate now i
- 3:52:56screened my screen freaked out a little
- 3:52:57bit but use a test certificate it's
- 3:52:59going to put on a temporary cert just
- 3:53:01remember this is not the cert that you
- 3:53:04want when you go to production so
- 3:53:07what's going to happen is is that it
- 3:53:08creates in iis terms an application pool
- 3:53:11for the web app creates the web app
- 3:53:13points the web app to where the files
- 3:53:15are and we're almost ready to go
- 3:53:19we just now have to tell it who's
- 3:53:20allowed to use this now
- 3:53:22this is going to be one of those rare do
- 3:53:24as i say not as i do
- 3:53:27and let me tell you why because i'm
- 3:53:29going to do get help again on
- 3:53:30on pswa we need to create
- 3:53:34who's allowed to use this and what
- 3:53:36they're allowed to go to when they use
- 3:53:38this
- 3:53:40so we need to add rules and you're going
- 3:53:41to want to add granular rules that make
- 3:53:43sense in other words
- 3:53:45is there a group of administrators that
- 3:53:46you want to be able to have remoting
- 3:53:48or to have powershell web access and
- 3:53:51what machine
- 3:53:52should they be allowed to get to or
- 3:53:55remote to when they use this
- 3:53:57you're going to want to keep control on
- 3:53:59this you're not going to want to do what
- 3:54:00i'm going to do just for easy sex so let
- 3:54:02me show you how to
- 3:54:04what you're looking for here so add
- 3:54:07a pswa uh authorization rule and let me
- 3:54:11just show you
- 3:54:13uh what computers do you want to be able
- 3:54:16to remote to
- 3:54:17so you can make this list you can create
- 3:54:18it as a computer group you also have
- 3:54:21another parameter you're going to need
- 3:54:22is either by
- 3:54:24user group or user name who's allowed to
- 3:54:27use this so you're going to want to fill
- 3:54:28out the username
- 3:54:29what computer and we're not going to get
- 3:54:31a chance to do
- 3:54:34different kinds of configurations but
- 3:54:36you can control
- 3:54:38through different configurations what
- 3:54:39command lets a person is allowed to use
- 3:54:41when they get there
- 3:54:42which is actually totally cool these
- 3:54:45three things
- 3:54:46you need to specify just be clear that's
- 3:54:48for things like
- 3:54:49hey i'm going to let um these people
- 3:54:51come into these machines
- 3:54:53and all they can do is read only
- 3:54:54operations
- 3:54:56like they can do gets they can't do sets
- 3:54:58and then
- 3:54:59this guy on these machines he can reboot
- 3:55:02the machine
- 3:55:03okay but he can't read data things like
- 3:55:06that and that's a really important point
- 3:55:08is that
- 3:55:08these users i've got administrators that
- 3:55:10have full capabilities but i got a guy
- 3:55:12who's a lot of reset passwords when he
- 3:55:14gets there
- 3:55:15that kind of stuff that you can control
- 3:55:17don't
- 3:55:18do what i'm about to do in real life if
- 3:55:20you're just testing on a vm that's fine
- 3:55:22but what i'm going to do is i'm for
- 3:55:23those three parameters i'm going to do
- 3:55:24star
- 3:55:25star star yeah i know i know that means
- 3:55:29everybody can do anything to everybody
- 3:55:30and it's just
- 3:55:31it's just lullable it's just yeah not
- 3:55:34not cool but
- 3:55:35for demonstration first summer of love
- 3:55:38the summer of
- 3:55:39love at this point
- 3:55:42i installed the feature i ins
- 3:55:45i i i installed the web app and i have
- 3:55:48now created a rule
- 3:55:51anarchy anarchy
- 3:55:55this is so so freaky cool guys this is
- 3:55:57um let me exit out of that machine
- 3:55:59this is so freaky cool that i'm going to
- 3:56:02uh this is start process i'm going to
- 3:56:04use the
- 3:56:04alias start and i'm going to start i
- 3:56:06explore
- 3:56:08with https and i'm going to go to that
- 3:56:11powershell web access box the box i just
- 3:56:13set up
- 3:56:16pwa and it's going to go to the default
- 3:56:19website and there's a web application
- 3:56:22underneath the default called pswa
- 3:56:25you can of course alter all this to make
- 3:56:27it cleaner but watch what happens
- 3:56:30secured site a matter of fact let me
- 3:56:32make this just a little bit
- 3:56:33zoomier sooner zoomier
- 3:56:37so this is the temporary certificate
- 3:56:39remember in real life when you go to
- 3:56:40production you're going to
- 3:56:41replace this continue the website
- 3:56:44it's going to come up it's going to ask
- 3:56:45me oh lookie it's going to ask for some
- 3:56:47credentials so
- 3:56:48doesn't it look like a outlook web
- 3:56:50access yeah we need to talk about that
- 3:56:55so here i'm going to put in my
- 3:56:56credentials watch
- 3:56:58and what computer do i want to remote to
- 3:57:01and work with
- 3:57:02well let's go mess with the domain
- 3:57:03controller i feel kind of froggy today
- 3:57:08get it oh do a hostname hostname show
- 3:57:10them where we are
- 3:57:11oh this is so cool it's powershell
- 3:57:15through a
- 3:57:15browser it's powershell through
- 3:57:19you made power shall work through but
- 3:57:23guys gals on the beach
- 3:57:26on the beach through any browser it's
- 3:57:29anything funny
- 3:57:30that it can be safari it can be
- 3:57:34ie it can be chrome it can be on any
- 3:57:37device a microsoft device a
- 3:57:39non-microsoft device
- 3:57:41your phone your tablet your laptop
- 3:57:44anywhere in the world
- 3:57:45you got powershell and i i want you to
- 3:57:47point out that not all these things have
- 3:57:49tab buttons when you use them
- 3:57:51but look i'll just even type a get
- 3:57:55dash serve lookie graphically they gave
- 3:57:58you a tab completion button
- 3:58:01i mean come on they thought this through
- 3:58:03this is so
- 3:58:04totally awesome now a lot of you right
- 3:58:06now are going wait a minute wait a
- 3:58:08minute wait a minute wait a minute wait
- 3:58:09a minute
- 3:58:10what about security stop it
- 3:58:13it's just like getting your email it's
- 3:58:15the same thing as getting your email if
- 3:58:17you have exchange
- 3:58:18you've got a casual out there probably
- 3:58:21in your middle tier
- 3:58:22protected by threat management gateway
- 3:58:23whatever you have it it's the same thing
- 3:58:26you can put the box right next to it
- 3:58:28it's the same
- 3:58:29thing so everybody says well this is
- 3:58:32going to be dangerous no more dangerous
- 3:58:34than you checking your email it's over
- 3:58:35https
- 3:58:37you control who has access to this you
- 3:58:39can even control what commandlets they
- 3:58:40can run
- 3:58:42this is one of the best tools and here's
- 3:58:44for a guy like me that's
- 3:58:46traveling all over the place i don't
- 3:58:49have a laptop
- 3:58:50necessarily with vpn to my network all
- 3:58:52the time sometimes the only thing i have
- 3:58:54is the tablet in my hand
- 3:58:56and i can run scripts which we need to
- 3:58:58do scripts
- 3:58:59and i can have access to powershell and
- 3:59:01remote to any box that i want to remote
- 3:59:03to dude you've undersold it
- 3:59:06i sold it i undersold it
- 3:59:09the security yeah absolutely no this is
- 3:59:12more secure than that
- 3:59:13okay why so let's see what we're
- 3:59:15comparing ourselves against
- 3:59:17so there you are and you got your laptop
- 3:59:19and you connect to your domain
- 3:59:20controller
- 3:59:21versus you're on your phone or this
- 3:59:24device of that device and you go https
- 3:59:27to a browser there to a to a website
- 3:59:30that then goes talks to the domain
- 3:59:32controller
- 3:59:33okay now on that machine that web server
- 3:59:37you're not setting that up so that
- 3:59:38people are surfing the net
- 3:59:40that web server that you go to on your
- 3:59:42laptop you're off there surfing your net
- 3:59:44you're at this new site that news site
- 3:59:46maybe some dodgy new dodgy sites dodgy
- 3:59:49sites
- 3:59:49yeah somebody's you're reading your
- 3:59:51email and people are saying oh you know
- 3:59:53click here
- 3:59:54for something wonderful and so that the
- 3:59:56risks of you know using that same box
- 3:59:59to manage your domain controller is
- 4:00:01pretty dodgy
- 4:00:02and so that's why the professional sites
- 4:00:05they set these things up called
- 4:00:06jump boxes they says okay look take your
- 4:00:09dodgy device
- 4:00:10whatever and then you go to this machine
- 4:00:13now this environment
- 4:00:14is safe stay safe you get to do one
- 4:00:17thing on this environment that is
- 4:00:18go to these other environments and you
- 4:00:20know i think that that that is such a
- 4:00:22great description because a lot of you
- 4:00:23guys probably have
- 4:00:24uh you might refer to them as bastion
- 4:00:26boxes question servers
- 4:00:28bastion servers where that's the whole
- 4:00:30point is that my laptop
- 4:00:32might be the wrong tool to be managing
- 4:00:34active directory with because
- 4:00:36of all of the weird things on it but
- 4:00:37this is a controlled server a controlled
- 4:00:40point that i'm going to that isn't going
- 4:00:41to have all that garbage and viruses and
- 4:00:44worms
- 4:00:44and crap on it and this becomes your
- 4:00:47bastion point or your bastion server
- 4:00:49this is awesome
- 4:00:50this is a huge time saver anywhere in
- 4:00:53the world and this way
- 4:00:54you know i heard this in in from
- 4:00:55microsoft i think it was in the year
- 4:00:572001
- 4:00:58we want to get to a place to where we
- 4:00:59can do we could be anywhere
- 4:01:02anytime on any device i think was the
- 4:01:04phrase and
- 4:01:05when this uh feature came out it was i
- 4:01:08can do powershell anywhere anytime any
- 4:01:09device
- 4:01:10you win so awesome feature before we
- 4:01:13wrap up promoting
- 4:01:14now we're going to do sessions in a
- 4:01:16little bit so okay but still i think
- 4:01:18there was a key
- 4:01:18point we didn't we didn't well
- 4:01:22you got the remote man what would you
- 4:01:24like to do
- 4:01:25let's leave this page yeah okay so go
- 4:01:27back to where you did the
- 4:01:28the uh and get the event log
- 4:01:32okay so uh you just want to get a value
- 4:01:34involved invoke command okay
- 4:01:36three machines oh you're gonna do it all
- 4:01:37over computer name
- 4:01:39by the way computer name if you want you
- 4:01:40can just type cn but anyway that's fine
- 4:01:42uh get log stop yeah
- 4:01:46get event log log name let's do
- 4:01:50system notice tab completion is working
- 4:01:52in the squigglies guys
- 4:01:54uh let's do newest three yeah yeah good
- 4:01:58character turn okay so here's the
- 4:02:01question
- 4:02:03why did we return objects
- 4:02:06like like that looks like text to me and
- 4:02:08that looks like what i wanted
- 4:02:10why didn't you just do that and the
- 4:02:12answer is
- 4:02:13because it's objects and objects are
- 4:02:15awesome so now what you can do is you
- 4:02:17can take that
- 4:02:18and do oh right go back just fine all
- 4:02:21right
- 4:02:22just run it okay okay so now what you
- 4:02:24can do is you can say
- 4:02:25uh pipe two sort
- 4:02:29time see here these aren't sorted by
- 4:02:32time
- 4:02:32so you get a three from this guy and
- 4:02:34then three from this guy and then three
- 4:02:35from those guys
- 4:02:36then say select are they sorry format
- 4:02:38table
- 4:02:39format table uh let's just say time and
- 4:02:43message
- 4:02:44property time and message
- 4:02:48oh time we need to do time um um it's
- 4:02:51time written
- 4:02:52yeah time written so uh let's do time
- 4:02:56written oops and i need to actually
- 4:02:59write it in here you guys get the idea
- 4:03:01but let me just get the and then maybe
- 4:03:02it's auto auto uh
- 4:03:05and oh this is getting better and then
- 4:03:07with the format commands guys the format
- 4:03:09commands are wonderful you should take a
- 4:03:10look at them
- 4:03:11format table one of my favorite ones
- 4:03:12because it has auto size
- 4:03:18is that crazy that is totally crazy so
- 4:03:20looking at that one liner
- 4:03:22what we're bringing back and this is
- 4:03:24this is a great thing is that we can
- 4:03:26then continue the pipeline and
- 4:03:27sort and select and still work with this
- 4:03:29exactly that's
- 4:03:30why the power of objects is so important
- 4:03:33because you know when you go do this
- 4:03:34stuff it's not about text
- 4:03:36it's about giving the objects and now
- 4:03:38all of a sudden like when i'm over there
- 4:03:40and i'm doing stuff i can manipulate the
- 4:03:41objects there and that's great
- 4:03:43but when i do remoting what i can do is
- 4:03:45i can get the objects from a very large
- 4:03:47set of machines
- 4:03:49bring them here and operate against the
- 4:03:51object so imagine
- 4:03:52imagine you say oh i got somebody and i
- 4:03:55need to give them
- 4:03:56i need to give them a share you can go
- 4:03:58out to all your file servers get the
- 4:04:00disk space from all your file servers
- 4:04:02as a collection of objects sorted by
- 4:04:04free space
- 4:04:05and then you can say give me the top
- 4:04:06three and then you can look at those and
- 4:04:08say
- 4:04:09yeah that's the one i want imagine how
- 4:04:10else you do it you go to this one find
- 4:04:12it write it down
- 4:04:13you go to that one write it down you go
- 4:04:15to that one how many of you guys are
- 4:04:16actually
- 4:04:17still sending people out to do that go
- 4:04:19check that file server see how much disk
- 4:04:21space it is put it into the spreadsheet
- 4:04:23so we can keep track of
- 4:04:24this as opposed to and there's several
- 4:04:26ways to do it what he's talking about
- 4:04:28but as opposed to
- 4:04:29um let's just use what is it get volume
- 4:04:32right is that is one of the new tests
- 4:04:35or get i think get volume will give you
- 4:04:37free space in science
- 4:04:38we're going to find out in a minute
- 4:04:39we're going to find out what's inside
- 4:04:40size remaining in size
- 4:04:42so yeah do it don't do it do it do it do
- 4:04:44it do it
- 4:04:46do it do it do it do it so let's do uh
- 4:04:49what do you want to do
- 4:04:50command and we'll do it to the way can
- 4:04:52we show them this short way
- 4:04:54this is this yeah yeah here's the short
- 4:04:56way yeah
- 4:04:57yeah i see icm and then and then the
- 4:05:00names
- 4:05:01or just do the names yeah because it's
- 4:05:02positional so dc s1
- 4:05:05s2 that's the short way and we want to
- 4:05:07do
- 4:05:08let's see get volume and pipe it to sort
- 4:05:11size remaining
- 4:05:13[Music]
- 4:05:14volume
- 4:05:16sort size
- 4:05:19i can't spell anymore it's a long day
- 4:05:23sort size remaining let's just try that
- 4:05:24see what we get
- 4:05:25[Music]
- 4:05:28oh god look look look the size remaining
- 4:05:31no wait wait wait no here's the thing
- 4:05:32go back up scroll up scroll up
- 4:05:35scroll up okay notice see you see notice
- 4:05:39how the formatting's no
- 4:05:40i want to show the previous previous one
- 4:05:42so notice here it just shows you
- 4:05:44drive letter to size but now you go
- 4:05:47scroll down
- 4:05:48notice we have ps computer name when the
- 4:05:51objects come back
- 4:05:52we add properties to it and we add where
- 4:05:56did this thing come from
- 4:05:57so that when i do this sort and then you
- 4:05:59go down at the bottom
- 4:06:01i can see okay well there's my volume
- 4:06:03but where did the volume come from and
- 4:06:04the answer is
- 4:06:05s2 that's right so and guys party on my
- 4:06:09friends
- 4:06:09oh and here's the thing that commandlet
- 4:06:11you can
- 4:06:12just say just show me the c drive you
- 4:06:15can sort and filter this out more where
- 4:06:16i just want to see the computer name and
- 4:06:18the size remaining
- 4:06:19and just get a nice short terse list
- 4:06:22then
- 4:06:23export to csv you got your report done
- 4:06:25and you did it on as many computers as
- 4:06:27you wanted to
- 4:06:28in seconds you show them select last
- 4:06:32yeah yeah yeah so here this might have
- 4:06:34been like if i'd done this to like lots
- 4:06:36of machines and there were file services
- 4:06:37and lots of stuff on it
- 4:06:38this would be pretty big and you don't
- 4:06:39want to mess with that right so what you
- 4:06:41do is you say select minus last
- 4:06:43let's pick the last three three
- 4:06:47and what it'll do is give you the last
- 4:06:49three just exactly what you think it
- 4:06:51would do boom
- 4:06:51boom there's the last three so we can
- 4:06:54show rocks
- 4:06:55at powershell so rocks we have first we
- 4:06:57have last there's
- 4:06:58all kinds of ways this is the importance
- 4:07:00of taking a look at those help files
- 4:07:02skip exactly so make sure you look
- 4:07:04inside these help files because
- 4:07:06you can do it it's not something well i
- 4:07:08can't figure out how to do it
- 4:07:09you don't need bizarre long links of
- 4:07:11code you need to look at the help files
- 4:07:13they've really thought this stuff
- 4:07:15through
- 4:07:15and if you get stuck powershell.org
- 4:07:18and ask on the forum yeah lots of really
- 4:07:21helpful people out there
- 4:07:22and just as a side note i it's it's it's
- 4:07:25fascinating that
- 4:07:26how strong the powershell community is
- 4:07:29you guys have noticed
- 4:07:30this is not necessarily the easiest tool
- 4:07:32in the world for you to learn it's the
- 4:07:33most powerful one in your toolbox but
- 4:07:35it's not an easy tool to learn because
- 4:07:37you're just staring at a prompt and now
- 4:07:39what do i do
- 4:07:40we've all gone through this and so the
- 4:07:42powershell community
- 4:07:44is so strong they want to help you so
- 4:07:46avail yourself of those resources and
- 4:07:48i'll give you some more here in a little
- 4:07:50bit
- 4:07:50yeah can you riff on that a second yeah
- 4:07:51so here's the thing you know we found as
- 4:07:54we were rolling out powershell that the
- 4:07:55community just flourished and it's like
- 4:07:57wow and people are having a blast
- 4:07:59now here's the interesting thing turns
- 4:08:01out that this this like hurts the
- 4:08:03community
- 4:08:04no seriously it hurts the community why
- 4:08:06and so and we noticed this because
- 4:08:07at some point we're putting things
- 4:08:08together and everyone like hey did you
- 4:08:10see what bruce did no what did bruce do
- 4:08:12we all run into bruce's office
- 4:08:14and he shows what he does he's like oh
- 4:08:16man that's awesome can you send that to
- 4:08:17me he sends it to me and i'm doing it
- 4:08:19and then i change it and they're like oh
- 4:08:21check out what jeffrey did and everybody
- 4:08:22comes running
- 4:08:23and we were just having a blast with
- 4:08:24this and when lois we thought we said we
- 4:08:26talked about this a little last night we
- 4:08:28said
- 4:08:28boy we're really having fun here and
- 4:08:30like it used to
- 4:08:31computers always used to be fun and then
- 4:08:33for some point
- 4:08:34they stopped being fun it just seemed
- 4:08:36like it was a job
- 4:08:38it became mundane mundane and i think it
- 4:08:40was because of this damn thing
- 4:08:42the mouse right and so here's the idea
- 4:08:44like like i never
- 4:08:46i never never never say hey come on guy
- 4:08:49did you
- 4:08:49check to see the way jason was clicking
- 4:08:51that mouse my god
- 4:08:53you were such a clever guy did you see
- 4:08:55the snap on that thing see i love you
- 4:08:57man because man i work on my mouse moves
- 4:08:59and
- 4:09:00so it's yeah well no that's the point so
- 4:09:02when when i see you
- 4:09:03program when you script and you write
- 4:09:05together as command line
- 4:09:07i see how you think and i'm able to say
- 4:09:09wow that's really clever that's really
- 4:09:11neat
- 4:09:11and you're able to then then i say oh
- 4:09:14can i have that
- 4:09:15right and you give it to me and all of a
- 4:09:16sudden you've helped me
- 4:09:18like you click let's say you're a god at
- 4:09:20clicking that mouse right
- 4:09:22how can you help me like step back and
- 4:09:24be impressed i guess
- 4:09:29right but with a script you can help me
- 4:09:30and i can take it and i've modified it
- 4:09:32meets my needs and i look great to my
- 4:09:34boss
- 4:09:34and all of a sudden you know what two
- 4:09:35things one is you feel good because you
- 4:09:37help me
- 4:09:38two i feel good i have a debt of
- 4:09:40gratitude to you i mean thank you very
- 4:09:41much
- 4:09:42that's very awesome and you buy your
- 4:09:44beer or something like that
- 4:09:45and also i say hey you know what i
- 4:09:47should help other people too
- 4:09:48so really you should help other people
- 4:09:50first be aware
- 4:09:52there's lots of people in the community
- 4:09:53out there more than willing to help you
- 4:09:55should not be sitting
- 4:09:57you know suffering in silence no no if
- 4:09:59you're confused or anything
- 4:10:01i guarantee you nobody's going to be and
- 4:10:04you should not be embarrassed by any of
- 4:10:05your questions people aren't going to
- 4:10:07make fun of you
- 4:10:08that's not going to happen the barrier
- 4:10:10for you asking a question should be
- 4:10:12extraordinarily low just
- 4:10:14ask the question in a form in twitter
- 4:10:16twitter
- 4:10:17very useful place as well just ask that
- 4:10:19question people will help you
- 4:10:20and it turns out then when and then you
- 4:10:23should participate
- 4:10:24you should say hey i found this clever
- 4:10:26way to do things you should blog things
- 4:10:28and here's a great thing right
- 4:10:29so you might know i've been doing this
- 4:10:31powershell thing for a little while now
- 4:10:33i blog things i blog things and say oh
- 4:10:35here's what i do and people will say
- 4:10:37jeez why do you do it that way why
- 4:10:39didn't you do it this way i was like
- 4:10:40i didn't know you could do it that way
- 4:10:42and so the community is teaching me how
- 4:10:44to do things
- 4:10:45honestly it's just a wonderful thing and
- 4:10:47i have to say it's
- 4:10:48it's truly amazing and and remember when
- 4:10:51computers were fun when it wasn't i need
- 4:10:52to reset a bunch of passwords and you
- 4:10:54just sat there and went like
- 4:10:55this where now you're actually going oh
- 4:10:57i'm going to figure out how to reset
- 4:10:59these passwords i'm going to figure out
- 4:11:00how to do xyz
- 4:11:02awesome and now i'm going to automate it
- 4:11:05so i never have to do it again but it
- 4:11:07was fun figuring out the problem it used
- 4:11:09to be
- 4:11:09fun solving the problem and powershell's
- 4:11:13brought that back and the community is
- 4:11:14really strong with that
- 4:11:16folks so here's what we're going to do
- 4:11:17is let me show you the um just
- 4:11:19to let you know that with all of this
- 4:11:20stuff we did in remoting is in the
- 4:11:22slides
- 4:11:23and i'm just going to go through these
- 4:11:25real quick but it's not the end yet of
- 4:11:26remoting we've got some more stuff to do
- 4:11:28but we want to start some automation and
- 4:11:29some scripting to come up
- 4:11:32and so um we're going to kind of get
- 4:11:33started on this and before we take a
- 4:11:35break so
- 4:11:36if you have questions or comments please
- 4:11:38make sure you're jumping out there and
- 4:11:39we're going to come back to remoting in
- 4:11:41just a second
- 4:11:42but before we take a break let's get
- 4:11:44started on this concept
- 4:11:46of automation and to do that
- 4:11:49we need to start to talk about things
- 4:11:51like
- 4:11:52security because we're going to talk
- 4:11:54about scripting now
- 4:11:55and so we're going to take the commands
- 4:11:57that you're building as one-liners and
- 4:11:59and so forth
- 4:12:00and we're going to take those commands
- 4:12:01and now automate them by putting them
- 4:12:03into a script and just telling the
- 4:12:05script to run them for us
- 4:12:07no major deal yet it's pretty
- 4:12:09straightforward but to run a script
- 4:12:11requires some special security so
- 4:12:13we're gonna talk about security we're
- 4:12:14gonna talk about variables a place to
- 4:12:16store your stuff
- 4:12:17maybe a little bit with quotes and then
- 4:12:19we'll start getting into the automation
- 4:12:20so the first thing off
- 4:12:22is and by the way that's a picture of me
- 4:12:24right there the big guy in there
- 4:12:26on the next screen usually people say
- 4:12:28that's the picture of me but that's it
- 4:12:30no oh no guys in the background yep
- 4:12:32that's it
- 4:12:34so powershell is secured by default for
- 4:12:37several different with several different
- 4:12:40ways we had some problems in the past
- 4:12:41with
- 4:12:42like vbscript you double click on it it
- 4:12:44runs oh god
- 4:12:45yeah talk a little bit about what
- 4:12:47powershell does for us
- 4:12:49yeah so okay again remember it's secure
- 4:12:51by default you know we did this
- 4:12:52secure secure secure so when you double
- 4:12:54click so what happened if you weren't
- 4:12:56around then uh people would came in one
- 4:12:59morning
- 4:13:00and they got a mail i love you and
- 4:13:02they're like
- 4:13:03oh well i feel i feel special i've got a
- 4:13:05secret admirer
- 4:13:06and even even the people like i bet
- 4:13:08that's not true
- 4:13:10but it might be right so i want to find
- 4:13:12out why not who loves me
- 4:13:14click click and and then it would run
- 4:13:17you click on this thing and it would run
- 4:13:18and guess what
- 4:13:19bad things happen bad things anybody
- 4:13:21who's like giving you something free
- 4:13:23are promising to grow or shrink your
- 4:13:24body parts with just with money
- 4:13:27just doesn't work okay and so too
- 4:13:29somebody sends you love
- 4:13:30don't click on that stuff anyway so with
- 4:13:32powershell somebody sends you that
- 4:13:34and you double click on it it brings up
- 4:13:36it in the editor it doesn't run it
- 4:13:38it doesn't run it that is the key so
- 4:13:42let me do a quick demonstration of that
- 4:13:43let's uh let's just make a really quick
- 4:13:45script and guys
- 4:13:46do we will get cooler than this but i'm
- 4:13:48going to make a really quick script and
- 4:13:50i've been doing this git service bits
- 4:13:51thing all morning i'm getting sick and
- 4:13:53tired of typing this in
- 4:13:54and i'm going to make sure that it works
- 4:13:56it works i'm going to take this right
- 4:13:57now and i'm
- 4:13:59copying it and i'm going to start up
- 4:14:01notepad
- 4:14:02and i'm going to yeah we're using
- 4:14:04notepad right now don't worry we're
- 4:14:06going to get to the ise i'm going to
- 4:14:07paste it in there
- 4:14:08file save as and here's the magic to
- 4:14:12making a script
- 4:14:13well let me put it on my desktop so we
- 4:14:14can see it is what do you want to call
- 4:14:16this script let's
- 4:14:17call it i love you i love you
- 4:14:21and uh let's uh dot ps1
- 4:14:25uh ps1 and i don't actually want to put
- 4:14:28on my desktop i'm going to put it under
- 4:14:30my scripts folder here so i can get to
- 4:14:32it and
- 4:14:34there's a scripts folder right there i
- 4:14:36love you ps1 you gotta get rid of the
- 4:14:37text
- 4:14:38i gotta hear oh yeah yeah yeah files
- 4:14:41all files and save stick with me guy
- 4:14:44i'll help you out
- 4:14:47so i i've got a script what i want you
- 4:14:49to see is is yes i'm going to show you
- 4:14:51this graphically first because i want to
- 4:14:53see what
- 4:14:53what jeffrey just said i'm going to go
- 4:14:55out here and if somebody were to send
- 4:14:57this to me
- 4:14:58i love you ps1 and i'm going to double
- 4:15:01click it
- 4:15:02see brings it up in notepad or whatever
- 4:15:05editor you're
- 4:15:06you're you're they've set for it then
- 4:15:08what they didn't look
- 4:15:09they didn't actually love me it didn't
- 4:15:10execute my script now this is a good
- 4:15:12thing
- 4:15:12for so many reasons as you guys already
- 4:15:14know you don't want scripts to
- 4:15:15automatically execute but i want to
- 4:15:17bring something up
- 4:15:18a lot of the security that we're going
- 4:15:19to be talking about and the next thing
- 4:15:21which is execution policy which we're
- 4:15:23going to do before we go and break um
- 4:15:25i need to tell you that this is this
- 4:15:28security
- 4:15:29is is is designed to take an
- 4:15:31unintentional
- 4:15:32user to stop them from doing
- 4:15:34unintentionally malicious things in
- 4:15:36other words
- 4:15:37i want you to think about i downloaded a
- 4:15:39script i double click on it i didn't
- 4:15:41want it to run i just i wanted to look
- 4:15:42at it
- 4:15:44we this helps you now if you
- 4:15:47are a power user that wants to be
- 4:15:50malicious
- 4:15:51can we change this well yeah
- 4:15:54i mean power i mean yeah i can i know
- 4:15:57how to change the association of the ps1
- 4:16:00to make it actually execute that's just
- 4:16:03not a good idea
- 4:16:04don't do that the point is is we're not
- 4:16:06going to stop you from doing that but
- 4:16:08this helps you for making foolish
- 4:16:10mistakes like this
- 4:16:11so let's try to execute this script and
- 4:16:13watch what happens
- 4:16:15there's another security feature the
- 4:16:17whole path thing
- 4:16:18you you make us type in the path yeah
- 4:16:20well first just try and type it
- 4:16:22so c colon scripts and i was i love you
- 4:16:26cd to there oh okay
- 4:16:30and then just type i love you i love
- 4:16:33you i love you i no that's not going to
- 4:16:36work
- 4:16:37well i love ip i love ip i love ip i p
- 4:16:39therefore i am there we go i love you
- 4:16:41what what what what what
- 4:16:44says no no no no no not recognized as
- 4:16:48the name of a commandlet a function or a
- 4:16:50script
- 4:16:50file check the spelling well look at the
- 4:16:54suggestion have you ever known someone
- 4:16:55did you notice that the command i love
- 4:16:57you was not found but
- 4:16:59does exist in the current location you
- 4:17:01never know
- 4:17:02i never noticed that tricky tricky so
- 4:17:04now that's just going to confuse me more
- 4:17:06because it's going to say
- 4:17:07oh but then it actually tells me how to
- 4:17:09solve it yeah
- 4:17:10type dot slash now here's the reason why
- 4:17:13this is what's called a you know kind of
- 4:17:14a trolling attack so what would happen
- 4:17:17is
- 4:17:17and this is the old-time unix problem
- 4:17:20your admin
- 4:17:21and your cd to somewhere and you say
- 4:17:22print working directory
- 4:17:24and a bad guy would go in that directory
- 4:17:26and they'd put something called
- 4:17:28print working right directory they would
- 4:17:29rename iloveyou.vbs to print working
- 4:17:31directory directory
- 4:17:32so you cd there you do print working
- 4:17:34directory you run that code
- 4:17:37and so and bad things would happen and
- 4:17:39so what we said was no no
- 4:17:41if you want to run something in the
- 4:17:42current directory you have to be
- 4:17:44clear that that's what you want to do
- 4:17:46we're very clear
- 4:17:47very big on intentionality you have to
- 4:17:49tell me that that's what you want
- 4:17:51otherwise no i remember uh root kits
- 4:17:54used to come in there was a dir
- 4:17:55root kit and you would go dir and you
- 4:17:58were running the root kit
- 4:18:01yeah bad bad so what this prevents from
- 4:18:03is let me show you this two ways one is
- 4:18:05i could try to run the script by typing
- 4:18:07in the full path to the script
- 4:18:09i love you or i can be in the current
- 4:18:13directory and let me show you that one
- 4:18:14if i'm in the current directory with the
- 4:18:15script and try to run it
- 4:18:19it's dot slash i love you ps1
- 4:18:22and that's what that general message at
- 4:18:24the bottom told you to do is because it
- 4:18:26saw it there
- 4:18:27this will run my script oh
- 4:18:30no i'm a failure i'm a failure in life
- 4:18:32because it found it but it
- 4:18:34says it can't be loaded because the
- 4:18:36running of scripts is disabled on this
- 4:18:39system
- 4:18:39for more information in other words
- 4:18:41you're not allowed to run
- 4:18:42scripts and when we come back from break
- 4:18:45we're going to show you
- 4:18:47why you're not allowed to run scripts
- 4:18:49and then how to change that so
- 4:18:51we'll see you guys in 10 minutes yeah 10
- 4:18:53minutes cheers
- 4:19:12[Music]
- 4:19:20oh now see i was talking for like a
- 4:19:22minute and a half and they didn't turn
- 4:19:24the cameras on
- 4:19:25so so back to what we were
- 4:19:29back to what we were doing there they
- 4:19:31are where are you back
- 4:19:32there where have you been um so here's
- 4:19:35the deal
- 4:19:36we need to work with the execution
- 4:19:37policy now i just want you to take a
- 4:19:38quick look at this slide because it it
- 4:19:40lists the execution policy
- 4:19:42for us kind of quick now we have a
- 4:19:44couple of commandlets that'll let us
- 4:19:45work with the execution policy and by
- 4:19:47default
- 4:19:48you are restricted in other words no
- 4:19:51scripty allowed to run
- 4:19:52now interactive only yeah and i just
- 4:19:54want to point out
- 4:19:56that see the word under here called
- 4:19:58unrestricted
- 4:19:59can we just right now kind of put into
- 4:20:01our heads that that's not an option for
- 4:20:03you to set
- 4:20:04it did it with bypass bypass because
- 4:20:06there bypass like
- 4:20:08yeah but unrestricted and bypass so can
- 4:20:11you kind of i know you i don't want you
- 4:20:13drawing on your computers but can you
- 4:20:14just kind of cross those off
- 4:20:16restricted unrestricted well restricted
- 4:20:18is good for
- 4:20:19but no crossover unrestricted bypass can
- 4:20:22we focus on the two that we really want
- 4:20:24you to focus on which is
- 4:20:26remote signed and all signed
- 4:20:30so do you want to talk about the the the
- 4:20:32what is this signed
- 4:20:33thing in the first place that we're
- 4:20:35talking about so basically basically
- 4:20:36digital signatures now in the past like
- 4:20:38vbscript had this
- 4:20:40that was really bad stuff all it did was
- 4:20:41said hey if
- 4:20:43a script is digitally signed i'll run it
- 4:20:45not
- 4:20:46digitally signed by someone i trust
- 4:20:47trust yeah so
- 4:20:49we took a different approach we said it
- 4:20:51has to be digitally signed
- 4:20:52and you have to trust them so before we
- 4:20:55talk about the difference between
- 4:20:56all signed and remote signed can you
- 4:20:58show us what's what it's like to sign a
- 4:21:00script
- 4:21:00okay so let me first go i i've created a
- 4:21:03new
- 4:21:04a self-signed certificate and if you
- 4:21:06ever wonder about that you just say new
- 4:21:08self signed certificate you can go
- 4:21:12create your own
- 4:21:13i've already created some and what i do
- 4:21:15is they're in the cert drive not if
- 4:21:17we've talked about this there are these
- 4:21:18things called providers
- 4:21:19get ps drive okay and you'll see the
- 4:21:23traditional drives like the c
- 4:21:24drive that we've been showing but
- 4:21:26there's a certificate drive oh
- 4:21:28so what i can do is i can do a dir of
- 4:21:30the certificate drive and i do tab
- 4:21:32completion here
- 4:21:33sorry current user and what i'm doing is
- 4:21:35i'm looking for a code signing search so
- 4:21:37the interesting thing is when i'm in the
- 4:21:38certificate drive
- 4:21:39i can do things like well i can do
- 4:21:41recurse on any drive of course
- 4:21:43but i can say give me the code signing
- 4:21:45certs
- 4:21:46how strange and then what i'm going to
- 4:21:48do is i'm going to say ov
- 4:21:49or output put variable
- 4:21:53a okay so what that did was it got me
- 4:21:57did a recursive search found me my code
- 4:21:59signing certs
- 4:22:00i now put them in dollar sign a and then
- 4:22:03what i'm going to say is dollar sign
- 4:22:04cert equals dollar sign a zero so now
- 4:22:06i've got a particular code signing cert
- 4:22:08okay so now let's see let's get my
- 4:22:11execution policy
- 4:22:13get execution policy and you see it's
- 4:22:16remote sign here i'm going to change
- 4:22:18that to
- 4:22:21set execution policy equals
- 4:22:25all signed okay oops sorry
- 4:22:29a equals what am i doing i'm making an
- 4:22:30idiot set execution all signed
- 4:22:33it says yep do it now here i am and i
- 4:22:36have this
- 4:22:36test script oop let me just edit that
- 4:22:39test script
- 4:22:43let me just get rid of this because i
- 4:22:44already signed it that's not right
- 4:22:49don't you see that
- 4:22:52okay so there's my test script
- 4:22:56right and i go and i run it
- 4:23:00it says no you can't do it because
- 4:23:03uh it's not digitally signed okay
- 4:23:06because you went to all signed which
- 4:23:07means
- 4:23:08everything must be signed talk about
- 4:23:10remote signed in a second but everything
- 4:23:12must be signed
- 4:23:12so now i say well i'd like to sign it
- 4:23:14because i trust this i first
- 4:23:16don't sign stuff you haven't understood
- 4:23:18like sign it saying
- 4:23:20sign it is remember i said earlier like
- 4:23:22i take my badge out i put it on the
- 4:23:24table and i say
- 4:23:25i guarantee is it going to work when
- 4:23:27you're digitally signing something
- 4:23:28you're taking your badge out you're
- 4:23:30putting on the table and say anything
- 4:23:31wrong
- 4:23:32take my badge okay so be careful so you
- 4:23:35probably want to take a look at the
- 4:23:36script you're going to smell probably
- 4:23:37yeah i take a look then i said i'm
- 4:23:41so you want to set the auth
- 4:23:45authentication code signature
- 4:23:48of i give my cert and my dollar sign
- 4:23:51cert and
- 4:23:55the file pack yeah okay now notice
- 4:23:59now when i do this test.ps1
- 4:24:03here i'll cat it cat test
- 4:24:08oh look at that thing look at that
- 4:24:11wow yeah so now i mean that is a
- 4:24:14that's a big beast so now if your script
- 4:24:17actually did something harmful
- 4:24:18we know who you are and we can hunt you
- 4:24:20down yes
- 4:24:21except it's a self-signing script right
- 4:24:23so so yeah but yes we can
- 4:24:25now here's the deal dot slash test now
- 4:24:27watch what happens
- 4:24:29just because it's signed doesn't mean
- 4:24:30i'll run it okay
- 4:24:32so we'll say hey uh do you want to run
- 4:24:34this thing
- 4:24:35and you can say hey never run it
- 4:24:38uh don't run it run it once i'm gonna
- 4:24:40say run it once
- 4:24:42okay now if i said always run it it
- 4:24:45would have then taken that certificate
- 4:24:46and said
- 4:24:47i always trust stuff from this guy from
- 4:24:49this certificate yeah and then you can
- 4:24:51run it
- 4:24:51now here you want to see something crazy
- 4:24:53yeah yeah
- 4:24:54i told you we pay attention to the
- 4:24:56security stuff right
- 4:24:58i told you that okay so now imagine
- 4:25:01imagine i go and i say
- 4:25:02um okay so we say let's say
- 4:25:06now just because it's signed i can run
- 4:25:09it always so i can say set
- 4:25:11execution policy and i'll say
- 4:25:14um uh the remote signed
- 4:25:20okay so fine now
- 4:25:23now i can go and i can run this thing it
- 4:25:26just runs
- 4:25:27okay just run but now watch this now
- 4:25:29again what did i say
- 4:25:31when i get a script from the internet
- 4:25:32you don't want to just run it you want
- 4:25:34to examine it
- 4:25:35okay so imagine i do this thing and i
- 4:25:38say
- 4:25:38hey let let me look at this thing and i
- 4:25:40see that and i say hey you know what
- 4:25:42that's safe
- 4:25:42i'm just going to run it right let me
- 4:25:44take a look is it safe
- 4:25:46it's got a signature it looks and the
- 4:25:48code looks safe yeah okay
- 4:25:49okay but wait what if i do this
- 4:26:00oh that's not safe that's not safe now
- 4:26:03now let's save that that's that's kind
- 4:26:04of mean so
- 4:26:06let's make sure we do this so now again
- 4:26:09you come here and you have this script
- 4:26:11yeah yeah
- 4:26:13that that that's mean man but you say
- 4:26:15hey you evaluate it
- 4:26:16right i'm evaluating and it looks good
- 4:26:18at the top right yeah but what if
- 4:26:20down here or somewhere in there is there
- 4:26:22everybody yeah
- 4:26:24well let's run it what do you think
- 4:26:26should i run it
- 4:26:27yeah let's let's no no because you're
- 4:26:30going to run it it's going to rest no i
- 4:26:31checked it out i read it it looked fine
- 4:26:33look look all right it looks fine it's
- 4:26:36fine
- 4:26:36okay run it i mean it looks great you
- 4:26:38know what could possibly go wrong nobody
- 4:26:40would have
- 4:26:40stuck anything in
- 4:26:45so check this out executable code
- 4:26:48found in the signature block
- 4:26:51so we're aware of this threat we're rare
- 4:26:54that
- 4:26:54that people how they're going to
- 4:26:55evaluate things they're going to look at
- 4:26:57things we're going to see the signature
- 4:26:58block
- 4:26:59they're just going to say yeah yeah yeah
- 4:27:01and so we look for people
- 4:27:03uh sneaking in bad code and so we
- 4:27:06protect you from that and say no we're
- 4:27:07not running that crap
- 4:27:09and we even tell you where it is line
- 4:27:1093.
- 4:27:12oh i just got saved from this horrible
- 4:27:15thing no
- 4:27:15that's totally awesome so i so here's
- 4:27:18here
- 4:27:20all signed versus remote sign all sign
- 4:27:22means every script
- 4:27:23that you download and that you create
- 4:27:25locally
- 4:27:26needs to be signed and just to let you
- 4:27:28know and i'm going to type this on my
- 4:27:29screen
- 4:27:30there is a help file about underscore
- 4:27:32signing that will basically take you
- 4:27:33through
- 4:27:34everything that jeffrey just did to sign
- 4:27:37a script
- 4:27:38but let's talk about something for a
- 4:27:40second remote signed
- 4:27:42a lot of you right now it's going to be
- 4:27:44easier for you to start off with remote
- 4:27:45signed here's what this means anything
- 4:27:47you download
- 4:27:48like from the internet needs to be
- 4:27:50signed do you guys know that
- 4:27:52we know what you download from the
- 4:27:54internet
- 4:27:57okay i'm just saying a bunch of guys
- 4:27:59just went
- 4:28:00i got to delete this uh nah there's
- 4:28:05there was a i can't remember what was
- 4:28:06put in mark of the web was put in
- 4:28:09so that things got tagged if they got
- 4:28:11downloaded from the internet this is to
- 4:28:12protect you this is a feature
- 4:28:14and they tagged it so that it overwrote
- 4:28:16rootkits well powershell knows this and
- 4:28:18powershell knows
- 4:28:20that if you downloaded it from the
- 4:28:21internet if you're set to remote signed
- 4:28:24there needs to be a signature on there
- 4:28:26but if you make the script locally there
- 4:28:29doesn't have to be a signature on it so
- 4:28:31a lot of folks
- 4:28:32will set their policy and this is okay
- 4:28:34to start with to remote sign
- 4:28:36just because it's easier to get started
- 4:28:38with
- 4:28:39[Music]
- 4:28:40which that's fine but as soon as you
- 4:28:42possibly can you really want to remove
- 4:28:44go to all sign because i want you to
- 4:28:46think about this at some point you're
- 4:28:48going to want to have this
- 4:28:49execution policy where you can run
- 4:28:50scripts in other places
- 4:28:52and it'd be nice to be able to control
- 4:28:55this through
- 4:28:56that the scripts have to be signed
- 4:28:57imagine what your users might do if they
- 4:29:00figure out how to turn on scripting
- 4:29:01policy
- 4:29:02they might want to download a script if
- 4:29:05you set this through
- 4:29:06a group policy then you're going to be
- 4:29:09able to help control what could be some
- 4:29:11possible issues of users trying to do
- 4:29:13weird things
- 4:29:14so this is actually really important
- 4:29:16remote signs good to start with all
- 4:29:17signs
- 4:29:18is really the best to get to watch what
- 4:29:21happens now and you've seen it with
- 4:29:22jeffrey now that
- 4:29:23i have an execution policy that works i
- 4:29:26can try to run my script
- 4:29:27and i forgot what my script was i love
- 4:29:30ups one and lo and beholds
- 4:29:32there it goes now so script script
- 4:29:35execution policy need to turn it on yeah
- 4:29:39let me talk about the latest version
- 4:29:40latest version of windows
- 4:29:42top secret top secret topsy we're
- 4:29:44disclosing we're going to bring you into
- 4:29:47the circle of trust
- 4:29:50so the next version of windows server
- 4:29:52let's say windows server 2012 r2
- 4:29:55we change the default execution policy
- 4:29:58to be
- 4:29:58remote signed by default which is
- 4:30:00awesome because that way you don't have
- 4:30:02to run around to your servers
- 4:30:03or issue out a group policy to get this
- 4:30:05because you need your servers
- 4:30:07to have an execution policy so when
- 4:30:09modules load and you want to shoot you
- 4:30:11want to load scripts from all that kind
- 4:30:12of stuff
- 4:30:13it makes life a lot easier so server
- 4:30:152012 r2
- 4:30:17right is when it ships we'll have the
- 4:30:19new poli which is amazing to
- 4:30:21have that set yeah by the way a number
- 4:30:22of people let me just clarify one thing
- 4:30:24we're not going to get into the details
- 4:30:25of the security but i will just point
- 4:30:27out that even if you're
- 4:30:28uh if you have like uh execution policy
- 4:30:31to be
- 4:30:32you know uh unrestricted whatever an
- 4:30:34interactive user basically an
- 4:30:36interactive user can do
- 4:30:37anything and they can bypass that that
- 4:30:41don't worry about that that is not a
- 4:30:43security violation that's not a hole
- 4:30:45there's actually a long explanation for
- 4:30:47that we won't get into it here because
- 4:30:48it's not that interesting
- 4:30:49but just don't freak out if somebody has
- 4:30:51access to a terminal
- 4:30:52i mean basically here's the thought if
- 4:30:54they have access to a terminal uh
- 4:30:56they can uh uh create programs compile
- 4:30:59those programs and run it which means
- 4:31:01they can do anything
- 4:31:02so at this point it's it's not a
- 4:31:04security remember the old the old thing
- 4:31:06of physical access right
- 4:31:07physical access so um guys we want to do
- 4:31:10a couple of things to set us up for some
- 4:31:11scripting one of the things that we want
- 4:31:13to do here oh this is
- 4:31:14we're going to start doing first of all
- 4:31:15variables now uh
- 4:31:17we've already been using them believe it
- 4:31:19or not i just want to show you that
- 4:31:21um watch i'm going to show you there's a
- 4:31:22whole bunch of commandlets so i'm
- 4:31:24thinking to myself
- 4:31:25how would i find if powershell had any
- 4:31:27commandlets to help me with variables
- 4:31:29i can do this variable and
- 4:31:32oh looky there's a whole bunch of clear
- 4:31:34variable get variable new variable
- 4:31:36remove variable set
- 4:31:38stop looking at the screen we're not
- 4:31:40going to use any of them we don't need
- 4:31:41to
- 4:31:42powershell makes working with variables
- 4:31:44really easy we don't necessarily need
- 4:31:45these commandlets
- 4:31:46so let me show you how easy it is to
- 4:31:48make a variable um
- 4:31:50watch variables um have a dollar sign
- 4:31:53and
- 4:31:54there's a lot of reasons for the use of
- 4:31:55this dollar sign we're not going to get
- 4:31:57a chance to go into
- 4:31:58how the parsing engine reads all of this
- 4:32:00but this is not the name
- 4:32:01or part of the name of the variable it
- 4:32:04tells powershell hey
- 4:32:05something's about to happen and if it's
- 4:32:06alphanumeric after it
- 4:32:08my var this is going to be a variable
- 4:32:11if you want to set this variable equal
- 4:32:12to something equals
- 4:32:15hello thank you thank you no commandlets
- 4:32:19required i just created variable
- 4:32:20totally totally awesome you want to see
- 4:32:22what's inside of a variable
- 4:32:24myvar but variables are awesomely cool
- 4:32:27because
- 4:32:28variables don't just take text they
- 4:32:30don't just take integers
- 4:32:32watch my var
- 4:32:35equals get service
- 4:32:40bets guess what's in my var right now
- 4:32:43guess what's in my bar wait a minute let
- 4:32:45me show you this is called my
- 4:32:46bar
- 4:32:50wait wait wait wait wait watch watch
- 4:32:53watch
- 4:32:53get member lookie look look look
- 4:32:56look look what's in my bar i got a
- 4:32:59service controller object in there
- 4:33:01it's not just text guys it's it's
- 4:33:03service controller object so
- 4:33:04i want you to notice something we
- 4:33:06haven't talked much about running
- 4:33:07methods but
- 4:33:08all these properties and look there's a
- 4:33:10couple of methods here there's a start
- 4:33:12and a stop method
- 4:33:14i have an idea i wonder if i could use
- 4:33:16this
- 4:33:17dot notation that you started using
- 4:33:20my var dot let's see a property status
- 4:33:24oh it's running and i wonder if i could
- 4:33:26get it to run
- 4:33:27a method like stop
- 4:33:34now i know you're all saying well prove
- 4:33:35it prove it prove it all right well
- 4:33:37one little thing is i'm going to do my
- 4:33:39var status but you're going to say oh
- 4:33:40so you didn't work no no no no no if we
- 4:33:43refreshed
- 4:33:44everything that existed in windows
- 4:33:46constantly
- 4:33:47oh my god so there's a method to help us
- 4:33:49refresh this so refresh
- 4:33:53and now look at the status boom
- 4:33:56totally awesome vars make your life
- 4:33:59much easier and of course with scripting
- 4:34:02bars become very important now there's a
- 4:34:04lot to do with vars and there's a lot of
- 4:34:06tips and tricks with working with bars
- 4:34:09um can you tell one thing oh absolutely
- 4:34:11so snap to mine
- 4:34:13so here's the thing you i think it's
- 4:34:15because it's a jump start and it's
- 4:34:17tutorial
- 4:34:17um like why do we have this dollar sign
- 4:34:20some people like i hate the dollar sign
- 4:34:21blah blah blah
- 4:34:22well here's why so when we say dollar
- 4:34:24sign my var
- 4:34:27equals get service
- 4:34:31service bits okay right just works right
- 4:34:34but what happens if i do this
- 4:34:37right some people like i don't like
- 4:34:39dollar signs okay fine what happens
- 4:34:42and the answer is an error but look at
- 4:34:43the error the term myvar
- 4:34:46is not recognized as the name of a
- 4:34:48commandlet
- 4:34:50okay so so when you start a command
- 4:34:53when you start a line with a name
- 4:34:56the question is well is it a variable or
- 4:34:58is it a command line right
- 4:34:59and we have to know and so that's why we
- 4:35:02have dollar signs in front of our
- 4:35:03variables because you have to know
- 4:35:05and this remember i talked about the
- 4:35:06struggle between interactive programming
- 4:35:09and
- 4:35:09and systems programming this was the key
- 4:35:11thing that
- 4:35:12interactive commands uh have require a
- 4:35:15special syntax
- 4:35:16in programs you're not running things
- 4:35:18out of the file system
- 4:35:19right right you're running you know apis
- 4:35:22and such
- 4:35:23in an interactive shell you run things
- 4:35:24out of the command so so when you type
- 4:35:26ping you just want ping to work you
- 4:35:28don't want to have to say
- 4:35:30oh well i want to do something special
- 4:35:31for ping
- 4:35:33so that's why you just type ping
- 4:35:36right but if you want dollar sign ping
- 4:35:39to be
- 4:35:40x you type dollar sign ping that's why
- 4:35:44we have the dollar sign that's it
- 4:35:45no and that's actually very important
- 4:35:47everybody's always asking about the
- 4:35:48dollar sign so when you're working with
- 4:35:49vars
- 4:35:50you got to have the dollar sign now a
- 4:35:52couple of little things a little uh
- 4:35:54um oh let's let's play with since we're
- 4:35:57getting ready for scripting we're going
- 4:35:58to take this concept of using a var and
- 4:36:00try something here let's uh watch
- 4:36:02this let's see uh there's a commandlet
- 4:36:04called read host
- 4:36:06it'll actually read things from the host
- 4:36:10the host so let me see dollar sign var
- 4:36:13equals
- 4:36:13read host so whatever we read in is
- 4:36:16going to get stored in the variable and
- 4:36:17i'm gonna say
- 4:36:18enter a computer name now guys you can
- 4:36:21imagine
- 4:36:22this in a script already because watch
- 4:36:24what happens i'm gonna strike enter
- 4:36:25comes up says enter a computer name
- 4:36:26okay i'll enter one now what's stored in
- 4:36:30var right now
- 4:36:32is that computer name you can now use
- 4:36:34that variable
- 4:36:35which is where we're going with all this
- 4:36:37get service
- 4:36:38name bits dash computer name dollar sign
- 4:36:41var
- 4:36:42guess where we're going to go get that
- 4:36:44information from now
- 4:36:45so we're going out to that that that
- 4:36:48that the dc in this case
- 4:36:50so we're storing stuff in the vars and
- 4:36:52then we're going to use those vars
- 4:36:53in our commands with our parameters as
- 4:36:55part of the arguments
- 4:36:57this is going to start us making better
- 4:36:59scripts and being able to do automation
- 4:37:01a little bit better
- 4:37:03but i want to show you just a couple of
- 4:37:04quick things because you're going to
- 4:37:06hear this and you're going to see this a
- 4:37:07lot and i just have to throw it out
- 4:37:09because
- 4:37:10i'm kind of i want to ask about it so
- 4:37:13dollar sign var if i do this it just
- 4:37:15prints it to the screen but we actually
- 4:37:16have a commandlet
- 4:37:18that were is designed to print things to
- 4:37:20the screen for you
- 4:37:21um let's do uh write host real quick
- 4:37:24you're going to see this a lot right
- 4:37:25host dollar sign var
- 4:37:27same result except right host has things
- 4:37:29like foreground color
- 4:37:30red background color green
- 4:37:34yay you can play with the colors
- 4:37:36everybody just got really excited
- 4:37:37because now they can play with colors
- 4:37:38yeah start playing with colors um we
- 4:37:42have ways for you to play with colors
- 4:37:43and i
- 4:37:44you probably have heard the phrase every
- 4:37:47time and
- 4:37:47every time you use write host
- 4:37:50god kills a puppy
- 4:37:53so don't use right house no i i want to
- 4:37:56be straight with you
- 4:37:57there are times to use write host it's
- 4:37:59just i want you to see
- 4:38:00what you're doing and when you start
- 4:38:02scripting this really starts to matter
- 4:38:04yeah
- 4:38:04dollar sign var watch what i'm going to
- 4:38:06do i'm going to pipe this to get member
- 4:38:09you would expect
- 4:38:10a result at this point look at what i'm
- 4:38:13getting
- 4:38:14i get no object has been specified in
- 4:38:16other words
- 4:38:17nothing went across the pipeline right
- 4:38:19host just
- 4:38:21destroyed everything that i've been
- 4:38:23working
- 4:38:24so hard for with objects right host has
- 4:38:27annihilated it by the way notice it
- 4:38:29showed dc on the on the coast
- 4:38:31yeah because it actually wrote it out to
- 4:38:34the house yes
- 4:38:35but there was nothing going down the
- 4:38:37pipeline and the point is we want stuff
- 4:38:38going on the pipeline
- 4:38:40so with right host we have a command
- 4:38:43that watch this
- 4:38:44write output dollar sign var
- 4:38:48and it does the exact same thing but
- 4:38:51it's doing it through the pipeline look
- 4:38:53get member look at what i got
- 4:38:56i got a real object that's crossing
- 4:38:57across there now
- 4:39:00so it matters but everybody says well
- 4:39:02you lost the ability to make colors
- 4:39:04get over the color thing we don't here's
- 4:39:07the deal we have ways for you to make
- 4:39:09colors
- 4:39:09properly you've noticed that powershell
- 4:39:11has a built-in color scheme
- 4:39:13that it uses and as you start to script
- 4:39:15this is going to become
- 4:39:16real paramount as admins we get used to
- 4:39:19certain colors
- 4:39:20popping up so in powershell we've
- 4:39:22included commandlets to use the existing
- 4:39:24color scheme if you just play along
- 4:39:26it'll all be good such as i want to
- 4:39:29write
- 4:39:30a warning please
- 4:39:34don't do that
- 4:39:37look it comes up as a powershell warning
- 4:39:40the yellow on black so it makes
- 4:39:41sense to my brain because i've seen
- 4:39:43those warnings before or things
- 4:39:45that i need to care about i didn't have
- 4:39:46to go through and use right host and
- 4:39:48come up with my own color scheme
- 4:39:50and of course we give you things like
- 4:39:51write error and there's other stuff that
- 4:39:54we have but right error being one
- 4:39:55stop touching me and
- 4:39:59now it looks like a power shell error
- 4:40:01message and i've generated the error and
- 4:40:03it's in the same color scheme in the
- 4:40:05same format so you don't need write host
- 4:40:07most of the time if you want to put
- 4:40:09something on the screen in a different
- 4:40:10color great but try to stick with right
- 4:40:12output and the other right
- 4:40:14commands that we give you to write
- 4:40:16things out to the screen especially when
- 4:40:18you're working with your
- 4:40:19your vars because right host couldn't
- 4:40:21can be
- 4:40:22somewhat problematic you know i'm
- 4:40:24checking this is very analogous to what
- 4:40:26i mentioned about the console
- 4:40:28remember i said i'm trying to kill off
- 4:40:30the console because i'm trying to kill
- 4:40:32off console apps
- 4:40:33because apps that write directly to the
- 4:40:35console can't be
- 4:40:36automated they are the enemy of
- 4:40:38automation right host is another flavor
- 4:40:40of a console app is another flavor of a
- 4:40:43console app so don't do it by the way
- 4:40:44there are times there are times we have
- 4:40:46a special
- 4:40:47like dispensation for people who are
- 4:40:50trying to to do this here's the key
- 4:40:52thing
- 4:40:52your say you want to write a script that
- 4:40:54was well formatted and had colors and
- 4:40:56all that good stuff that's fine
- 4:40:57but use the word show okay whenever you
- 4:41:00see the word
- 4:41:01show you should hear in your head ah
- 4:41:04i'm not going to be able to program or
- 4:41:06script the output of that
- 4:41:08so that's perfectly fine but just make
- 4:41:10sure you use the right term
- 4:41:11show right and then and yes most of the
- 4:41:15time just don't use right house
- 4:41:16okay okay just just don't do it it's
- 4:41:18because you like dogs
- 4:41:20it's because i like dogs and and i have
- 4:41:23to give don jones credit for that phrase
- 4:41:25who uses
- 4:41:26that all the time so let's do something
- 4:41:28kind of fun and kind of exciting at this
- 4:41:30point i
- 4:41:31i i think that's because you show them
- 4:41:32the squiggle brackets
- 4:41:34uh-huh the squiggle brackets you want to
- 4:41:36show them the variables with the
- 4:41:36squiggle brackets yeah
- 4:41:38really that's awesome here i'll do it
- 4:41:40it's okay here's me okay you're doing so
- 4:41:42here's the thing
- 4:41:43hey what can i do like hey this you know
- 4:41:45is this an anglo-centric english thing
- 4:41:47and the answer is no no no my friends
- 4:41:49like let's say you want to have you can
- 4:41:51put
- 4:41:51you can you have variables of any sort
- 4:41:53of names including spaces right
- 4:41:55so you can say hey this is a
- 4:41:58test equals four right
- 4:42:01and then this is a test
- 4:42:04it's four is that cool now check this
- 4:42:06out you can have anything you want in
- 4:42:08here right
- 4:42:09oh sorry get the wrong thing what the
- 4:42:11heck was that
- 4:42:12oh that wasn't good what did i do
- 4:42:16oh good lord help help help help me help
- 4:42:18me
- 4:42:20no i oh here we go
- 4:42:24there we go there that's what i meant to
- 4:42:27do
- 4:42:27okay there you go that's really weird
- 4:42:31wow whoa
- 4:42:34okay so now look that's the name of my
- 4:42:37variable oh did i screw that up i did
- 4:42:39screw that up
- 4:42:40oh no i did equals okay so that's the
- 4:42:43name of my variable is that crazy or
- 4:42:45what
- 4:42:45that's crazy but here it gets a little
- 4:42:47bit cooler
- 4:42:48because we draw this distinction between
- 4:42:50the syntax of a variable and the
- 4:42:51semantics of the variable
- 4:42:53so here the syntax is just showing you
- 4:42:55um
- 4:42:56it's a container and i i mentioned you
- 4:42:58could put any very
- 4:42:59any parameter you want you can use sorry
- 4:43:02any uh
- 4:43:03character you want you can using unicode
- 4:43:05etc it's not entirely true
- 4:43:07there's a special character and that is
- 4:43:10the colon character
- 4:43:11so let me make sure here's where i am
- 4:43:13imagine i do this imagine i do
- 4:43:151.5 okay and then i'm going to put that
- 4:43:18in a file
- 4:43:19test dot txt okay
- 4:43:22so now imagine watch this c colon
- 4:43:26jumpstart test.txt
- 4:43:32so look at that so i did dollar sign
- 4:43:35my parameters and i gave a file path
- 4:43:39and i get the value
- 4:43:42of the file so you're basically saying
- 4:43:45call and do this
- 4:43:46well it is hey this dollar sign syntax
- 4:43:50basically says where do i store my data
- 4:43:52and in general the way we think of
- 4:43:54variables is well you store data in
- 4:43:55memory somewhere and when the process
- 4:43:58goes away
- 4:43:59well that goes away right we'll look
- 4:44:01here look here look here
- 4:44:03wait a second so now i get a second
- 4:44:05command and i can say
- 4:44:07dollar sign c colon
- 4:44:12jump start slash test
- 4:44:17test.txt i did squiggle brackets
- 4:44:26slash slash
- 4:44:29i can get it there now wait so wait so
- 4:44:32equals
- 4:44:41i go to this machine and now
- 4:44:44so now i've got variables that cross
- 4:44:47cross
- 4:44:48that's awesome that is totally awesome
- 4:45:07[Music]
- 4:45:16so when we're doing remoting yes and
- 4:45:18remember in vote command we're now going
- 4:45:19to use the alias
- 4:45:20icm for this just to abbreviate things
- 4:45:24we're actually starting a remote
- 4:45:26powershell session
- 4:45:28yeah like you said we're feeding it a
- 4:45:31command
- 4:45:33then we're closing that powershell
- 4:45:35session and
- 4:45:36leaving right so we start a tcp
- 4:45:38connection tcp we start a process
- 4:45:41we load the clr we load powershell
- 4:45:44we initialize powershell we run all your
- 4:45:47profiles that can be up to four profiles
- 4:45:50we run those and when those are all
- 4:45:51ready then we take the code
- 4:45:54we execute it and we throw all that away
- 4:45:56and then we throw everything away so
- 4:45:58you this is important when you're using
- 4:46:00remoting we're going to connect to that
- 4:46:02box we're going to
- 4:46:03start all this stuff up we're going to
- 4:46:04climb up this mountain we're going to
- 4:46:06give it your
- 4:46:06little tiny code do that
- 4:46:09and then we have to tear all this down
- 4:46:12and walk away
- 4:46:13you can imagine that if you're going to
- 4:46:14do a lot of invoke commands in a row
- 4:46:17that's not very efficient so there's a
- 4:46:20way we can make this more efficient and
- 4:46:21i want to demonstrate it using variables
- 4:46:23first and then
- 4:46:24we'll take a look at some cool things
- 4:46:25that we can do with this so watch guys
- 4:46:27i'm going to go to
- 4:46:28i'm just going to do this on dc first
- 4:46:30and what i'm going to do is
- 4:46:31i'm going to show you what's happening
- 4:46:33i'm going to do dollar sign var equals
- 4:46:352.
- 4:46:36now think this through i'm going to go
- 4:46:38to the domain controller i'm going to
- 4:46:39start up powershell i'm going to
- 4:46:41set a variable and then i'm going to
- 4:46:44destroy powershell
- 4:46:45so what happens is is if i now ask it
- 4:46:49what's that variable on output
- 4:46:53on uh on dc well is anybody shocked that
- 4:46:58it's not there anymore when the console
- 4:47:00dies everything dies
- 4:47:02this is why powershell has to run all
- 4:47:03the time so nothing dies
- 4:47:05but no when the new console dies when
- 4:47:07that execute when powershell exe on the
- 4:47:10other side dies everything dies with it
- 4:47:12what i'd really like to do
- 4:47:15is i'd like to be able to connect to the
- 4:47:16machines go through starting all this up
- 4:47:19and leave it up yeah yeah i'm in you in
- 4:47:22for this yeah so we call those things
- 4:47:25sessions sessions you'd like to create a
- 4:47:27powershell session
- 4:47:28we're going to create a power so watch
- 4:47:30let's create the powershell session so
- 4:47:31what i'm going to do is i'm going to set
- 4:47:32this equal to a variable called
- 4:47:34sessions equals new
- 4:47:37ps session now i'm going to specify the
- 4:47:40computer and right now i'm just going to
- 4:47:41keep it real simple i'm just going to
- 4:47:42use
- 4:47:43the dc right now so what happens is that
- 4:47:46i've created a session
- 4:47:48that's going to keep powershell running
- 4:47:50on that remote machine now i'm only
- 4:47:52doing it to one machine right now but
- 4:47:54it's on that remote machine just to show
- 4:47:56you we have a command for get ps session
- 4:47:58that will show you what sessions you
- 4:47:59have notice
- 4:48:01got a session to that computer it's open
- 4:48:04life is good what i can do now is start
- 4:48:07using invoke command and instead of
- 4:48:08using dash computer name i can specify
- 4:48:10that i want to use
- 4:48:12this session so icm we're going to do
- 4:48:15the exact same example again so let me
- 4:48:17just go ahead and clear the screen here
- 4:48:18and i'm going to do icm
- 4:48:21computer oh no not a computer yeah
- 4:48:24dollar sign sessions of course i had to
- 4:48:25make it long and easy hard to type
- 4:48:27and i'm going to do the same thing var
- 4:48:29equals 2
- 4:48:31and this time i'm going to go back and
- 4:48:34check on it
- 4:48:38fast fast fast fast fast fast and this
- 4:48:40now gives us a lot of power to do a lot
- 4:48:42of
- 4:48:42really really cool things so we can keep
- 4:48:46this session open and we continuously
- 4:48:47fire things we can reference variables
- 4:48:49that we have open
- 4:48:50this is going to make our lives a lot
- 4:48:52easier um happy happy happy
- 4:48:54happy happy happy i can't show them the
- 4:48:55difference in time yeah yeah
- 4:48:57okay do you do measure commit you know
- 4:48:59measure command yeah do measure command
- 4:49:01on
- 4:49:02just invoke command minus command name
- 4:49:03or my computer name
- 4:49:05oh you want to see the difference in
- 4:49:07time oh yeah i wonder if that would
- 4:49:08you think it's going to be apparent here
- 4:49:09computer named dc yeah
- 4:49:11and do get process oh get process yeah
- 4:49:14that's good get process
- 4:49:15and then screw it and then uh no no no
- 4:49:18you put wrap that whole thing in a
- 4:49:19script block
- 4:49:20and put measure command at the beginning
- 4:49:26measure measure command
- 4:49:31so what's happening here is that the
- 4:49:33measure command is going to take what
- 4:49:34we're running
- 4:49:35and so you can see what it's doing is
- 4:49:37that it's it's showing us how long this
- 4:49:39is taking
- 4:49:40yeah i love text um but anyways
- 4:49:42milliseconds
- 4:49:43eight eight six milliseconds now do it
- 4:49:45with a session
- 4:49:47so let's do the same thing so i'm going
- 4:49:49to just do measure command let's just do
- 4:49:50up arrow man
- 4:49:51oh yeah me and my up arrows
- 4:49:54down one there now change computer name
- 4:49:58dc
- 4:49:58to okay let's do that it says 886
- 4:50:02886 to session dollar sign sessions
- 4:50:09five oh probably even faster but it's
- 4:50:12yeah it's going to actually be faster
- 4:50:14and here's the thing
- 4:50:15it is faster doing it this way um
- 4:50:18but now when it's really going to pay
- 4:50:20off being faster
- 4:50:22want to see something cool yeah yeah i'm
- 4:50:24going to draw okay
- 4:50:26watch wow this is when sessions and
- 4:50:29remoting
- 4:50:30change your world so i want to prove to
- 4:50:32you that i'm not lying to you
- 4:50:33so first of all i'm going to kill
- 4:50:35everything so you know that i'm not i'm
- 4:50:36going to kill the shell oink and i'm
- 4:50:38going to bring up a new one
- 4:50:39really that way you know that i've got
- 4:50:41clean shell i'm not hiding no no
- 4:50:43not rabbits nothing up sleeves anything
- 4:50:45like that here we go
- 4:50:47quick demonstration but see if you catch
- 4:50:49what's going to happen here first of all
- 4:50:50dollar signs servers
- 4:50:52equals who let's do s1
- 4:50:55and s2
- 4:50:58so you guys know in dollar sign servers
- 4:51:01well here
- 4:51:02you know cool
- 4:51:05watch i'm going to show you that i'm not
- 4:51:07cheating nothing's being hidden here
- 4:51:09start uh
- 4:51:11[Music]
- 4:51:12let me do it this way dollar sign
- 4:51:14servers
- 4:51:18coffee oh yeah um dollar sign servers
- 4:51:21and watch watch i'm gonna use a command
- 4:51:24called for each and what this is gonna
- 4:51:26let me do
- 4:51:27is iterate through each one of those
- 4:51:29coming across the pipeline so
- 4:51:30you know it's in dollar sign servers i
- 4:51:32got two computer names
- 4:51:34i want to grab the current one across
- 4:51:36the pipeline
- 4:51:37and use it in a special way so what i'm
- 4:51:38going to do is start http oops start i
- 4:51:42explore
- 4:51:45http dollar sign underscore think about
- 4:51:49this for a second guys here's what i'm
- 4:51:50going to do is
- 4:51:50start up i explore for each one of these
- 4:51:53and make it go to those servers to show
- 4:51:55you that there's no websites there
- 4:51:57there's no
- 4:51:58default web pages it's just going to
- 4:51:59come up and it's going to give me an
- 4:52:01error
- 4:52:01this can't be displayed all right so
- 4:52:04that's not that big of a deal but i just
- 4:52:06want you to see that i'm not hiding
- 4:52:07anything
- 4:52:08so now let's do a session and let's do
- 4:52:11something cool
- 4:52:12abandoned session let's just type dollar
- 4:52:15sign yes
- 4:52:16yeah you're right i type in way too much
- 4:52:18um equals new
- 4:52:20ps session and what we've done and what
- 4:52:22i want to do it to is
- 4:52:24dollar sign servers boom i'm going to
- 4:52:27get my sessions to these remote boxes
- 4:52:29now so just so that you see i'm not
- 4:52:31cheating multiple sessions
- 4:52:33multiple sessions you know what i want
- 4:52:35to do and this was an actual business
- 4:52:37problem that i've had several
- 4:52:38times um did i mention i was a web guy
- 4:52:39i'm just saying anyways um
- 4:52:41so here's the business problem i need to
- 4:52:43deploy
- 4:52:44uh actually i had a friend call me up on
- 4:52:46the phone um i need to deploy a web
- 4:52:4950 server website load balanced and i
- 4:52:53need to copy the website out from the
- 4:52:55developers and we have three months to
- 4:52:57do it
- 4:52:57can powershell help me with any of this
- 4:53:01seriously dude when's the last time you
- 4:53:04had a vacation
- 4:53:06well this conversation went on for a
- 4:53:07while me talking about vacations and him
- 4:53:09talking about this three month long
- 4:53:10project
- 4:53:13let's do it so with the session that we
- 4:53:16have
- 4:53:16three months what's that we only have
- 4:53:18like a couple hours
- 4:53:20throughout three months well let's okay
- 4:53:22okay
- 4:53:23okay so you want to challenge me okay
- 4:53:25fine okay fine so
- 4:53:26invoke command on the session that i
- 4:53:28just made which now is shorter dollar
- 4:53:30sign s
- 4:53:31here's what i want to do install windows
- 4:53:34feature
- 4:53:35web dash server now i know guys this
- 4:53:37isn't gonna be all that cool and tricky
- 4:53:39but
- 4:53:39um here's the thing uh for web services
- 4:53:42every component that you need of the web
- 4:53:44service
- 4:53:45you can just put in comma and specify
- 4:53:47every single one
- 4:53:48this doesn't have to be web servers this
- 4:53:49could be hyper-v servers this could be
- 4:53:51whatever it is you need deployed and i
- 4:53:54want you to see that it's happening
- 4:53:59that it pretend that the sessions for
- 4:54:02dollar sign s
- 4:54:03was 50 servers a thousand servers
- 4:54:07now take a look comes up and as it shows
- 4:54:09me as it's finishing the installation on
- 4:54:10those remote boxes
- 4:54:12and i'm maintaining this session so that
- 4:54:13i can still do it it's not
- 4:54:15serial it does it in parallel yeah it
- 4:54:17does it in parallel
- 4:54:18so what's happening is is that it's not
- 4:54:20going to this server
- 4:54:21and then going to this no it's going
- 4:54:23dudes install
- 4:54:27come on we're talking less than four
- 4:54:29minutes i've just deployed
- 4:54:31as many web servers as i want but wait
- 4:54:33we're not done
- 4:54:34watch there's more watch i'm just gonna
- 4:54:37up arrow
- 4:54:39for once and go back to this command
- 4:54:42watch oh oh come on
- 4:54:45oh i got oh come on yeah
- 4:54:48but wait there's one more step you guys
- 4:54:50we got to make our own web page right we
- 4:54:51got to make our own web page
- 4:54:57so three runs baby we're gonna make our
- 4:54:59own web page real quick just to prove
- 4:55:01that you can still do this uh yeah i
- 4:55:02just make this uh default htm and when
- 4:55:04students say
- 4:55:05mva and powershell
- 4:55:09rocks i'm going to save this i want to
- 4:55:12deploy this
- 4:55:14i want to deploy this so i'm going to
- 4:55:16dollar sign
- 4:55:17servers pipe for each
- 4:55:20one of those servers i'm going to have
- 4:55:23it
- 4:55:24copy item god i love i love i love the
- 4:55:28item commands to it to work with stuff
- 4:55:30because we're going to take that default
- 4:55:32htm and
- 4:55:34the coolest thing about powershell
- 4:55:36commandlets is they give you more
- 4:55:37capabilities you've ever had before
- 4:55:39because the destination
- 4:55:40can be a unc so i'm going to say
- 4:55:44backslash backslash dollar signup
- 4:55:46remember that's the current object
- 4:55:48that'll be
- 4:55:48those servers and i want it to go to
- 4:55:50their administrative share
- 4:55:52and i want it to go to inet pub
- 4:55:56this is where the default web page is is
- 4:55:58stored
- 4:55:59and
- 4:56:03and let's go up and run it again and lo
- 4:56:06and behold
- 4:56:08so aruba we're going it's vacation
- 4:56:12time now so in other words in just a
- 4:56:14couple of minutes i've deployed
- 4:56:15out in this case a web server and a
- 4:56:18website it's a small demonstration but
- 4:56:20the idea is this
- 4:56:22it changes how you think about
- 4:56:23administration now it's
- 4:56:25instead of sending guys out going uh go
- 4:56:27out there and install this and install
- 4:56:29that and
- 4:56:30let me know when you're done in three
- 4:56:32months now it's get somebody with a
- 4:56:34screwdriver to rack and drag these
- 4:56:35things
- 4:56:36as soon as they're powered up i'm going
- 4:56:37to remote into these things install what
- 4:56:38they need
- 4:56:39i'll probably script it so i never have
- 4:56:41to actually type these four commands
- 4:56:43again
- 4:56:43and boom it's done
- 4:56:46and now that i've got the script if i
- 4:56:48need to add more just add some more
- 4:56:50add some more or give it to me because i
- 4:56:53have a problem and you give it to me and
- 4:56:55i just do it give it to you like it
- 4:56:56might be more complex like i really
- 4:56:58don't understand this web stuff and i
- 4:56:59say
- 4:57:00oh i have this problem and you can say
- 4:57:02hey jeffrey here's a script i have i
- 4:57:04look and i said
- 4:57:05minus what if yeah do it off to a robot
- 4:57:09i mean that's the thing i think that is
- 4:57:11is some people just sort of don't get
- 4:57:13until they get it
- 4:57:14and that is the transformational effect
- 4:57:17of these technologies
- 4:57:18remoting in particular the fact that all
- 4:57:20of a sudden you're able to do
- 4:57:21just phenomenal things massive things
- 4:57:26in a heartbeat things that your boss is
- 4:57:28probably thinking
- 4:57:29i'm just not even going to ask because
- 4:57:30that's going to take so long
- 4:57:32we don't do things and so you end up
- 4:57:34with a sort of static
- 4:57:36brittle ossified excuse me ossified i.t
- 4:57:39data i.t processes and structures
- 4:57:42all of a sudden now with these tools you
- 4:57:44can become fast
- 4:57:46you can become flexible you can become
- 4:57:48agile you can do things you never
- 4:57:50thought of doing before
- 4:57:51all because of the power of powershell
- 4:57:54well it really is transformational it is
- 4:57:55transformational and also
- 4:57:57my cto doesn't like the answer it's
- 4:58:00going to take three months
- 4:58:02he really likes it when i give him the
- 4:58:04answer of
- 4:58:05it'll be done within the hour as a
- 4:58:07matter of fact it's done now i'm just
- 4:58:09testing
- 4:58:09yeah i mean that's the whole point to
- 4:58:12this is that your management totally
- 4:58:14changes
- 4:58:14not only in scale but what's that or
- 4:58:16like that guy i'll have a tea in the
- 4:58:18morning
- 4:58:18i'm going home yeah i'm going home
- 4:58:20that's the whole thing
- 4:58:21now one other thing i'm remoting that we
- 4:58:23want to show you right now we're
- 4:58:24promoting like
- 4:58:26uh
- 4:58:28[Music]
- 4:58:31there's one other super cool thing in
- 4:58:33remoting that we want to show you before
- 4:58:34we get into the rest of scripting
- 4:58:36and i have to do it with a new console
- 4:58:42you know i don't i'm not going to be at
- 4:58:45this machine
- 4:58:46tomorrow oh oh and i you know what in
- 4:58:50fact
- 4:58:50when i'm out on vacation and i'm using
- 4:58:53powershell web access who knows you know
- 4:58:55i'm going to be at
- 4:58:57some box and the thing is is that guys
- 4:58:59i've been using active directory
- 4:59:01commandlets i've been using all kinds of
- 4:59:02stuff from modules that are
- 4:59:04installed for the remote server
- 4:59:06administration tools and
- 4:59:08you know if i want to manage exchange i
- 4:59:10i need the remote server administration
- 4:59:11tools i
- 4:59:12am going to need to install the exchange
- 4:59:14management tools
- 4:59:16and i do a lot of scvmm stuff i'm going
- 4:59:18to need to install
- 4:59:20oh man all the vmm management tools
- 4:59:23god's going to take me a couple hours to
- 4:59:25do that
- 4:59:26and as soon as i go to a different
- 4:59:28machine
- 4:59:30and none of the commands none of the
- 4:59:32modules will be there none of it exists
- 4:59:34so i want to show you what i think is
- 4:59:36not is is absolutely the coolest thing
- 4:59:38in the world i use it constantly because
- 4:59:40on my box
- 4:59:42i don't install anything i don't install
- 4:59:43the remote server administration tools
- 4:59:44the exchange so it's nothing
- 4:59:46and here's the reason why put your seat
- 4:59:48belts on because this
- 4:59:49is freakish freakishly powerful
- 4:59:52this is this is this is the new world or
- 4:59:54order because here's the deal i don't
- 4:59:56have time to be installing tools
- 4:59:58every time i sit down in a box and the
- 4:59:59other thing is if i walk up to a server
- 5:00:01or something like that
- 5:00:03you're not going to be installing
- 5:00:04anything on there so i need a bunch of
- 5:00:06commandlets we're gonna
- 5:00:07i'm gonna need the active directory
- 5:00:08command i don't know why i'm starting to
- 5:00:10do it like this but it's kind of like
- 5:00:11watching
- 5:00:11godfather yeah it's like watching god i
- 5:00:13don't know what i'm doing um
- 5:00:15you call me funny yeah it's funny i'm
- 5:00:18funny funny
- 5:00:19you say you got powershell you just
- 5:00:20stick down you know so here we go
- 5:00:24so what i'm going to do is i'm going to
- 5:00:25create a session to the
- 5:00:27servers that have the commandlets that i
- 5:00:29want now think about this
- 5:00:32you really want the commandments from
- 5:00:34the servers that
- 5:00:36naturally have them a domain controller
- 5:00:38has the active directory commandments
- 5:00:39an exchange 2007 server has the
- 5:00:43exchange 2007 command let's an exchange
- 5:00:462010 server has the exchange 2010 ones
- 5:00:49i couldn't get all those tools on my box
- 5:00:51if i wanted to
- 5:00:52but watch and you don't want to and you
- 5:00:55don't want to so dollar sign s
- 5:00:56equals new ps session and in this case
- 5:00:59i'm going to uh
- 5:01:00i'm just going to hit a domain
- 5:01:01controller
- 5:01:03so i'm gonna establish a session to this
- 5:01:05domain controller
- 5:01:07import um ps session
- 5:01:12module guys do you see what i'm doing
- 5:01:15there's a module on that remote server
- 5:01:17called active directory so i'm going to
- 5:01:19say
- 5:01:19give me that module active directory
- 5:01:22now because i right now on this vm
- 5:01:26i do have the rsat tools i'm going to
- 5:01:27prefix this so there's a prefix and i'm
- 5:01:29going to call it remote so you know it's
- 5:01:31coming from somewhere else
- 5:01:32then we're going to ask jeffrey how to
- 5:01:34explain how this magical stuff works
- 5:01:36because watch as soon as i do this
- 5:01:39to oops i forgot to give it the session
- 5:01:42darn dollar sign s i was going to do it
- 5:01:44all in one line and i screwed it up i
- 5:01:45forgot the session
- 5:01:47oh yeah no you can't that's a string oh
- 5:01:49it's
- 5:01:50yeah so let me do this you see dollar
- 5:01:52sign session there we go
- 5:01:53way back machine you didn't see that
- 5:01:55click click click ben and black
- 5:01:56men in black men in black so module
- 5:02:01session dollar sign ass
- 5:02:06i don't know if you know what just
- 5:02:07happened right now but check this out
- 5:02:09i wonder if i have any command let's now
- 5:02:11pretend that i had no active directory
- 5:02:13command so what we're going to do is i
- 5:02:14wonder if i have anything for remote
- 5:02:16remote remote remote room ah let's do
- 5:02:18this remote um
- 5:02:20a.d should work
- 5:02:24dudes do dude that's ducey's you see
- 5:02:26what's scrolling across my screen right
- 5:02:27now
- 5:02:28looks and smells like i suddenly have
- 5:02:30all these commandlets i just asked for
- 5:02:31look at all these active directory
- 5:02:32commits yes they're prefixed with remote
- 5:02:34so
- 5:02:35i have these command matter of fact i
- 5:02:36can do this watch get
- 5:02:38remote a d computer
- 5:02:42filter fiddler
- 5:02:45yeah this is brother anyways the star
- 5:02:49so look it ran look at this look look
- 5:02:52look
- 5:02:53i got these commands from a server it's
- 5:02:55nothing's installed how is this working
- 5:02:56explain to me how this is working
- 5:02:58because this is like freaking me out
- 5:02:59right now it's magic baby i love
- 5:03:01magic so here's the deal um here let me
- 5:03:04show you this
- 5:03:05so here we've been showing people get
- 5:03:08command
- 5:03:09or sorry get help get help but get help
- 5:03:12get help
- 5:03:12get process okay
- 5:03:16and that gives you this but there's
- 5:03:18another thing that's called get
- 5:03:20command and people have often asked well
- 5:03:22what's the difference between these two
- 5:03:23get help versus get command and the
- 5:03:25answer is that get command
- 5:03:27is more structural programmatic
- 5:03:30information so watch this dollar sign
- 5:03:32c dollar signs hello oh wrong one
- 5:03:36i'll assign c equals get command dollar
- 5:03:38sign c dot
- 5:03:39parameters okay and then let's take a
- 5:03:42look at this parameter
- 5:03:43say name oops sorry name
- 5:03:48okay and look we've got all the
- 5:03:49information the name its type etc yeah
- 5:03:52okay
- 5:03:53and so what happens is when i go and
- 5:03:56i do that import what i do is i go to
- 5:03:59that remote machine
- 5:04:00i load the module that you asked for and
- 5:04:03i do a get command on all the things
- 5:04:06and i get that data structure and what i
- 5:04:08do is on this side on now on
- 5:04:10on my side i go and i take that
- 5:04:13information
- 5:04:14and i recreate a set of scripts with
- 5:04:16exactly the same signature
- 5:04:19and then the body of the function
- 5:04:21basically says hey when you go do this
- 5:04:23gather all that stuff up and run it over
- 5:04:26there
- 5:04:26using invoke command i don't actually
- 5:04:29have these commandlets
- 5:04:30on my machine i have a a a like a
- 5:04:33proxy yeah or or a shortcut
- 5:04:37that is saying take all the information
- 5:04:39from the parameters and then go run it
- 5:04:40on the desk
- 5:04:41the source machine exactly so do this do
- 5:04:43on your machine now
- 5:04:44type get command get command get dash
- 5:04:48star 80 computer get dash
- 5:04:51star 80 computer
- 5:04:56okay so look notice one the get 80
- 5:04:59computers commandlet now that
- 5:05:00that command net code okay okay but look
- 5:05:04at the function
- 5:05:06so now take a look and do this uh type
- 5:05:10parentheses paren get command
- 5:05:14get remote 80 computer
- 5:05:17get remote ad computer and
- 5:05:21print dot definition
- 5:05:24ah definition will it ah
- 5:05:28yeah so look at this this was
- 5:05:30dynamically generated
- 5:05:31code dynamically generated code on my
- 5:05:35side
- 5:05:35on your side that says grab these
- 5:05:37parameters oh so you know what let me
- 5:05:39just say
- 5:05:39in in powershell version two was a
- 5:05:42pivotal technology
- 5:05:43in powershell version one uh uh
- 5:05:45commandlets
- 5:05:47had to be.net in powershell version two
- 5:05:50we said commandlets could be dotnet
- 5:05:53or powershell itself okay so now
- 5:05:57powershell scripts are full commandlets
- 5:06:00which you're going to see in a little
- 5:06:01bit guys now this was a
- 5:06:03transformational technology because what
- 5:06:04it means is now the sudden
- 5:06:06you can write programs which generate
- 5:06:09commandlets
- 5:06:10dynamically and that's what we do here
- 5:06:12that's what that import ps session does
- 5:06:15we go and we get a data structure we
- 5:06:17have a program that
- 5:06:18dynamically generates a powershell
- 5:06:21script
- 5:06:22that has exactly the same signature as
- 5:06:25the
- 5:06:25net commandlet on the remote machine has
- 5:06:28exactly the same signature
- 5:06:30i gather up all that information and i
- 5:06:32then
- 5:06:33run it on the remote machine and i think
- 5:06:35what the is so to make sure the concept
- 5:06:37is good
- 5:06:38is that we're just like jeffrey said
- 5:06:40this is
- 5:06:41it looks and tastes and feels like the
- 5:06:43commandlets are here on my machine but
- 5:06:45they're not they're functions that are
- 5:06:47going back and running it on the remote
- 5:06:49machine
- 5:06:49so think about this who's going to be
- 5:06:51better at running get ad computer
- 5:06:53anyways your box or the domain
- 5:06:56controller
- 5:06:57so first of all that's going to be
- 5:06:59faster but you know you were telling me
- 5:07:00about this scenario and
- 5:07:02i i love this scenario about the guy who
- 5:07:04had to do a migration from exchange
- 5:07:06yeah of of um i had to
- 5:07:09do a migration from exchange 2007 to
- 5:07:12exchange 2010.
- 5:07:13you're not going to get those tools all
- 5:07:16installed on your box
- 5:07:17but you can import both sets of
- 5:07:20commandlets
- 5:07:21prefix one with 2007 prefix another with
- 5:07:242010
- 5:07:25now you got both sets of commandlets all
- 5:07:27in the same place
- 5:07:28and you can get the two products to work
- 5:07:30together exactly it was doing the
- 5:07:31equivalent of like
- 5:07:32get uh like i'll just say v1 v2 get v1
- 5:07:36uh user pipe to set v2 user
- 5:07:40right and what's happening is he's on
- 5:07:41this box he's getting the
- 5:07:43users from this machine and he's setting
- 5:07:45them on that machine and this is the
- 5:07:46power of this stuff now
- 5:07:48all of a sudden i mean it used to be
- 5:07:49that integration was just
- 5:07:51painful right i got to find all this
- 5:07:53stuff i got to get it all in this box so
- 5:07:55it bloats the box i'm
- 5:07:57running out of disk space oh wait this
- 5:07:59guy updated something i got gotta patch
- 5:08:01it
- 5:08:02oh wait they require different versions
- 5:08:04of stuff
- 5:08:05just hideous idiots videos and now the
- 5:08:08answer is
- 5:08:09hey dude i'm sitting right here i import
- 5:08:11the stuff from there i import the stuff
- 5:08:13i
- 5:08:13import the stuff i import the stuff and
- 5:08:15i'm sitting here and by the way type
- 5:08:17type type type type look you got tab
- 5:08:19completion okay
- 5:08:21so get remote and look
- 5:08:24well here let me do remote so that we uh
- 5:08:28look yeah also you got tab completion
- 5:08:31you have help
- 5:08:32everything you got everything and help
- 5:08:34will discover
- 5:08:35all of this so you've got full
- 5:08:36discoverability you got full help
- 5:08:38it looks and feels like it's here but
- 5:08:40it's running in the best place
- 5:08:41possible which is on those machines and
- 5:08:44i didn't have to install
- 5:08:45anything now this is referred to as
- 5:08:47implicit remoting and you're probably
- 5:08:50going to want to do this yourself it's
- 5:08:51already in the slides but we'll also
- 5:08:53give you some more references
- 5:08:55for the implicit remoting and to be
- 5:08:56honest when i'm managing i literally
- 5:08:58this is what i'm doing i don't install
- 5:09:00anything on my local box because i'm not
- 5:09:02too sure as a consultant what box i'm
- 5:09:04going to be
- 5:09:05on so i'll just implicitly remote the
- 5:09:07commands that i need when i need them
- 5:09:09um you know what we here's the other
- 5:09:12thing that's so important
- 5:09:13is when i imagine i'm going to go get
- 5:09:15this stuff from different things
- 5:09:17uh over here i might need a different
- 5:09:19set of credentials than over there
- 5:09:20right so instead of having to type the
- 5:09:23credentials all the time
- 5:09:24you create the session with a set of
- 5:09:26credentials you import the commandlets
- 5:09:27those credentials are then used every
- 5:09:29time and
- 5:09:30guys there's a dash credential parameter
- 5:09:33on this so when you create the session
- 5:09:34yeah you use the credentials that you
- 5:09:36want to use when you do
- 5:09:38the import of the of of the modules
- 5:09:41then it's you're using those credentials
- 5:09:43over and over and over again so you
- 5:09:44don't have to keep track of all of that
- 5:09:46it's it's
- 5:09:47it really makes your life a lot easier
- 5:09:49and cuts down on all the minutia of
- 5:09:51tools and all this kind of stuff yeah i
- 5:09:53really encourage you guys to go
- 5:09:55try this even if you do it locally like
- 5:09:56here let me show you something i'll just
- 5:09:58show you how to do it locally right
- 5:09:59because it's just so freaky
- 5:10:00so here uh you can do
- 5:10:03uh i just say dollar sign s equals new
- 5:10:05session and that'll connect to locally
- 5:10:07right your local machine and then you
- 5:10:09can do import
- 5:10:11ps session dollar sign s
- 5:10:14minus and we'll just like do one command
- 5:10:17like nice command
- 5:10:18get process minus prefix
- 5:10:22prefix wow right and so all of a sudden
- 5:10:25you get get
- 5:10:27wow process
- 5:10:31and and it just works okay
- 5:10:34so the point is you know just try it
- 5:10:36right because you don't necessarily have
- 5:10:38to have access to some remote machine
- 5:10:39with the main controllers and all that
- 5:10:41stuff you can do it on your local box
- 5:10:43uh but it is so freakishly cool i mean
- 5:10:45you just want to have fun with it
- 5:10:47it's seriously going to solve a lot of
- 5:10:49business problems for you going forward
- 5:10:51i mean just grabbing the commands from
- 5:10:53the machines that have them you've got
- 5:10:54the correct versions
- 5:10:56you know of whatever product you're
- 5:10:57working with implicit remoting is truly
- 5:10:59a godsend
- 5:11:00for this now guys we're going to take
- 5:11:02another 10 minute break and we're going
- 5:11:03to have our last session
- 5:11:05for today for today today and it's going
- 5:11:08to be
- 5:11:09on we're going to start scripting we're
- 5:11:11going to start
- 5:11:12seeing what the script looks like so
- 5:11:14come back and join us in 10 minutes and
- 5:11:15let's automate
- 5:11:16and then in two weeks we do the advanced
- 5:11:18one now the advanced one
- 5:11:20we roll up our well they already rolled
- 5:11:22up we roll up our sleeves and we get
- 5:11:24into the scripting the automation et
- 5:11:26cetera
- 5:11:27yeah the hardcore stuff but this is a
- 5:11:28taste that i think you're going to enjoy
- 5:11:30and it'll get you working
- 5:11:31and it'll get you prepped for what you
- 5:11:32need in two weeks so see you in 10
- 5:11:38[Music]
- 5:11:44minutes
- 5:11:52[Music]
- 5:12:00and and we're back for our last session
- 5:12:03for today
- 5:12:04last and best last and best session for
- 5:12:06today guys before we forget we should
- 5:12:08just give a super shout out to the mvps
- 5:12:10uh
- 5:12:10answering all those great questions yeah
- 5:12:13thank you
- 5:12:14again uh just representative example of
- 5:12:16the awesome powershell community
- 5:12:18join be part of the powershell community
- 5:12:20let's go
- 5:12:21and so guys what we're going to do is
- 5:12:23this is kind of a warm-up for what we're
- 5:12:24going to do on august 1st where we go
- 5:12:25through all the details in this this is
- 5:12:28more than just a warm-up though you can
- 5:12:30start immediately using this today i
- 5:12:31like to refer to this as immediately
- 5:12:33effective and so
- 5:12:34let's start off with though
- 5:12:38thank god you're not physically in this
- 5:12:41room because
- 5:12:43what i'm about to show you i've actually
- 5:12:45had people threaten to hit me
- 5:12:48oh so you have to imagine that no don't
- 5:12:51hit me man don't
- 5:12:52you just got punched by jeffrey snowden
- 5:12:54that's going to look really good on my
- 5:12:55resume
- 5:12:56um so we've been spending all of our
- 5:12:59time
- 5:12:59in the console and god i love the
- 5:13:02console and we've been working on
- 5:13:03commands and here's what you want to do
- 5:13:04you want to work stuff out in here
- 5:13:06copy it and like we did earlier paste it
- 5:13:08into a script but i want to show you
- 5:13:10something that comes with
- 5:13:12powershell and it's the ise and
- 5:13:15yeah i know and this is where so i'm
- 5:13:17going to close this console and guys i
- 5:13:18want to show you this real quick so that
- 5:13:20we can kind of get into it but
- 5:13:22i'm going to start the ise and you know
- 5:13:25they're going to do that
- 5:13:25picture-in-picture thing so let me lower
- 5:13:27this thing down here a little bit
- 5:13:30now i'm going to show you don't yell at
- 5:13:32me please don't yell at me first of all
- 5:13:34there's a scripting pane up here down
- 5:13:36here is a console pane then there's this
- 5:13:38commands pane i'm going to
- 5:13:40simplify this screen real quick
- 5:13:44and i want to show you these buttons
- 5:13:45across the top you can have
- 5:13:47the the scripting pane on top and a
- 5:13:49console on the bottom you can have them
- 5:13:51side by side which if you have two
- 5:13:52monitors
- 5:13:53this is awesome yeah to put this between
- 5:13:55the dual monitors
- 5:13:56but i'm going to make it even simpler
- 5:13:58i'm just going to go to one pane and so
- 5:14:00i can kind of shorten things up a little
- 5:14:01bit here
- 5:14:03and and bring this down a little bit
- 5:14:05here's the part that you're going to
- 5:14:07threaten to beat me to death with i'm
- 5:14:09going to hit control r that flips me
- 5:14:11between
- 5:14:11the scripting pane and the console and
- 5:14:14you might be asking yourself
- 5:14:15well this looks kind of like a console
- 5:14:18yeah this is a damn fine console
- 5:14:20remember this morning
- 5:14:22when we were talking and jeffrey was
- 5:14:23saying hey look we can't touch
- 5:14:25that original console thing that you
- 5:14:27know controller
- 5:14:29huh i didn't know that what controller
- 5:14:32yeah it's awesome
- 5:14:33oh i keep trying to remember control d
- 5:14:35versus control i
- 5:14:36like d what the hell is no i think i
- 5:14:38think bruce pan i think bruce payette
- 5:14:40did something with control r and i'm
- 5:14:41like
- 5:14:42so yeah controller oh i've learned
- 5:14:44something oh that's
- 5:14:45uh yeah right on bro so here's the deal
- 5:14:49i'm going to type something here and
- 5:14:51you're going to see that this is not the
- 5:14:53console that
- 5:14:54you think we are first of all let me
- 5:14:56clear it up now watch
- 5:14:58i'm going to do get
- 5:15:01look at what it's doing look at what
- 5:15:02it's doing
- 5:15:04dude this is like it's it's intellisense
- 5:15:08helping me through here this is like
- 5:15:10totally awesome and watch
- 5:15:12you might notice that it's also
- 5:15:16color syntax so
- 5:15:20here's the deal and we're going to ask
- 5:15:21jeffrey about this because
- 5:15:23this is the coolest thing in the world
- 5:15:25you've got a console that has color
- 5:15:26syntax coding which
- 5:15:27helps a lot when you're typing to see if
- 5:15:30you're typing an error
- 5:15:31and it's got this help flying at me as
- 5:15:34i'm typing
- 5:15:37is this your solution to the the the
- 5:15:39console going forward is it because
- 5:15:40this makes it makes it a lot easier yeah
- 5:15:42right take spend a couple of
- 5:15:44hours with this and stop asking me about
- 5:15:46improving the console
- 5:15:47that's that which is what the thing was
- 5:15:49this morning is don't ask about
- 5:15:50improving the console because they're
- 5:15:52doing it right now and this is the way
- 5:15:54to do it so
- 5:15:55let's use this console and let's let's
- 5:15:57let's take a command here let's do a git
- 5:15:59wmi object yeah
- 5:16:00it's okay it's okay we'll all be good
- 5:16:02win32 underscore logical disk
- 5:16:04i just want to show you i want to get
- 5:16:05something to work and i'm going to type
- 5:16:06something in you probably haven't seen
- 5:16:07before
- 5:16:08you will but i'm going to do device
- 5:16:12filter on device id equals
- 5:16:16c i want you to see what it gives me as
- 5:16:19an output well
- 5:16:20absolutely nothing because i screwed up
- 5:16:22the filter
- 5:16:24and so what this command now gives me is
- 5:16:27it gives me some useful information it's
- 5:16:28giving me um i'm having a scroll issue
- 5:16:30here hang on
- 5:16:32it's giving my drive c and it gives me
- 5:16:33free space and size i don't like the
- 5:16:35numbers
- 5:16:36so i'm going to do something in flight i
- 5:16:38want you to notice i'm building a
- 5:16:40command to make sure that it works first
- 5:16:42and then i'm going to show you how easy
- 5:16:43cool this gets so
- 5:16:46what i'd like is i'd like to select and
- 5:16:49i'm only going to take one property for
- 5:16:50this demonstration so i'd like to use
- 5:16:52the free space
- 5:16:53but you know what i can't stand is okay
- 5:16:57let's just do free space watch
- 5:17:00i i don't know about you but i don't
- 5:17:02really like that number because that
- 5:17:03number is like in bytes and
- 5:17:05it's like not making me happy because i
- 5:17:08want to see it like gigabytes or
- 5:17:09something like that
- 5:17:10because can't point sit down yeah
- 5:17:13so you did get wmi object do get sim
- 5:17:16object
- 5:17:18and then yeah wait yeah no let's start
- 5:17:20from scratch
- 5:17:21okay let's start from scratch you want
- 5:17:24you want get
- 5:17:24sim object get sim object get sim object
- 5:17:28or sim instance instant sorry yeah and
- 5:17:30say win32
- 5:17:32lodge and then tap tap tap
- 5:17:43and then control space control space
- 5:17:47and then control space
- 5:17:54that's awesome intellisense against the
- 5:17:56wmi namespaces
- 5:17:58oh and guys when you start working with
- 5:18:00wmi one of the hardest things is dealing
- 5:18:02with the namespaces and finding the
- 5:18:03classes and this is one of the most
- 5:18:05important technologies out there we
- 5:18:06haven't had time today to go through it
- 5:18:07but
- 5:18:08this is awesome oh yeah
- 5:18:12yeah so and you're going to be wanting
- 5:18:13to use get some instance instead of the
- 5:18:15old-fashioned command that i'm going to
- 5:18:16use right now
- 5:18:18okay and so i'm going to do select free
- 5:18:21space i can't stand that number so
- 5:18:23i'm going to do a custom column i'm
- 5:18:25going to just like we had done earlier
- 5:18:27because i don't like that i'm going to
- 5:18:28create my own there's a reason i'm doing
- 5:18:30this but don't panic we're almost there
- 5:18:32and so i'm going to call it free gb
- 5:18:36and uh oops would help if i put in
- 5:18:38something to tell it what i was doing
- 5:18:40and you're not showing the best
- 5:18:44practices
- 5:18:47hit the cancel up to the pipeline and
- 5:18:50now it hit carriage turn oh well but
- 5:18:54but but oh it doesn't do that in the ise
- 5:18:57it doesn't only in the console
- 5:18:59i i know what you so here's what jeffrey
- 5:19:01is saying and i'll show it to you in
- 5:19:02there
- 5:19:02and in here so because i want you to see
- 5:19:04this because you guys this will actually
- 5:19:06be really interesting
- 5:19:08i want you to see that watch so i'm
- 5:19:10doing this this long line here get wmi
- 5:19:13object win32 underscore logical disk
- 5:19:17logical desk
- 5:19:19filter and device id
- 5:19:24equals c colon and guys here's the thing
- 5:19:28is that i want to that's great and
- 5:19:29that's fine that's dandy
- 5:19:31but i'm going to start typing this long
- 5:19:33command that's going to be wrapping
- 5:19:34around
- 5:19:35a really great great way to work at the
- 5:19:37console is to realize that
- 5:19:39there are certain things that
- 5:19:40automatically give us line continuation
- 5:19:42the pipeline being one of them watch
- 5:19:44what happens here when i strike in or
- 5:19:46after the pipeline see these things
- 5:19:51this means i'm not sure but it means
- 5:19:55you're you're we i we get it you're
- 5:19:57still on the same line
- 5:19:58just keep typing so from here i can do
- 5:20:00my select
- 5:20:02it becomes easier to read and it's
- 5:20:04easier to edit when you're doing stuff
- 5:20:06in real time
- 5:20:07um select and i'll do my
- 5:20:10at n equals uh
- 5:20:13free gb and
- 5:20:17oops uh it's late in the day x e
- 5:20:20equals and i'm going to take the current
- 5:20:23object across the pipeline i'm going to
- 5:20:24grab its free space
- 5:20:26and i want to see it in gigabyte so i'm
- 5:20:27going to divide it by
- 5:20:301gb we have these built-in things to
- 5:20:32help us with math because i'm not good
- 5:20:33at math so
- 5:20:34these help me with math and so the
- 5:20:36number looks a strike enter on this line
- 5:20:38number looks better
- 5:20:39but i'd like it all rounded up so i'm
- 5:20:41just going to do this as an integer real
- 5:20:43quick
- 5:20:44now i'm going to do it as an integer
- 5:20:48real quick
- 5:20:48but it's going to yell at me because i
- 5:20:49didn't run both lines
- 5:20:52so let me do this no that's fine that's
- 5:20:54fine and so as int
- 5:20:57and oops now i screwed something up
- 5:20:59right hang on brackets i forgot the
- 5:21:01brackets
- 5:21:03i'll get you a good line of code don't
- 5:21:05panic this is all in the slides too so
- 5:21:07if i can't fail to type
- 5:21:09boom so i've got a nice line now
- 5:21:12i've got something that's giving me
- 5:21:13information that i want it's pretty cool
- 5:21:15got it all worked out what i'm going to
- 5:21:17do is
- 5:21:18cut and paste now from here you know cut
- 5:21:19and paste is kind of hard to do but if
- 5:21:21you did this over here
- 5:21:23cut and paste is really easy to do
- 5:21:24because you know what's funny is they
- 5:21:26figured out how to use things like oh
- 5:21:28let's see and this old this old
- 5:21:30technology called
- 5:21:31control c control v so i'm going to say
- 5:21:34control c
- 5:21:35i'm going to hit control r to flip the
- 5:21:36screen so i'm going to control v
- 5:21:39oh yeah baby now i've got my line
- 5:21:42now we're going to start having some fun
- 5:21:43because we're going to save this as a
- 5:21:44script right now
- 5:21:45file save as we'll uh
- 5:21:49save it uh here in my scripts folder
- 5:21:52we're gonna save it as uh well we did i
- 5:21:53love you uh
- 5:21:54let's do this as let's just call it disk
- 5:21:56info dot ps1
- 5:21:59and i can run it from right here if i
- 5:22:01run it boom shows me a result
- 5:22:02uh it helps if i clear the screen and
- 5:22:05everything else i typed but
- 5:22:07i can run it oink and it shows me the
- 5:22:09results i'm going to hit control r
- 5:22:11everything's good now we want to start
- 5:22:14adding stuff to this
- 5:22:16so let's make this a little better first
- 5:22:17of all you know this is a nice script
- 5:22:19and all this but if i give it to
- 5:22:20somebody else all it's doing right now
- 5:22:21is getting
- 5:22:22information off the c drive on the local
- 5:22:24machine that's not
- 5:22:25cool i wanted to be able to get it from
- 5:22:32whatever computer i want it to get it
- 5:22:34from now i can sit here and hard code
- 5:22:35this
- 5:22:37dude computer name right i'm not
- 5:22:40spelling anything right
- 5:22:41computer
- 5:22:46name localhost and this will work but
- 5:22:50yeah go ahead and save it that's fine
- 5:22:53but
- 5:22:54here's the problem if i give this to a
- 5:22:57friend
- 5:22:59what are they going to have to do
- 5:23:00they're going to have to go in here and
- 5:23:02edit my script and i don't want people
- 5:23:05editing my script
- 5:23:06what could possibly go wrong especially
- 5:23:08if you digitally signed it
- 5:23:10especially if i digitally signed it so
- 5:23:12what i'm going to do is let's do a
- 5:23:13simple concept
- 5:23:14let's make a variable up here called
- 5:23:16dollar sign computer name
- 5:23:18and let's set it right now equal to
- 5:23:20localhost just to have
- 5:23:21some value in there and instead of
- 5:23:24we'll put the variable in here now this
- 5:23:26is kind of common to a lot of other
- 5:23:28scripting languages where
- 5:23:29what you would do is you put your
- 5:23:32variables up here so you'd make it
- 5:23:33easier
- 5:23:35for somebody to edit your script i still
- 5:23:38don't like this
- 5:23:39whole editing my script thing but i want
- 5:23:41you to see that this still works right
- 5:23:43all i'm doing is
- 5:23:44is putting it into dollar sign computer
- 5:23:46name still prints it out
- 5:23:47everything's cool you know
- 5:23:51let me show you how to test the script
- 5:23:53properly from the console
- 5:23:55because i'm about to blow your mind
- 5:23:57something that these guys have done
- 5:23:58is awesome so let's run the script from
- 5:24:01the console since a lot of scripts get
- 5:24:03run from the console i actually like to
- 5:24:04test them from there
- 5:24:06yep cds
- 5:24:10and so we called this disk info
- 5:24:13run it we're good happy happy happy
- 5:24:16happy but you know what
- 5:24:18i've been learning powershell and as an
- 5:24:21administrator
- 5:24:23this isn't exactly what i expect i
- 5:24:25expect i don't want to
- 5:24:26go in and edit computer name no when we
- 5:24:29have commandlets and stuff
- 5:24:31we get parameters that we can adjust so
- 5:24:34you know would be really cool
- 5:24:36i think i think it'd be really cool if
- 5:24:39there's this special keyword called
- 5:24:42param
- 5:24:44open parentheses close parentheses
- 5:24:50indent so that jeffrey loves you that's
- 5:24:52right
- 5:24:53make it look pretty i want you guys to
- 5:24:55notice something i'm going to save this
- 5:24:57so i'm going to hit ctrl s
- 5:24:58and save it i'm going to go back to my
- 5:25:00powershell console
- 5:25:04and watch this i'm going to clear the
- 5:25:05screen dot disk info
- 5:25:08dash oh
- 5:25:15i just made a parameter oh it was so
- 5:25:18easy
- 5:25:19to make a parameter so now i can type in
- 5:25:21any computer i want
- 5:25:23now i'm not selecting out a computer
- 5:25:25name which we will fix but i want you to
- 5:25:27kind of get the concept of
- 5:25:30i just put a variable in here matter of
- 5:25:31fact let's do another one let's just
- 5:25:32call it bogus
- 5:25:34just so you can see i'm going to go back
- 5:25:36here watch watch my chest it's so cool
- 5:25:40um let's do
- 5:25:45i'm making parameters on the fly for
- 5:25:47whatever i need
- 5:25:49this is becoming what's called a
- 5:25:50parameterized
- 5:25:52script and what you're getting is it's
- 5:25:54starting to
- 5:25:55kind of smell look and feel more like a
- 5:25:58commandlet
- 5:25:59it's making my life a little bit easier
- 5:26:02i'm liking this so let's try this i i
- 5:26:06there's another thing that would be
- 5:26:07really nice is if if
- 5:26:09for for an instance at least get help
- 5:26:12dot
- 5:26:12disk uh info yeah
- 5:26:16look at what powershell is doing
- 5:26:17powershell is starting to build that
- 5:26:19syntax for me but i a computer name it
- 5:26:22says it's an
- 5:26:23object no uh let me go in here and you
- 5:26:25can strongly type what the variables
- 5:26:28are we didn't haven't talked much about
- 5:26:29that but i want this to be a
- 5:26:31string so when i go out here and do this
- 5:26:34again
- 5:26:37notice it's now making it a string and i
- 5:26:39want you to notice that between the
- 5:26:41chihuahuas it says string it doesn't say
- 5:26:43that it can take multiple objects we
- 5:26:44don't have any of the binkies in there
- 5:26:46so here's how we put binkies in there
- 5:26:50[Music]
- 5:26:54and
- 5:26:56i'm starting to actually get syntax now
- 5:26:58built on these parameters
- 5:27:00and the only thing i've had to do so far
- 5:27:02is add one keyword different from what
- 5:27:04i'm used to and this one called param
- 5:27:06but wait there's more oh wait it gets
- 5:27:08better
- 5:27:10we're going to turn something on so that
- 5:27:12you can use
- 5:27:14parameter attributes yeah so let's do
- 5:27:17commandlet binding
- 5:27:20this turns on something called parameter
- 5:27:22attributes and here's the thing i don't
- 5:27:23really want to have local host in here
- 5:27:25what i want to do oh whatever
- 5:27:27just hit save just hit save yeah yeah
- 5:27:29and now do get help
- 5:27:30okay oh i see what he okay now what what
- 5:27:33he added one line of code one line
- 5:27:35one line of code and watch what happens
- 5:27:39what well that wasn't that wasn't it did
- 5:27:41i save it i think i saved it
- 5:27:43oh well we got common parameters so yeah
- 5:27:45it did okay we just need to do the
- 5:27:47um yeah so we got common parameters so
- 5:27:49this is actually making the syntax full
- 5:27:51watch watch so command binding will let
- 5:27:54us
- 5:27:54use something called parameter
- 5:27:56attributes things like making things
- 5:27:58mandatory
- 5:27:59let me show you an example i'm going to
- 5:28:00get rid of this default
- 5:28:03and i'm going to go in here and i'm
- 5:28:06going to say
- 5:28:08uh parameter i got to spell this right
- 5:28:13mandatory mandatory
- 5:28:16equals true and i think i got the syntax
- 5:28:20correct now i want to point out that
- 5:28:22this is a parameter attribute i'm going
- 5:28:23to say mandatory is true it only affects
- 5:28:26the next parameter after it's not going
- 5:28:27to affect bogus
- 5:28:29so watch look at what happens to the
- 5:28:31syntax on this
- 5:28:33notice up here
- 5:28:36i had the brackets around it now look
- 5:28:38there's no brackets around that this is
- 5:28:40going to become mandatory so watch as i
- 5:28:42start to try to run this
- 5:28:44i'm going to do disk info i'm going to
- 5:28:47run it
- 5:28:48oh you got to give me a computer name
- 5:28:49man so it's mandatory now
- 5:28:52dc and now it works i can do it
- 5:28:56i've made it mandatory i can also then
- 5:28:58do
- 5:28:59of course i've got the actual parameter
- 5:29:01so in just
- 5:29:02two lines of code we're making our own
- 5:29:05parameters
- 5:29:06on our script a parameterized script and
- 5:29:08we're getting syntax but you know what i
- 5:29:10want to be a nice guy when i give this
- 5:29:11to somebody else
- 5:29:12i want to be a really nice guy when i
- 5:29:14give it to you i want to be a great guy
- 5:29:16so what do you say we add in a little
- 5:29:18bit of help i love it
- 5:29:19love it let's do some help guys this is
- 5:29:22a uh
- 5:29:24a a block comment now usually when you
- 5:29:27type in comments see how they're in
- 5:29:28green
- 5:29:29usually the the parsing engine that will
- 5:29:31just ignore what's ever in there but
- 5:29:33with power shell watch i'm just going to
- 5:29:35type in a couple of things synopsis
- 5:29:38i'm going to say this is the short
- 5:29:41explanation
- 5:29:42it's okay if i have typing mistakes at
- 5:29:43this point because tired
- 5:29:46description this is the long
- 5:29:49disc yeah everybody's gonna be making
- 5:29:51fun of me because i can't type in i'm
- 5:29:53gonna type in
- 5:29:54parameter whoops what's what
- 5:29:57parameter and i'm going to say computer
- 5:29:59name
- 5:30:01and i'm going to say this is for remote
- 5:30:03computers
- 5:30:04and just just a couple more things here
- 5:30:06real quick uh example
- 5:30:08um let's do an example of uh oh let's do
- 5:30:11uh
- 5:30:12disk info uh dash computer name
- 5:30:16you know remote and let's do one more
- 5:30:19this is for this can we do an example
- 5:30:23this oh
- 5:30:28remote computer watch
- 5:30:31look guys just a couple of things this
- 5:30:34is going to be totally amazing
- 5:30:37let's do this all over watch much get
- 5:30:39help
- 5:30:44lookie does it look like powershell help
- 5:30:47now
- 5:30:49so i've got i've got name synopsis look
- 5:30:52it's building the syntax i got
- 5:30:53description but wait that's the
- 5:30:55short help watch watch one watch full
- 5:30:59oh now look what powershell's built for
- 5:31:02me it shows me the parameters the
- 5:31:03parameter definitions
- 5:31:05it's going to i've got an example down
- 5:31:07here for crying out loud
- 5:31:08this is what i want i want to give this
- 5:31:10to somebody else that works with
- 5:31:11powershell because this is what they
- 5:31:13expect
- 5:31:14oh this is making me so happy now can i
- 5:31:17just point something out yes
- 5:31:18absolutely i can never remember any of
- 5:31:20this i can't remember any of this either
- 5:31:22well you did well that's pretty good i
- 5:31:24can't do that
- 5:31:25so show them the amazing control j so
- 5:31:28guys
- 5:31:30i'm going to hit the only way i can deal
- 5:31:32with it and and here's the thing
- 5:31:33and when we come back on august 1st this
- 5:31:35is going to become one of your best
- 5:31:36friends so
- 5:31:37i'm going to start a new tab just i'm
- 5:31:39going to hit ctrl j it's going to bring
- 5:31:41up snippets now i want to point
- 5:31:42something out
- 5:31:43i'm not quite done with this
- 5:31:44demonstration yet but these snippets
- 5:31:46look at this
- 5:31:47commandlet snippet it gives you
- 5:31:50the basics of putting this together and
- 5:31:53the advanced one the complete one
- 5:31:54is super rock and cool but we've got
- 5:31:57comment blocks and we've got
- 5:31:59some of the the constructs and then the
- 5:32:01loops that we're going to be using on
- 5:32:02august 1st that you'll be able to
- 5:32:04work with to help you build this um
- 5:32:08so you could actually pick a a snippet
- 5:32:11and look it auto creates all these
- 5:32:14possibilities for you and oh look
- 5:32:16it see all you got to do now is just go
- 5:32:18in and so if you
- 5:32:19are a deeply flawed human like me and
- 5:32:21cannot smell synopsis
- 5:32:25this is what my problem is so you can
- 5:32:28use this as a
- 5:32:29template and to fill it up but wait
- 5:32:32there's more we're not done yet because
- 5:32:33here's the deal um this is nice this is
- 5:32:36a parameterized script and you can do
- 5:32:38a lot of powerful things with
- 5:32:40parameterized scripts but you know
- 5:32:43i want to take this to the next level
- 5:32:44just a little bit more so you can get an
- 5:32:46idea of where we're going to go on
- 5:32:47august 1st take it to 11.
- 5:32:49take a tool my amp goes to 11. it does
- 5:32:53um so we're going to go we're going to
- 5:32:54crank this bad boy up because
- 5:32:56my ise goes to 11. save script no let's
- 5:32:59do this
- 5:33:01so that you can see the typing what i'm
- 5:33:03going to do is i'm going to remove the
- 5:33:05help for it right now
- 5:33:07okay so don't don't freak out on me i'm
- 5:33:08just going to are you doing that well
- 5:33:10because i want them to oh i guess i can
- 5:33:11just scroll yeah
- 5:33:12no click click the button oh click the
- 5:33:14button on you just
- 5:33:16collapse yeah oh because highest c goes
- 5:33:19to the left oh yeah because ise goes to
- 5:33:2111 so
- 5:33:22here we go guys right now we're running
- 5:33:25this like a script i don't know about
- 5:33:26you but we ain't done this all day long
- 5:33:28we haven't typed in and run this script
- 5:33:30what we've been doing is we've been
- 5:33:31running things
- 5:33:32like verb dash noun verb dash noun
- 5:33:36god i'd like to do the same thing too if
- 5:33:38only i knew how
- 5:33:40well here's how i'm going to add one
- 5:33:43more keyword
- 5:33:45to your day of fun function you need to
- 5:33:49give it a name now we're going to give
- 5:33:51it a proper name
- 5:33:52verb dash now don't do this
- 5:33:57gimme dash stuff no
- 5:34:00gimme is not on the improved verb list
- 5:34:02so knock it off with making up your own
- 5:34:04verbs
- 5:34:04there's and everybody uh you got to do
- 5:34:07it at least once right but here we're
- 5:34:08going to do get dash and we're just
- 5:34:10going to call it disk info
- 5:34:12now the function it has an open squiggly
- 5:34:14and then when you're done with your code
- 5:34:16all the way at the end
- 5:34:17but wait what we're going to we're going
- 5:34:19to do i see later
- 5:34:21we going to do what we're going to talk
- 5:34:22about ise a lot next time
- 5:34:24yeah oh yeah yeah yeah yeah what do you
- 5:34:26what do you want him to see get rid of
- 5:34:27the last squiggle
- 5:34:29the the last one get rid of the last
- 5:34:31squiggle
- 5:34:32okay see the first squiggle see that
- 5:34:33squig see the red oh yeah yeah
- 5:34:36missing clothes so it's trying to help
- 5:34:39us
- 5:34:40understand where we're making that cool
- 5:34:41so you see that little squiggle it's
- 5:34:43actually pretty useful
- 5:34:44and you guys see on the screen the
- 5:34:45little red squiggly that jeffrey's
- 5:34:46talking about is this one right here and
- 5:34:48so if you leave your mouse over it it
- 5:34:49tells you
- 5:34:50hey you're missing something here bro
- 5:34:52and in this case dude
- 5:34:54dude and so we're we're missing that
- 5:34:56bottom squiggly now really going to like
- 5:34:58two
- 5:34:59yeah exactly so i'm going to
- 5:35:02indent this so that it's easier to read
- 5:35:05so you can see that i have a function
- 5:35:06now
- 5:35:08don't do what i'm about to do because
- 5:35:10this is just i'm going to show you
- 5:35:11something much cooler than this i'm
- 5:35:12going to save this
- 5:35:13and i want to show you here's one of the
- 5:35:15interesting things
- 5:35:17i'd like to run that script and then use
- 5:35:18that function well
- 5:35:20here's the challenging thing watch if i
- 5:35:22run disk info and i hit enter
- 5:35:24what happens when you run a script is
- 5:35:26the script runs it executes
- 5:35:28and then everything is discarded out of
- 5:35:30memory this is a good thing
- 5:35:32but here's the problem i just ran a
- 5:35:34script and it has a function called get
- 5:35:36disk info
- 5:35:37so what happened is the script just ran
- 5:35:39it just made this function up in memory
- 5:35:41for me
- 5:35:42and when the script ended it just killed
- 5:35:45it
- 5:35:46so there is no get disk info no no so
- 5:35:48i'll
- 5:35:49show you a unique way to do this now
- 5:35:51this is a great way for testing but i i
- 5:35:52got a better solution for you
- 5:35:54dot space
- 5:35:58i know i love it no it's awesome this
- 5:36:01retains the stuff in your script in
- 5:36:04memory so watch i'm going to run it it's
- 5:36:06not the right explanation okay but
- 5:36:08to tell them okay so here's the way it
- 5:36:10works so what happens is there's a stack
- 5:36:12right and so what happens is uh when you
- 5:36:15run something in general
- 5:36:16you create a new stack and you put all
- 5:36:19your variables in that stack
- 5:36:21and then when you do an exit or a return
- 5:36:23that stack goes away and they all get
- 5:36:24cleared up
- 5:36:26when you dot something what happens is
- 5:36:28it runs it doesn't create a new stack
- 5:36:30it runs it in the current stack so any
- 5:36:32new variables or anything that gets
- 5:36:34created they get created here when you
- 5:36:36exit you just exit but they stick around
- 5:36:38they stick around so
- 5:36:42dot sourcing and your unix guys will you
- 5:36:45like cotton right onto this this is
- 5:36:46dot source isn't that what i said only
- 5:36:48not nearly as well as you said it
- 5:36:50okay okay so watch get disk watch i'm
- 5:36:53going to hit tab completion at this
- 5:36:55point get disk
- 5:36:56get disk image hey tab completion
- 5:36:59it look looks like a commandlet lookie
- 5:37:02look at computer name dc
- 5:37:04we are rock and roll
- 5:37:08i don't like having to do this dot
- 5:37:09source stuff probably did you
- 5:37:11you when you hit that command line wait
- 5:37:12wait do it again do it again
- 5:37:14up arrow up there dash
- 5:37:18o tab
- 5:37:21ooh oh out oh out variable so
- 5:37:25let's um hey what do you want to call it
- 5:37:27a hey everything's a
- 5:37:28everything's a no dallas on a no dollar
- 5:37:30sign a so now i don't you guys see that
- 5:37:33it just sent it out to the variable it's
- 5:37:35some of those common parameters that we
- 5:37:36can use so now we've got
- 5:37:38this stuffed into a variable it's
- 5:37:39awesome so what that meant was when you
- 5:37:41put that commandlet binding there
- 5:37:43it said common parameters there's a
- 5:37:45bunch of common parameters and these are
- 5:37:47functions
- 5:37:48you know just by putting that one thing
- 5:37:49and you say hey powershell engine could
- 5:37:51you do some stuff work for me
- 5:37:52could you like give them output variable
- 5:37:55and then could you do like error action
- 5:37:57an error variable and warning action and
- 5:37:59warranty variable
- 5:38:00oh really cool stuff well you know let's
- 5:38:03take this one step further and you and
- 5:38:04you
- 5:38:05can certainly throw uh stuff into this
- 5:38:07but but guys this is going to be the
- 5:38:09meat of of what we
- 5:38:10we do on august uh first yeah and that's
- 5:38:14you know this is nice but this isn't
- 5:38:16something quite
- 5:38:17yet what we refer to as an advanced
- 5:38:19function although it's getting there
- 5:38:21and what i want to be able to do is i
- 5:38:22don't want to have to dot source
- 5:38:24and run this as a script that doesn't
- 5:38:25make sense to the junior admin that i
- 5:38:27want to give this to
- 5:38:28it's really worth the investment it's
- 5:38:30going to take some time right it's not
- 5:38:32going to be the simplest thing in the
- 5:38:33world
- 5:38:33it's going to take some time but you
- 5:38:34really need to invest in learning about
- 5:38:36modules okay because modules are the
- 5:38:39future they're really worth the
- 5:38:40investment
- 5:38:41yes you know why don't we just like
- 5:38:43settle in and teach them how to do it
- 5:38:45and teach them how to do it so you guys
- 5:38:47ready hardcore here we go yeah we're
- 5:38:49gonna hardcore we're gonna make a module
- 5:38:50wake up first of all i'm gonna show you
- 5:38:53the cheesy way to make a module
- 5:38:54nope cheesy file save as
- 5:38:59notice my my script
- 5:39:06that's that's it that's that's that's it
- 5:39:08that's that's that's it that's that's
- 5:39:10how you make them out you psm
- 5:39:12one watch what watch out what what
- 5:39:16you can now go to sleep yeah you can
- 5:39:17wait watch watch
- 5:39:19now now look because it's not in the
- 5:39:21special place
- 5:39:22that we're going to talk about i'm going
- 5:39:24to have to manually import this module
- 5:39:26and this module is called psm1
- 5:39:31so this is kind of like the old v2 way
- 5:39:33we'd always have to
- 5:39:34do that but watch
- 5:39:38do it again
- 5:39:42verbose you want to do dash force that
- 5:39:46does it again
- 5:39:46for us force the other force the other
- 5:39:49force and then dash for both for both
- 5:39:51and just this just
- 5:39:52shows you yeah see ah
- 5:39:55removing one important oh i love that i
- 5:39:57love that so yeah it's importing the get
- 5:39:59disk info
- 5:40:00and this is actually when you especially
- 5:40:02especially on august 1st when we're
- 5:40:04working with you know you have to you
- 5:40:05have to reload modules you have to do
- 5:40:07this is actually very useful to have
- 5:40:09around so i've got a module that's
- 5:40:11imported now i can just do get disk info
- 5:40:13but you know
- 5:40:15this is still not exactly the way that i
- 5:40:18want it because i don't want to have to
- 5:40:20say here's this thing i made you this
- 5:40:22pretty
- 5:40:23module it's a psm1 file and i
- 5:40:26you're going to have to import it every
- 5:40:27time you want to use anything in it that
- 5:40:29just doesn't make sense
- 5:40:31dude so hard was that it was easy i know
- 5:40:33it was easy but you guys have like
- 5:40:34magical locations
- 5:40:36oh there is the magic yeah yeah so it's
- 5:40:38going to let them in on the secrets well
- 5:40:39i don't know i
- 5:40:40see um env
- 5:40:43is it ps module path it shows us all the
- 5:40:45magic
- 5:40:46so there are two paths here
- 5:40:50these are the magic locations right now
- 5:40:52as far as we're going to talk about the
- 5:40:53magic locations
- 5:40:55if you put your module in these
- 5:40:57locations in a special way
- 5:41:00they too will be dynamically loaded dude
- 5:41:02what are you doing there that's odd
- 5:41:04i never do it that way what do you want
- 5:41:06to do show it my way
- 5:41:07okay we'll do it your way
- 5:41:10okay so what i do is i do i do oh
- 5:41:14let's make this bigger i do dollar sign
- 5:41:18okay and that looks the same but check
- 5:41:21this out because we need to do dollar
- 5:41:22signs dollars
- 5:41:25split do it your way yeah
- 5:41:30and then you break it out now you can
- 5:41:31read it yeah let's do it that way let's
- 5:41:33do it
- 5:41:34back to him split up so i can't spell
- 5:41:37split i can spell spit apparently
- 5:41:40and what are we we're doing on what the
- 5:41:41semicolon yeah
- 5:41:43there's quotes a quote it's called it's
- 5:41:45called it's quotes
- 5:41:46ah oh now we can read the two paths this
- 5:41:51makes a lot
- 5:41:52much better so here's the first path
- 5:41:54that i want you guys to take notice of
- 5:41:56this is the path and i'm going to show
- 5:41:57this to you graphically for a second
- 5:41:59just so you can kind of see this i'm
- 5:42:00going to go out
- 5:42:01this is where powershell gets installed
- 5:42:03windows system 32
- 5:42:05and there's a reason i'm showing it
- 5:42:06graphically sometimes this makes more
- 5:42:07sense
- 5:42:08and so i'm going to go out where it says
- 5:42:09windows powershell
- 5:42:13and you'll see this folder called
- 5:42:15modules you see all these modules
- 5:42:17these are modules here's the thing don't
- 5:42:20put yours here
- 5:42:20yeah this is not for you a lot of guys
- 5:42:23will say oh just put it in there because
- 5:42:25i
- 5:42:25know where it is all that kind of stuff
- 5:42:26no don't put your stuff there this is
- 5:42:28the special place for microsoft
- 5:42:30you have your own special place
- 5:42:34and that is this one
- 5:42:38your account documents windows
- 5:42:40powershell modules but
- 5:42:41this doesn't exist let me show you let
- 5:42:44me show you graphically sometimes this
- 5:42:46makes a little bit more sense so i'm
- 5:42:47going to
- 5:42:48go out here to users
- 5:42:51and i'll go out to student company is my
- 5:42:54account and it's my documents through
- 5:42:56here
- 5:42:57you see there's no module called a
- 5:42:59windows powershell and there's nothing
- 5:43:01called
- 5:43:03modules so you will need to make it now
- 5:43:05i i know
- 5:43:06i'm making it graphically just because i
- 5:43:07happen to be here but
- 5:43:09you can do it with powershell of course
- 5:43:11windows powershell
- 5:43:13and then underneath of it you make
- 5:43:17it been faster if i'd done it in
- 5:43:18powershell oh my god what the hell's the
- 5:43:20matter with me
- 5:43:21so modules because now you're going to
- 5:43:23have to type it right now i'm going to
- 5:43:24have to type it right now here's the
- 5:43:25thing
- 5:43:26and this is very very important the name
- 5:43:30of your module you know the thing i call
- 5:43:33diskinfo.psm1
- 5:43:35needs to be the name of the folder that
- 5:43:37you're going to create here they need to
- 5:43:39match
- 5:43:40so i'm going to say new folder
- 5:43:44i'm going to say disk info now
- 5:43:47i've got this folder let's do this
- 5:43:51i need to put my module in there so let
- 5:43:54me go grab my module
- 5:43:56which was this psm1 disk info
- 5:44:00i'm gonna take it put it out to here
- 5:44:03oh yeah i should have never done this
- 5:44:05graphically but now i'm here
- 5:44:07i'm gonna put it now here's the
- 5:44:09important thing see look module name
- 5:44:12the the module folder name and then
- 5:44:16the name of the duder inside watch
- 5:44:19let's close this so you know i'm not
- 5:44:21cheating
- 5:44:24let's see i wonder if i can get some
- 5:44:26help on
- 5:44:28uh did you start a fresh window yeah i
- 5:44:30started a brand new one
- 5:44:31a brand new one oh here just in case
- 5:44:33anybody missed it i don't want you to
- 5:44:34miss it i'm not cheating let me close
- 5:44:36this thing up
- 5:44:36i'm not cheating brand new window
- 5:44:40get help um is there anything
- 5:44:43uh in commandlet's on disk information
- 5:44:48hmm wait wait wait wait wait
- 5:44:52oh
- 5:44:54[Music]
- 5:44:58inside my module and well let's just try
- 5:45:00it get uh
- 5:45:01disk uh info or not image info
- 5:45:05dash computer name dc
- 5:45:08oh okay
- 5:45:12you can tell that we're getting up to
- 5:45:13the end of the day because the guys
- 5:45:15in the back are are now going oh
- 5:45:19so let me let me let me just show you
- 5:45:21the uh the code again
- 5:45:22and jeffrey please go ahead and add in
- 5:45:24so all you're really doing is
- 5:45:26doing functions we're properly naming
- 5:45:28them so that they look like commandlets
- 5:45:29notice
- 5:45:30i just gave it a little bit of help
- 5:45:31there are about underscore comment based
- 5:45:33help
- 5:45:34files for this to help you with this or
- 5:45:36you can use
- 5:45:37ctrl j to get the snippets and notice i
- 5:45:40took a working line of code
- 5:45:42the only thing i did was i added param
- 5:45:45a couple of variables in there maybe an
- 5:45:47attribute and believe me on august 1st
- 5:45:49we'll talk a lot more about attributes
- 5:45:51that speeds rock
- 5:45:52oh they totally rock so with this simple
- 5:45:54little bit of code
- 5:45:55and saving it in the special place as a
- 5:45:57psm1 file
- 5:45:59i've made a module in fact in like all
- 5:46:02modules
- 5:46:02i'm not just going to put one function
- 5:46:04in here i'm going to put as many
- 5:46:06functions i'm going to make as many
- 5:46:08tools
- 5:46:09as i need and i'm going to put them into
- 5:46:11this module so just
- 5:46:13i'll just make it foo and i'll make
- 5:46:15function
- 5:46:16bar no i know they're not properly named
- 5:46:19but
- 5:46:20you get the idea now in that with that
- 5:46:22module i'm just adding more and more
- 5:46:24tools to this module now can do that
- 5:46:26save it save it save it
- 5:46:30uh so um important
- 5:46:33import import module and it's uh
- 5:46:36i forgot the name of disc info right and
- 5:46:38then we want to s force
- 5:46:40force and verbose or that's fine
- 5:46:45hmm oh did you expect it to come up and
- 5:46:48do the whole
- 5:46:48you're using a yeah not improved you
- 5:46:51know
- 5:46:51what he's talking about is and matter of
- 5:46:53fact i have to play with this i think
- 5:46:56well let's do uh gimme dash
- 5:47:00foo and uh
- 5:47:04yeah yeah bar dash foo and let me save
- 5:47:08it
- 5:47:13oh you know it's the force that's the
- 5:47:15problem oh it's the force that's doing
- 5:47:16it
- 5:47:16so move it remove it so module remove
- 5:47:19module
- 5:47:20by the way so force basically says i
- 5:47:23you're telling us
- 5:47:24we know what you're doing ignore all the
- 5:47:27errors just do what i told you to do
- 5:47:29dang it so watch what happens if you
- 5:47:31don't type force
- 5:47:32and this is actually uh disk info
- 5:47:38oh dude i don't know why it's i'm not
- 5:47:40saying it okay
- 5:47:41i don't know why it's not saying but
- 5:47:42here's what usually happens if you use
- 5:47:44an unapproved verb it comes up and it
- 5:47:46says in yellow
- 5:47:47knock it off stop using unapproved verbs
- 5:47:49don't be a dope
- 5:47:50don't be a dope so use the proved verbs
- 5:47:52and what are we doing on this uh
- 5:47:54today i see something up it gives us uh
- 5:47:57oh oh oh i they were trying to
- 5:48:01you guys don't understand what's up on
- 5:48:02the teleprompters in here right now
- 5:48:05the guys the production team was trying
- 5:48:07to be effing
- 5:48:08funny they didn't use the appropriate
- 5:48:11verb
- 5:48:11and so first of all here's what they
- 5:48:13typed in so you all can see it they said
- 5:48:16dollar sign mentioned this
- 5:48:19pipe to and i can't even read what
- 5:48:22character they're using
- 5:48:23this is were you guys up on
- 5:48:26site um and then was it a squiggly
- 5:48:30uh squiggly um it gives
- 5:48:35us good feedback
- 5:48:38in squeeze this is this is have you guys
- 5:48:40been awake at all today this is the
- 5:48:41crappiest powershell i've ever seen
- 5:48:47this is remarkable we've been we've been
- 5:48:50busting our bums all day long
- 5:48:52and you type this in please
- 5:48:55one of the mvps in the forums somebody
- 5:48:57you don't even be an mvp
- 5:48:58you take this and show them how it
- 5:49:00really should be done in the cliff note
- 5:49:02version
- 5:49:02yeah but the point is i thought we had a
- 5:49:05goodwill hunting moment there
- 5:49:08not so much that's good yeah here you go
- 5:49:12stay in av um what i think they're
- 5:49:15trying to say is that there's a poll
- 5:49:17up am i correct there's a poll up and
- 5:49:19it's a real important poll
- 5:49:21so make sure you you do the poll up on
- 5:49:23the site because the feedback
- 5:49:25for this session is is very important as
- 5:49:27a matter of fact we're we're starting to
- 5:49:29get kind of towards the end of
- 5:49:31what we we've done for the the day but
- 5:49:33your feedback on the session is very
- 5:49:35important
- 5:49:35um just so that you know we're going to
- 5:49:39dive
- 5:49:39deep deep deep and we're going to do it
- 5:49:41in a day so it's going to be
- 5:49:43definitely a day chewy chewy stuff
- 5:49:46into tool making basically making uh
- 5:49:49tools is going to show the different
- 5:49:51kind of parameter attributes
- 5:49:53more about the help how to see we've
- 5:49:56only scratched the surface
- 5:49:58our commandlet right now doesn't accept
- 5:50:01pipeline
- 5:50:01input it's not making changes so we're
- 5:50:04not supporting what if and confirm
- 5:50:07and you know we might want to make our
- 5:50:09own views we there's so many things that
- 5:50:12we're going to want to do
- 5:50:14so we've actually still got a lot of
- 5:50:16work to do we're just not going to do
- 5:50:17much more of it
- 5:50:19today so before we do a review
- 5:50:23is there anything you want to add to the
- 5:50:24stuff that we've done today is it
- 5:50:25telling you
- 5:50:26i think we i think we've been having fun
- 5:50:28we've walked through a bunch of stuff
- 5:50:29ton more
- 5:50:30ton more but again the key things i want
- 5:50:32you guys to to walk away with are
- 5:50:35one uh this spirit of exploration
- 5:50:38right go explore explore the help
- 5:50:41explore the help
- 5:50:42do you explore the help explore the
- 5:50:44forums go on the internet try some
- 5:50:46things
- 5:50:47and when you get confused ask questions
- 5:50:50do not be embarrassed not sit there say
- 5:50:52oh that's a dumb question no
- 5:50:53no ask that question you have a great
- 5:50:56community that will give you help
- 5:50:58and just a is hopefully you've seen the
- 5:51:01sense of fun
- 5:51:02there's just an incredible amount of
- 5:51:03power in powershell
- 5:51:05and it's fun to do this exploration by
- 5:51:07the way and it's safe too
- 5:51:08because you know you go and you have the
- 5:51:10minus what if and the
- 5:51:12and the uh confirm and verbose so you
- 5:51:15know it's uh you can explore and you can
- 5:51:17have fun and
- 5:51:18and do it safely and do it safely and it
- 5:51:21noticed that we've been having a lot of
- 5:51:22fun today because it's been a joy for
- 5:51:24the two of us to be able to spend the
- 5:51:25day talking with everybody about
- 5:51:27powershell
- 5:51:27because it is just a lot of fun
- 5:51:29especially when you get past some of the
- 5:51:31learning curve stuff
- 5:51:32so you we did get help and the the
- 5:51:34amazing discoverability of get help
- 5:51:37of finding commandlets regardless of
- 5:51:39what product that you're working with
- 5:51:40it'll find it for you
- 5:51:42and then you can go into the help files
- 5:51:44the examples the rich
- 5:51:46the syntax that's in there the
- 5:51:47definitions of the parameters
- 5:51:49so get help is definitely number one
- 5:51:52tool
- 5:51:53something you definitely want to get
- 5:51:54good at though is that middle piece we
- 5:51:56did just after the meal break
- 5:51:59of understanding the pipeline and how
- 5:52:01the pipeline works because
- 5:52:03if you can't figure out how to get two
- 5:52:05commandments to work together
- 5:52:07you're just not going to have a lot of
- 5:52:09fun that's so very important so
- 5:52:11remember don jones has a great book on
- 5:52:13learn windows powershell in the month of
- 5:52:14lunches it's chapter nine i know it
- 5:52:16sounds like i'm trying to sell a book i
- 5:52:17just want you to have
- 5:52:18more resource information on working
- 5:52:21through that and go out to the forums on
- 5:52:23powershell.org and ask about that
- 5:52:25also the thing that really changes and i
- 5:52:27i have to say
- 5:52:28you know understanding the pipeline that
- 5:52:31made a huge difference for me
- 5:52:33when v2 shipped and remoting that's what
- 5:52:36changed
- 5:52:37administration for me and it's changed
- 5:52:39it forever
- 5:52:40the remoting being able to hit multiple
- 5:52:43machines being able to do
- 5:52:44multiple things at once being able to
- 5:52:46put those into scripts
- 5:52:49has really really made a huge a huge
- 5:52:51difference
- 5:52:52so that's the stuff everybody you know
- 5:52:53powershell is running all of our
- 5:52:54websites
- 5:52:55you know all of our big internet sites
- 5:52:57and then that's why
- 5:52:58because i got a gazillion of these
- 5:53:00things how am i going to do things how
- 5:53:01am i going to do things and i think you
- 5:53:02guys have seen today
- 5:53:03a great example that powershell you can
- 5:53:06learn it you've learned a lot of it
- 5:53:07today
- 5:53:08and you know what i didn't tell them
- 5:53:09about what did you tell our sacred vow
- 5:53:12the sacred vow so uh so here's the
- 5:53:15sacred vowel the whole story behind the
- 5:53:16sacred vowel the sacred vowel is
- 5:53:17basically the story that says
- 5:53:19hey you're i.t pros your hair's on fire
- 5:53:21the last thing the world
- 5:53:22we know the last thing in the world you
- 5:53:23want to do is take your time to go
- 5:53:25learn a new tool and yet here i am and
- 5:53:28i'm sitting here asking you
- 5:53:29to learn this new tool and why and the
- 5:53:32answer is because it's going to help you
- 5:53:35and there's a set of things that you
- 5:53:36have to learn you have to learn the
- 5:53:38verbs you have to learn the syntax
- 5:53:39i have to learn the pipeline and you
- 5:53:41have to learn how to do things how to
- 5:53:43explore et cetera
- 5:53:44but my sacred vow to you is that if you
- 5:53:47learn those things
- 5:53:48i'm going to do everything in my power
- 5:53:50to reuse those words
- 5:53:52those concepts those techniques over
- 5:53:55and over and over and over again so that
- 5:53:58your investment in learning
- 5:54:00is the best payback the best investment
- 5:54:03you ever made
- 5:54:04now let me get concrete about what that
- 5:54:06means when we decided hey we need to
- 5:54:08support
- 5:54:08workflow the original design for
- 5:54:11workflow was this very unusual thing
- 5:54:13oh you know you got some weird syntax
- 5:54:15for workflow
- 5:54:16steps and workflow sequences
- 5:54:19and all that i said guys whack you
- 5:54:22forgot our sacred vow
- 5:54:24our sacred vow is they've already
- 5:54:25learned powershell use that over and
- 5:54:28over and over again
- 5:54:29so now when you when we teach you about
- 5:54:31workflow what you're going to see is
- 5:54:32you just type instead of function foo
- 5:54:35you type workflow
- 5:54:36foo and then you write powershell
- 5:54:39and the difference is that now it looks
- 5:54:42just like powershell
- 5:54:43except it's got very different semantics
- 5:54:45it isn't run
- 5:54:46by the traditional powershell engine we
- 5:54:49take that powershell syntax
- 5:54:51and we transcode it into a windows
- 5:54:54workflow
- 5:54:54object graph and we give it to the
- 5:54:56windows workflow
- 5:54:57engine to execute its execution engine
- 5:55:00but you
- 5:55:01your experience looks just like
- 5:55:04powershell even though underneath the
- 5:55:05covers
- 5:55:06it's very very different why because of
- 5:55:08our sacred vow
- 5:55:10you learn this stuff and we're going to
- 5:55:11do it over and over and over again
- 5:55:14use those techniques over and over and
- 5:55:15over again you learn how to manage
- 5:55:17exchange you're going to be able to let
- 5:55:18manage link having learned
- 5:55:20those two things you're going to be able
- 5:55:22to learn how to manage azure and
- 5:55:25sql and all that because of the sacred
- 5:55:27vow and we take that
- 5:55:28super seriously and i have to say it's
- 5:55:30it's a great honor to sit here next to
- 5:55:32jeffrey snover and it's been a great
- 5:55:33honor to be able to talk with with
- 5:55:35members of the powershell team because
- 5:55:36guys
- 5:55:37you got to realize that sacred vow
- 5:55:38they've stuck to it they've
- 5:55:40stuck to it over the over several you
- 5:55:42know the last five six years that i've
- 5:55:44been doing this
- 5:55:45there's one guarantee that i've always
- 5:55:47had and that's if i'm going to take
- 5:55:49the investment to learn this they're not
- 5:55:50going to screw me on the back end by
- 5:55:52suddenly
- 5:55:52ripping everything out replacing it and
- 5:55:54totally changing everything nope
- 5:55:56i'm going to get commandments i'm going
- 5:55:57to get parameters i've got a scripting
- 5:55:59environment that makes sense that's
- 5:56:00stable
- 5:56:01that's being moved forward it's always
- 5:56:03going to be improved but
- 5:56:04i know exactly what to expect and i know
- 5:56:06what to expect
- 5:56:07when i go to active directory to manage
- 5:56:09exchange to manage whatever
- 5:56:11it's the same and that experience makes
- 5:56:14this initial investment
- 5:56:16a little painful at first but it will
- 5:56:18pay off and it'll pay off
- 5:56:20for years and years and years and you've
- 5:56:22heard it from the architect they are
- 5:56:24so totally committed to that so
- 5:56:28a little bit of information of how you
- 5:56:30get some more information so let me just
- 5:56:32uh
- 5:56:33yeah we're going to leave your guys's
- 5:56:35mistake up on there a very embarrassing
- 5:56:37thing that you did
- 5:56:38and i want to just put up um a couple of
- 5:56:41things
- 5:56:42for you all first of all you know that
- 5:56:44at the
- 5:56:45nba where you're at or yeah mvs mba
- 5:56:47stuff
- 5:56:48we're going to have another presentation
- 5:56:49this is going to be on scripting and
- 5:56:51tool making
- 5:56:53now it's on august 1st but if you're
- 5:56:54watching this is a video look for the
- 5:56:56next title scripting and tool making so
- 5:56:58we'll
- 5:56:59we're going to do that it's going to be
- 5:57:00awesome it's gonna be totally awesome
- 5:57:02a couple of other things if you have a
- 5:57:04question please don't
- 5:57:06don't the only mistake you're gonna make
- 5:57:08if you have a question
- 5:57:09is not ask it so there are a couple of
- 5:57:12places you can go
- 5:57:13to get an answer of course
- 5:57:15powershell.org i think i've said that
- 5:57:16like 15 times a day
- 5:57:18but trust me the community nobody gets
- 5:57:20paid for this we're doing it because we
- 5:57:22actually care and we want to help
- 5:57:23go ask a question you'll get an answer
- 5:57:25we've all been through this
- 5:57:27i also want to give you something else
- 5:57:28something that's kind of uncommon i bet
- 5:57:30you you guys do this
- 5:57:32but every time i talk to a group of it
- 5:57:34pros something happens that's kind of
- 5:57:35bizarre i'll ask this question
- 5:57:37to a bunch of it pros how many of you
- 5:57:39use twitter and everybody will go like
- 5:57:41this
- 5:57:43that's not the correct answer knock it
- 5:57:45off so
- 5:57:47i i'm not saying go go i'm not saying
- 5:57:49set up twitter and start tweeting us
- 5:57:51what you had for lunch matter of fact
- 5:57:52don't do that please um but you need
- 5:57:56to get a twitter account even if you
- 5:57:57just want to look because where you're
- 5:57:59going to find
- 5:58:00the things that are going on is that a
- 5:58:02twitter hashtag called
- 5:58:05powershell that's where you're going to
- 5:58:07hear him you're going to hear the mvps
- 5:58:09and i'm not saying that they're just
- 5:58:10talking about here's a cool command no
- 5:58:12you're going to see
- 5:58:13pointers to here's how i solve this
- 5:58:16exchange problem here's how i solve this
- 5:58:18scvmm issue here's how i built this
- 5:58:22this is where the latest and greatest
- 5:58:23information is happening so get on
- 5:58:25twitter and
- 5:58:26while you're out there on twitter
- 5:58:27following the powershell stuff
- 5:58:30there's always at chase snover that's
- 5:58:33him
- 5:58:34see you can show them how to do they
- 5:58:35know how to use twitter
- 5:58:38ie you want me to bring up the tweeter
- 5:58:42the tweeter
- 5:58:43yeah well now i'm just the tweeter
- 5:58:46and twitter i don't know if i can use it
- 5:58:48this way okay you're gonna have to help
- 5:58:50me because
- 5:58:50this is actually hi can it be
- 5:58:54well i have to sign in don't you know
- 5:58:56how to do that well okay you want me to
- 5:58:58sign in
- 5:58:58really yeah okay i don't
- 5:59:01laugh at my sign-in
- 5:59:11it is what it is guys it just is what it
- 5:59:13is
- 5:59:16oops i think i did the password wrong
- 5:59:17let me let me
- 5:59:19wait a minute i'm signing into my
- 5:59:20twitter you're going to see all the
- 5:59:21stuff that i follow
- 5:59:22oh just wait a minute oh for crying out
- 5:59:24loud why wouldn't it let me in
- 5:59:26oh wait a minute
- 5:59:30wait a minute wait a minute i know i
- 5:59:31know i know oh my lord
- 5:59:33i know this is i i don't this isn't how
- 5:59:36i get to it
- 5:59:38oh and now it's making me type in all
- 5:59:39the device stuff are you kidding me guys
- 5:59:42here switch to mine switch to his i
- 5:59:44think his probably works
- 5:59:50oh there you go but did you finally get
- 5:59:52it no we're looking at yours
- 5:59:54see that's there's mine there's there's
- 5:59:56there's there's there's
- 5:59:57there's let's see let me see if i can
- 5:59:59finally get in ks
- 6:00:01ah what is that a w i hate these things
- 6:00:04e
- 6:00:04you're missing a what am i missing why
- 6:00:06don't i last
- 6:00:07had had a turkey sandwich for lunch um
- 6:00:10never mind
- 6:00:10that's that's i can't get signed into
- 6:00:12this awesome
- 6:00:13so twitter's awesome so you're going to
- 6:00:15want the first thing
- 6:00:17even if you can't get a hell of a
- 6:00:18twitter like obviously can't even use
- 6:00:20twitter
- 6:00:21but can use powershot so clearly did you
- 6:00:23guys see
- 6:00:24the problem with the internet today and
- 6:00:25he had to teach me um was it the host
- 6:00:28file
- 6:00:29it's e-hosts exactly so
- 6:00:33if you can't use twitter doesn't mean
- 6:00:34you can't use powershell that's right
- 6:00:36that's right so
- 6:00:37use powershell so ladies and gentlemen
- 6:00:39um
- 6:00:40on on behalf of the folks at mba and of
- 6:00:42myself i'd like to thank you for
- 6:00:44attending this
- 6:00:44this full day session and i would really
- 6:00:47sir
- 6:00:48like to thank you oh for spending the
- 6:00:50entire day it's been such a
- 6:00:52great fun it's been a blast had a great
- 6:00:54time with you and i i had a great time
- 6:00:55with you
- 6:00:56don't you guys remember fill out those
- 6:00:58polls we really do you know microsoft
- 6:01:00really pays attention to that stuff you
- 6:01:02know i know everywhere you go they're
- 6:01:03like oh yeah i fill out the poll
- 6:01:04no no we pay attention to that stuff if
- 6:01:07i get a vibe mark they'll fire me so
- 6:01:11just saying just
- 6:01:15it's been a true honor to be able to
- 6:01:17yeah exactly
- 6:01:18it's been a true honor to have the
- 6:01:20actual architect distinguished engineer
- 6:01:22jeffrey snover to be able to sit down
- 6:01:23and talk with us about powershell god
- 6:01:25knows i've learned a lot and now i have
- 6:01:26to go
- 6:01:27and study because now i've i've learned
- 6:01:30more and i have to study
- 6:01:31thank you sir this has been wonderful
- 6:01:33thanks a lot thanks a lot guys and
- 6:01:35thanks for joining us we're going to see
- 6:01:36at the next one
- 6:01:36scripting and tool making
- 6:01:45you
About this transcript
This page contains the full transcript of PowerShell For Beginners Full Course | PowerShell Beginner tutorial Full Course by Nerd's lesson, generated from the public captions YouTube serves with the video. The transcript has 68,278 words across 11,021 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.