YouTube2Text

PowerShell For Beginners Full Course | PowerShell Beginner tutorial Full Course — Transcript

by Nerd's lesson · 68,278 words · 11,021 segments · language en · Watch on YouTube

Full transcript

  1. 0:08[Music]
  2. 0:18good morning and welcome to the
  3. 0:19microsoft virtual academy and this is a
  4. 0:21special virtual academy jump start
  5. 0:23of getting started with the best one
  6. 0:25it's going to be the best one ever of
  7. 0:27getting started with powershell whether
  8. 0:28you're an it pro or even a dev
  9. 0:30this is the strongest most powerful
  10. 0:32management tool you have in your arsenal
  11. 0:34to take control of your network and
  12. 0:36we're going to take you through today
  13. 0:37step by step
  14. 0:38and when i say we well it's a very
  15. 0:41special training event today
  16. 0:42i'm jason helmick but this is the
  17. 0:45inventor of powershell
  18. 0:47distinguished engineer jeffrey snowberry
  19. 0:51and this is going to be a great event
  20. 0:52for for all of us today
  21. 0:54we're going to take you through step by
  22. 0:55step on how to get started and working
  23. 0:57with powershell
  24. 0:58and who better to learn it from than
  25. 1:00jeffrey snover so
  26. 1:01i'll tell you what jeffrey let's let's
  27. 1:03start out with some intro since there
  28. 1:04i'll flip the little slide thing in okay
  29. 1:07yeah so howdy i'm jeffrey snover um i'm
  30. 1:09a distinguished
  31. 1:10engineer and uh let's see so i you know
  32. 1:13start off the powershell team about 12
  33. 1:15years ago maybe a little bit more um and
  34. 1:19that worked out pretty well because
  35. 1:20after having shipped a couple versions
  36. 1:22they
  37. 1:22made me a distinguished engineer and
  38. 1:24then the lead architect for
  39. 1:26windows server 2012. awesome
  40. 1:29that worked out pretty well so now i'm
  41. 1:30the lead architect for windows server
  42. 1:33and system center data center products
  43. 1:34so
  44. 1:36having some fun oh boy having a lot of
  45. 1:38fun and with powershell and what we're
  46. 1:40going to talk about the windows
  47. 1:40management framework
  48. 1:41all of this bundled together not just in
  49. 1:44server 2012 but it works
  50. 1:45all the way backwards to 2003 so that we
  51. 1:48can
  52. 1:49we can do all of this management with
  53. 1:50everything that we have in our
  54. 1:51environment not just necessarily the
  55. 1:53latest and greatest that's the plan
  56. 1:55back to filling up your arsenal i like
  57. 1:57that term i like that term too
  58. 1:58that's turning out pretty good so let me
  59. 2:00tell you a little bit about myself
  60. 2:02i'm jason helmick i work with
  61. 2:04concentrated technologies i
  62. 2:06do this for a living i love to train i
  63. 2:07do powershell and i also work as an
  64. 2:09engineer and a consultant
  65. 2:11mainly doing a lot of automation with it
  66. 2:13uh author of a new book that's coming
  67. 2:15out
  68. 2:16learn windows iis in a month of lunch is
  69. 2:20tough title to say uh and it's not only
  70. 2:23about learning iis but it's
  71. 2:25using powershell for it so yeah just
  72. 2:27some uh interesting little tidbits about
  73. 2:29me
  74. 2:30truly what the best thing to know about
  75. 2:31me is i get to sit next to him
  76. 2:34so as we do this so this is gonna be a
  77. 2:36lot of fun
  78. 2:37let's start off with um showing you what
  79. 2:39we're gonna talk about today
  80. 2:41so as you can see from the agenda we're
  81. 2:43gonna cover several topics today and
  82. 2:44it's actually quite a few of them
  83. 2:46i'm gonna start off with one of my
  84. 2:47favorite ones which is don't fear the
  85. 2:49show you know i think a lot of
  86. 2:51it guys when they first get started with
  87. 2:53this i hear this all the time
  88. 2:55they they're scared to get started with
  89. 2:58powershell they're not used to a command
  90. 2:59line they don't say they're scared
  91. 3:01but they're not used to using a command
  92. 3:03line deep down
  93. 3:04they see that console window and they
  94. 3:06just like i don't know what to do yeah
  95. 3:08so one of the first
  96. 3:09headlights yeah so one of the first
  97. 3:10things we're going to want to do is
  98. 3:12get rid of some of that fear show you
  99. 3:14how straightforward you can get started
  100. 3:15with powershell
  101. 3:17and then we're going to take you into
  102. 3:19what powershell starts to look like
  103. 3:20and of course we're going to talk about
  104. 3:22the reasons why powershell even exists
  105. 3:23and there's some
  106. 3:25incredibly important ones so we'll also
  107. 3:27get into the help system probably one of
  108. 3:29the most important things that we do
  109. 3:30today
  110. 3:31the pipeline and extending the shell all
  111. 3:33of this stuff that we're going to do is
  112. 3:34going to make more sense as we hit it
  113. 3:36looking at what objects are
  114. 3:37and drilling into the pipeline what is
  115. 3:39that weird character i keep seeing
  116. 3:41between these commands and we'll get
  117. 3:44into one of the most important
  118. 3:45advantages that you have
  119. 3:46which will be uh powershell remoting
  120. 3:49which will let you do
  121. 3:50a lot of your stuff in scale that's
  122. 3:52where it gets fun that's where it really
  123. 3:53gets fun
  124. 3:54by the way so people should be uh doing
  125. 3:56these exercises with us so
  126. 3:58you know you should be at your computer
  127. 4:00fire up a powershell window and uh type
  128. 4:02along with us
  129. 4:03that's the way you get the most out of
  130. 4:05this course and actually i think that's
  131. 4:06the best way to get the most out of this
  132. 4:08is i i know you want to kick back and
  133. 4:10kind of you know
  134. 4:10sip some coffee or whatever and listen
  135. 4:12to us but keep your fingers close to
  136. 4:13that keyboard on that console
  137. 4:15um and powershell so you can work with
  138. 4:17us on this and you should be joining are
  139. 4:18you gonna tell them about the
  140. 4:19q a yeah yeah a matter of fact i got a
  141. 4:22slide coming up oh
  142. 4:23here let's do the expectations things on
  143. 4:25our target audience and then we'll
  144. 4:26talk about how to join us um the this
  145. 4:29was designed
  146. 4:30for it pros however if you're dev uh
  147. 4:33please join us on this this was designed
  148. 4:36for it pros
  149. 4:37to be a quick deep dive and get started
  150. 4:39with powershell there are so many
  151. 4:41guys out there right now and gals that
  152. 4:43are trying to get started with
  153. 4:44powershell
  154. 4:45and sometimes you find it really
  155. 4:47difficult well this is the ideas to get
  156. 4:48you through the difficulty and we're not
  157. 4:50just doing an introductory level we're
  158. 4:51going to go in pretty deep with using
  159. 4:53powershell
  160. 4:54and it doesn't matter what product you
  161. 4:56want to use it with whether you want to
  162. 4:57use it with active directory or
  163. 4:58sharepoint
  164. 4:59you got to know the tool and if you know
  165. 5:00the tool then the products are
  166. 5:02easy to deal with so if you're an it pro
  167. 5:05if you work in help desk if you're a
  168. 5:07developer interested in what powershell
  169. 5:09can do for you
  170. 5:10this is the place to be and as a couple
  171. 5:13of additional resources first of all we
  172. 5:14have chat available if you're all in on
  173. 5:16chat you can chat us questions and i'll
  174. 5:18constantly be reminding you to chat in
  175. 5:21questions
  176. 5:22we have an amazing support staff out
  177. 5:24there today
  178. 5:25a lot of the powershell mvps are joining
  179. 5:27us today
  180. 5:28to help answer questions and we'll be
  181. 5:30out there answering questions so we want
  182. 5:32you to join in
  183. 5:33and contribute and ask whatever
  184. 5:35questions you have and we'll do the best
  185. 5:36we can make sure you all get an answer
  186. 5:38to it
  187. 5:38yeah and the powershell community is is
  188. 5:40blessed with some fantastic
  189. 5:42mvps a number which are online and
  190. 5:44they'll be coming and
  191. 5:46going throughout the day so you know
  192. 5:48don't hesitate to ask questions you know
  193. 5:49you got some rock stars out there
  194. 5:51you certainly do and i also want to keep
  195. 5:53in mind that
  196. 5:54this particular virtual academy we're
  197. 5:57going to have a second session not the
  198. 5:58same thing we're going to go beyond this
  199. 6:00session
  200. 6:01further and further into scripting and
  201. 6:03tool making here in just a couple of
  202. 6:04weeks on august 1st right yeah
  203. 6:06it's going to be on august 1st so you
  204. 6:08want to join the mba community as a
  205. 6:10matter of fact you can join the mba
  206. 6:12community
  207. 6:13you get signed in online as you go
  208. 6:16through
  209. 6:16the videos that are available out there
  210. 6:18you get points and
  211. 6:20for right now you can get 50 special mva
  212. 6:23points if you put in the
  213. 6:24code that's at the bottom of the screen
  214. 6:27so make sure you keep track of what's
  215. 6:29going on with the mba community so that
  216. 6:30you can get
  217. 6:31more sessions just like this one
  218. 6:34i don't know i think we're ready to
  219. 6:36maybe let's go
  220. 6:38let's get into this my favorite topic i
  221. 6:40know this i just love talking about this
  222. 6:41so folks
  223. 6:42here we go we're going to get into uh
  224. 6:44don't fear
  225. 6:45the show come on you can hear the music
  226. 6:47right don't fear the don't
  227. 6:49fear the shell and in it okay maybe not
  228. 6:51yeah um okay we'll stop that then
  229. 6:54so look we're going to go through an
  230. 6:55overview of what powershell is white
  231. 6:56even exists and of course this is the
  232. 6:58great time for jeffrey to
  233. 7:00to help us out understand why we even
  234. 7:01have this and then we're going to start
  235. 7:02going into
  236. 7:04how to take some of the fear out of
  237. 7:05running powershell we'll show you how to
  238. 7:07get it installed and how to get it set
  239. 7:08up
  240. 7:09so let's rock and roll first of all the
  241. 7:11purpose of
  242. 7:12and i just want to point out can you see
  243. 7:13the slide yeah yeah look at you guys you
  244. 7:16see the you
  245. 7:16and the them that that picture you
  246. 7:18that's that's a picture of me when i was
  247. 7:20younger
  248. 7:21uh-huh i swear to no it's not really a
  249. 7:23picture in me so here's the idea
  250. 7:25you're sitting there struggling with the
  251. 7:27day-to-day events of everything that's
  252. 7:29around
  253. 7:30you you've got projects that you have to
  254. 7:32have done there are things that are on
  255. 7:33fire
  256. 7:34and everything's going right and you
  257. 7:35have them you have your your end users
  258. 7:37your boss
  259. 7:38all of these people that are that are we
  260. 7:40need this now we need this now
  261. 7:42and in microsoft environments this has
  262. 7:44been a challenge we've had some tools
  263. 7:47and you've had some scripting languages
  264. 7:49and we had vb
  265. 7:50script but there were certain
  266. 7:51limitations that would
  267. 7:53challenge us and it wasn't quite
  268. 7:56complete enough
  269. 7:57was also kind of hard and doing
  270. 8:00automation and solving problems
  271. 8:01was a huge challenge then came along
  272. 8:06this product that you made so why is it
  273. 8:09that
  274. 8:10what is it that you were trying to solve
  275. 8:11for all of us guys in i.t
  276. 8:13yeah you know when i came to the company
  277. 8:14i uh i said well you know we need an
  278. 8:16automation strategy and they said well
  279. 8:18we have an automation strategy i said
  280. 8:20really where and they said well you know
  281. 8:23here and it was vbscript it's like uh no
  282. 8:26my friends that's not an automation
  283. 8:27strategy
  284. 8:28and they said well here you know we've
  285. 8:29got these great apis like no my friend
  286. 8:32that's not
  287. 8:32automation i don't like the sound of
  288. 8:34that exactly
  289. 8:36and so what i knew was that we needed to
  290. 8:39have an interactive shell
  291. 8:41an environment that someone would say
  292. 8:42hey go explore the system try this try
  293. 8:45that try that
  294. 8:46be able to get things done and then from
  295. 8:48there the idea is like hey
  296. 8:50i i notice i do type the things over and
  297. 8:53over and over again
  298. 8:54why don't i put it in a script and just
  299. 8:56run it from there
  300. 8:58and then say well you know that's great
  301. 9:00now it's you know
  302. 9:01reduced my repetitive strain injury and
  303. 9:04i'd like to parameterize it oh i'd like
  304. 9:06to parameterize it now i can
  305. 9:08use it for a wider range of things and
  306. 9:09now i'd like to share it with you
  307. 9:11and now we'd like to use it to manage
  308. 9:13thousands of machines
  309. 9:14so we had this model we called it the
  310. 9:16develop or the admin development model
  311. 9:19which really you know bruce payet
  312. 9:20superstar bruce he says
  313. 9:22uh the the average lifetime of a command
  314. 9:25line script
  315. 9:26or sort of a script um starts at the
  316. 9:28prompt and
  317. 9:29ends at the the carriage return that it
  318. 9:31was very important that it be an
  319. 9:32interactive environment so that you can
  320. 9:34explore and honestly have fun
  321. 9:36i mean if there's two things you get out
  322. 9:38of today's session one
  323. 9:39is a spirit of exploration hey this is a
  324. 9:42great environment to go explore explore
  325. 9:44explore
  326. 9:45and then two just how much fun it is i
  327. 9:47mean it's just a blast to be able to
  328. 9:49to use and then from there to be able to
  329. 9:52automate
  330. 9:52you know automate automate automate you
  331. 9:54know if we had just transformed
  332. 9:56you know a click click click experience
  333. 9:58to a click click experience
  334. 10:00like okay that's good like lots of
  335. 10:02people prefer this
  336. 10:03over over this but you really
  337. 10:06wouldn't have transformed the platform
  338. 10:09it's the ability to then do this this
  339. 10:11and this and then say
  340. 10:12save right and then just say click
  341. 10:16and run and i and i i just want to
  342. 10:17emphasize that
  343. 10:19we're unaccustomed in windows
  344. 10:21environments of having an
  345. 10:22interactive shell a real time solve your
  346. 10:25problem tool i mean we've always had
  347. 10:27basic commands but that really wasn't
  348. 10:29solving our problem
  349. 10:30this means solve your problem and then
  350. 10:33literally
  351. 10:34copy paste or hit save and now you can
  352. 10:37automate it
  353. 10:38and it doesn't require any more than
  354. 10:41have fun
  355. 10:42finding and solving the problem and now
  356. 10:44i'm on my way
  357. 10:45yeah you know i mean you might say well
  358. 10:47why do i need to do that
  359. 10:49and the answer is because everybody's
  360. 10:50scenario's different
  361. 10:52so we were talking in the car last night
  362. 10:54about how well hey in
  363. 10:55exchange you know the gui you know
  364. 10:58honestly we spent a lot of time talking
  365. 10:59to customers and trying to understand
  366. 11:01the scenarios and put that into the gui
  367. 11:03so that you just click click click
  368. 11:04but the reality is and jason was telling
  369. 11:06me the story about hey
  370. 11:07i did that but then what i needed to do
  371. 11:09was i needed to have different quotas
  372. 11:11for these
  373. 11:11types of users versus those types of
  374. 11:13users versus those types of users
  375. 11:15and uh and and the gui didn't help me
  376. 11:18you know i had to go
  377. 11:19do a ton of clicking so we might have
  378. 11:21gone and said oh well okay we'll add
  379. 11:23that to the gui
  380. 11:24but then all of a sudden if you try and
  381. 11:25deal with everybody's scenarios in the
  382. 11:27gui
  383. 11:27it becomes big and it becomes complex
  384. 11:29and it becomes hideous
  385. 11:30and then you can't use the gui and i
  386. 11:33think that that's one of the uh
  387. 11:35biggest issues that people will will
  388. 11:37start to see at first is that
  389. 11:39the graphical there's nothing wrong with
  390. 11:41using a graphical interface
  391. 11:42i mean sometimes i use it too i and i
  392. 11:44use it for things that i just need to do
  393. 11:46once one off once every blue moon you
  394. 11:49know creating a site link in active
  395. 11:51directory
  396. 11:52the graphical is great for that but when
  397. 11:53you have business challenges that can't
  398. 11:55be met
  399. 11:56such as and i think what we were talking
  400. 11:57about last night was i needed to set the
  401. 12:00mailbox limits of
  402. 12:01a particular ou in active directory well
  403. 12:04the graphical doesn't support that and i
  404. 12:05don't expect microsoft to solve that
  405. 12:07problem for me because
  406. 12:09how are they supposed to know what my
  407. 12:10issues are powershell is the way that
  408. 12:13you can solve those issues and that you
  409. 12:15can
  410. 12:15get these business problems solved and
  411. 12:17it doesn't take six months you get them
  412. 12:19solved right now
  413. 12:20and then you automate them so the
  414. 12:22purpose to powershell really is all
  415. 12:23about
  416. 12:24making you more effective getting stuff
  417. 12:26done faster
  418. 12:27and solving problems that you probably
  419. 12:30had a hard time solving before
  420. 12:32so because often they're unique yeah
  421. 12:34very unique
  422. 12:35so let's see here installing powershell
  423. 12:38now
  424. 12:38right now there's there's a lot of it's
  425. 12:40kind of confusing for a lot of folks
  426. 12:43first of all let's talk about some of
  427. 12:44the versions of powershell nobody should
  428. 12:45have v1
  429. 12:46right now right can we you should
  430. 12:48upgrade
  431. 12:49you've got to release okay so v2 um
  432. 12:53came out a couple of years ago right
  433. 12:55yeah a couple years ago
  434. 12:56and you should have v2 on windows 7 and
  435. 12:59you should have it on 2000 a 2008 r2
  436. 13:02um and v2 also works and is is part of
  437. 13:05the update stream that you can uh
  438. 13:07update for windows xp and shame on you
  439. 13:09if you still have windows xp
  440. 13:10and of course server 2003
  441. 13:13now v3 is the new one and v3 came out
  442. 13:17for windows 8
  443. 13:18and for server 2012. if at all possible
  444. 13:22as the administrator
  445. 13:24you want v3 on your box and you're going
  446. 13:26to see plenty of examples of that today
  447. 13:27oh yeah of needing to have v3
  448. 13:30you can upgrade v3 um and have that on
  449. 13:32your box for both
  450. 13:34the uh uh uh windows 7 and
  451. 13:38server 2008 r2 and that's it though
  452. 13:40right windows server 2008
  453. 13:422008 2008 r2 and 2008 r2 i got to make
  454. 13:45sure i get all them all in there
  455. 13:47so you can upgrade to v3 now you don't
  456. 13:49have to rush right out right now and
  457. 13:50start upgrading your servers
  458. 13:52to v3 and you should take some cautions
  459. 13:55out there there are some products that
  460. 13:56aren't quite ready to handle v3 and
  461. 13:58there's plenty of information on that so
  462. 14:00don't be that guy or gal that makes that
  463. 14:02mistake and accidentally upgrade a
  464. 14:04server
  465. 14:05to v3 if the product running on it is
  466. 14:07not ready for it but on your
  467. 14:09administrative machine
  468. 14:10you got to have v3 you're going to love
  469. 14:12the features we show you today with it
  470. 14:13yeah you should always read the release
  471. 14:14notes you know we tell you what what it
  472. 14:16works with
  473. 14:17if you have this don't install that yeah
  474. 14:19release notes are really good along with
  475. 14:22you know testing is also really good um
  476. 14:24as well
  477. 14:25um if you take a look at the slide real
  478. 14:26quick you'll see that there's a place
  479. 14:28where you can download it's a strange
  480. 14:29name to download uh powershell three
  481. 14:31it's called the windows management
  482. 14:32framework
  483. 14:33we're gonna talk a lot more about what
  484. 14:34the what the term the windows management
  485. 14:36framework means it's not just powershell
  486. 14:38and there's a link there for you so that
  487. 14:40you can get it downloaded now if today
  488. 14:42you have v2 on your laptop you'll be
  489. 14:44fine
  490. 14:44but probably during lunch you're going
  491. 14:46to want to use v3
  492. 14:48and just to let you guys know so that we
  493. 14:49can get the confusion out of the way
  494. 14:51what we're doing today
  495. 14:52is how to use powershell what we show
  496. 14:54you how to use today
  497. 14:55is going to work on v2 v3
  498. 14:59and that mythical thing that's coming
  499. 15:00out sometime in the future
  500. 15:02v4 ish like stuff so you're
  501. 15:05going to be just fine with without
  502. 15:08whatever version you have that's we're
  503. 15:10going to be using
  504. 15:10it's all going to be about the tool
  505. 15:12today so
  506. 15:14well let's talk about launching
  507. 15:15powershell how do you find powershell to
  508. 15:17launch it and guys i'm actually going to
  509. 15:19demonstrate this off of my box real
  510. 15:20quick
  511. 15:22one of the most interesting things here
  512. 15:24is if you're on windows 8
  513. 15:26you have this magnificent windows key
  514. 15:28that brings up
  515. 15:29your desktop for you and to find
  516. 15:31powershell it's actually very simple
  517. 15:33just start
  518. 15:34typing the word powershell
  519. 15:37now i have to tell you the first thing
  520. 15:39that i always do is right click and pin
  521. 15:41this
  522. 15:42to my taskbar i need to you'll have this
  523. 15:45you're going to have
  524. 15:46powershell open more than anything else
  525. 15:49that you work with so
  526. 15:50you want to make sure you right click
  527. 15:51and get this guy pinned i've already got
  528. 15:53mine penned
  529. 15:54down here on my desktop so that you can
  530. 15:57see it now if you're working with
  531. 15:59um a pre windows 8
  532. 16:03operating system you're going to have to
  533. 16:05click on the start menu and i've got a
  534. 16:07screenshot of what that looks like here
  535. 16:09in the slides
  536. 16:11you'll click on the start menu as soon
  537. 16:12as i can figure out how to bring the
  538. 16:13slide back
  539. 16:14up it's this guy over here you're going
  540. 16:16to go under accessories and then
  541. 16:17windows powershell will be at the bottom
  542. 16:20and you're going to notice that there
  543. 16:21are two kinds of them out here you're
  544. 16:22going to see some repeats x86 versus
  545. 16:25ones that aren't x86
  546. 16:27the x86 are obviously the 32-bit
  547. 16:29versions you don't want to run those you
  548. 16:30want to run the
  549. 16:3164-bit version on your 64-bit os
  550. 16:35and we'll talk a little bit later about
  551. 16:36the ise but this is a great scripting
  552. 16:38editor
  553. 16:38that we can use as well so as long as
  554. 16:42you got powershell ready to go
  555. 16:43then we're ready to start to work with
  556. 16:45it rock and roll baby
  557. 16:47now let's talk a second about comfort
  558. 16:51comfort is important like these chairs
  559. 16:53right here
  560. 16:54in this studio are very very comfortable
  561. 16:56and that's very nice
  562. 16:58we're going to spend a lot of time and
  563. 16:59i'm rocking back and forth because
  564. 17:01they're so comfortable
  565. 17:01swaying swaying we're going to spend a
  566. 17:04lot of time
  567. 17:06looking at this console yep and
  568. 17:08powershell uses
  569. 17:10does he use every possible character on
  570. 17:12the keyboard
  571. 17:13no actually there's the up arrow
  572. 17:16great it's the up arrow that we don't
  573. 17:20use
  574. 17:20oh that's awesome well guys this is what
  575. 17:22i'm talking about
  576. 17:24first of all let me launch powershell
  577. 17:25and show this to you now i'm going to
  578. 17:27launch it i'm logged in as a regular
  579. 17:28user account
  580. 17:30and i want you to notice when i launch
  581. 17:31powershell the first thing you take a
  582. 17:32look at the top of the screen here see
  583. 17:33how it says windows powershell
  584. 17:35if you want to do some administration
  585. 17:36that's not what you want it to say so
  586. 17:38let me close this and show you
  587. 17:40if you're in as a regular user account
  588. 17:41you want to right click and do run as
  589. 17:43administrator if you're an administrator
  590. 17:44it'll already launch it
  591. 17:46with administrator if not it'll prompt
  592. 17:48you for credentials so that you can
  593. 17:50have administrative access we're going
  594. 17:52to talk about security later but this is
  595. 17:53actually an important thing
  596. 17:55notice as i'm looking at the console
  597. 17:57right now
  598. 17:58this is something that we're going to be
  599. 18:00staring at for a long time
  600. 18:02so there's a couple of things that you
  601. 18:03definitely want to be able to tell the
  602. 18:04difference in
  603. 18:06by the way one of the tricks there is if
  604. 18:08um if you're trying to do something
  605. 18:10and it's not working like this morning
  606. 18:12or trying to set some things up
  607. 18:14and i did get vm and it there was it
  608. 18:17showed me nothing
  609. 18:18i was like oh do i have the wrong
  610. 18:20machine did i provision this i recently
  611. 18:22provisioned it did i
  612. 18:23like forget to set things up and then i
  613. 18:25looked and i saw that i wasn't in
  614. 18:26admin mode so then you bring it up in
  615. 18:29admin mode and i said get vm and you see
  616. 18:31all your vms
  617. 18:32so if something's going a little wonky
  618. 18:33go check and uh
  619. 18:35see that you are running his admin and i
  620. 18:37just have to say that we're gonna be
  621. 18:38doing
  622. 18:39several things today and out of those
  623. 18:40things that we're doing today
  624. 18:42if you're not in administrative mode it
  625. 18:44isn't going to work it's going to be
  626. 18:46very wonky you're going to get error
  627. 18:47messages
  628. 18:48access denied messages and so you want
  629. 18:51to make sure you're in as administrator
  630. 18:52mode
  631. 18:53take a look at the characters i have on
  632. 18:55the screen can you see the difference
  633. 18:57on your screen with those characters you
  634. 18:59zoom it
  635. 19:00well no i i want them to look at it and
  636. 19:02go i can't tell the difference
  637. 19:03oh i want them to go no i don't know
  638. 19:05what it is don't you zoom it yeah don't
  639. 19:07use it with that
  640. 19:07um this is important you need to make
  641. 19:10sure that this screen
  642. 19:11you can see these individual characters
  643. 19:13i've got a grave character or a backtick
  644. 19:16character
  645. 19:17and then a single quote and there's only
  646. 19:18a couple of pixels in difference
  647. 19:20so here's actually one of the most
  648. 19:22important things to do when you're
  649. 19:23getting ready to use
  650. 19:24powershell i'm going to go in here to
  651. 19:26the properties and we're going to adjust
  652. 19:27this console
  653. 19:28now i'm not going to change mine because
  654. 19:30that'll screw all the views up but let
  655. 19:32me kind of show you the idea here
  656. 19:34under fonts you want to use a font that
  657. 19:37is
  658. 19:38nice and bold and thick and they gave
  659. 19:40you one called lucida console did
  660. 19:42i did i say that right you see concert i
  661. 19:45i have no idea
  662. 19:46consoles lucida
  663. 19:49nevermind that's okay consoles is a nice
  664. 19:52font but it's thinner i prefer the
  665. 19:54heavier weight font
  666. 19:55and then you want to adjust the font
  667. 19:56size but when you do that
  668. 19:59to get it to a nice font size you're
  669. 20:00going to notice in this preview pane
  670. 20:02that the pretty powershell window is
  671. 20:04going to extend to the right
  672. 20:05and go to the bottom and these are all
  673. 20:07bad things and let me tell you why
  674. 20:09when powershell is giving you
  675. 20:10information it wants to
  676. 20:12sometimes put information all the way to
  677. 20:14the right and all the way at the bottom
  678. 20:16and so if your screen has extended
  679. 20:19beyond the boundaries of your desktop
  680. 20:21you're not going to see anything so and
  681. 20:24you don't want scroll bars all over the
  682. 20:26place so let me show you how to fix that
  683. 20:28oh you don't use bold i always use bold
  684. 20:30do you use bold always
  685. 20:32really yeah that scares me oh because it
  686. 20:34feels like it's yelling at me or
  687. 20:36something
  688. 20:37okay well you want to turn the bullet on
  689. 20:40i always do
  690. 20:40okay let's turn bold on i find well
  691. 20:42here's the deal when you present
  692. 20:44if any of you ever present to the the
  693. 20:46audience always use bold
  694. 20:48because then it's just easier to read
  695. 20:50like a couple hundred females
  696. 20:52i don't want to turn it on now okay okay
  697. 20:55now in layout guys layout is where
  698. 20:57you're going to adjust
  699. 20:58your screen width and so that it fits
  700. 21:02and then what you want to do is fit just
  701. 21:03like this in the preview window
  702. 21:05let me show you two things the window
  703. 21:06size for width is right here and that'll
  704. 21:08adjust its width and i'll screw mine up
  705. 21:10for a second
  706. 21:12and see how it's kind of going off to
  707. 21:13the the right over there
  708. 21:15you don't want that you want your width
  709. 21:16so that it fits so you don't have a
  710. 21:18horizontal i think that's this way
  711. 21:19horizontal
  712. 21:20scroll bar when you adjust the window
  713. 21:24width size you also want to make sure
  714. 21:25that you keep the buffer size you don't
  715. 21:27want things going off into the buffer
  716. 21:28where you'll never be able to see it
  717. 21:30height is an important one as well i
  718. 21:32want you to notice as i scroll up and
  719. 21:33down this height
  720. 21:35what i don't want to do is scroll that
  721. 21:37all the way below my desktop because
  722. 21:39then when you see data
  723. 21:40data will get put down at the very
  724. 21:42bottom and you won't see it so i want it
  725. 21:44to fit on my desktop
  726. 21:45a vertical scroll bar you'll have will
  727. 21:47be okay
  728. 21:48make sure that for the height buffer
  729. 21:50size you get at least three
  730. 21:523000 or greater and i want to warn you
  731. 21:54that when you're working with some
  732. 21:55products that have a powershell console
  733. 21:57that console is set to 300 by default so
  734. 22:00you definitely want to change that
  735. 22:02you're going to lose information and not
  736. 22:03be able to scroll back and see it
  737. 22:05when it comes to colors oh dude
  738. 22:08i'm not changing the colors because i
  739. 22:10like the color scheme you picked out
  740. 22:12i mean you could i mean but you know if
  741. 22:14you want to change the colors to
  742. 22:15something that you like to read
  743. 22:17you know you want to make it green
  744. 22:18screen or whatever or
  745. 22:20come up with some weird color
  746. 22:22combination knock yourself out but i'm
  747. 22:24going to leave it at the default color
  748. 22:25size the important thing is good
  749. 22:27yeah i know i thought the yellow would
  750. 22:28look great the important thing is
  751. 22:30is that your console is now ready to go
  752. 22:33and it's all set up and it's in a
  753. 22:35comfortable font so while we move on
  754. 22:37take a second and make sure that you've
  755. 22:39got a nice looking powershell
  756. 22:41console to take a look at so let's see
  757. 22:44what we're doing next here i think we're
  758. 22:45ready to kind of
  759. 22:47get into some demonstration stuff
  760. 22:50yeah yeah this is lucky lucky lucky
  761. 22:55oh man that's old and you get like this
  762. 22:57milk mustache going i just like this is
  763. 22:59great get powershell this is awesome
  764. 23:01so let's talk a little bit um and start
  765. 23:04off by taking some of the fear out of
  766. 23:06powershell before we talk about this
  767. 23:08this magic word commandlet um
  768. 23:12you needed to come up with your own
  769. 23:15commands
  770. 23:16not the windows native ones you needed
  771. 23:17your own commands
  772. 23:19why the term commandlet yeah so there's
  773. 23:22two answers to that
  774. 23:23so first is that uh powershell um
  775. 23:27we want to have a model of composition
  776. 23:30okay and so the model of composition if
  777. 23:32you actually take a look at it
  778. 23:34the commands that you write are really
  779. 23:36really really small
  780. 23:37and the idea is that then you leverage
  781. 23:40the engine to do common processing
  782. 23:43so if you had each one of the
  783. 23:45commandlets try and do big tasks by
  784. 23:48themselves
  785. 23:48i want to get things and i want to
  786. 23:50process things and i want to format them
  787. 23:52then every developer would be doing
  788. 23:53things differently right you know
  789. 23:55oh well i like the term sort and you
  790. 23:58like the term order and order by and all
  791. 24:00that and so
  792. 24:01so he said no no you write the things
  793. 24:03that you
  794. 24:04and only you can use do and then
  795. 24:07leverage the engine to do everything
  796. 24:09else okay and so these commands got
  797. 24:12really really small and that was the
  798. 24:13whole point they're really really small
  799. 24:16and you use the pipeline to do bigger
  800. 24:18tasks
  801. 24:19and because of that you get or you get a
  802. 24:22a
  803. 24:22regularity that is to say you're going
  804. 24:24to learn something and then you can use
  805. 24:26it over
  806. 24:26and over and over again so that's where
  807. 24:28the term commandlet came from
  808. 24:30but then when we went to bring it out
  809. 24:32the documentation people said
  810. 24:34no way you can't do that we don't make
  811. 24:36up terms
  812. 24:37it's called command that's like well no
  813. 24:40we're going to call it command line
  814. 24:41and they just went to the mall it's like
  815. 24:42no no no no i said i'll tell you what
  816. 24:45bring up a a a search window okay say
  817. 24:48search for command and there was like x
  818. 24:51hundred million things
  819. 24:52i said now search for commandlet and it
  820. 24:54was x
  821. 24:55thousand i said every single one of
  822. 24:57those is related to powershell
  823. 24:59and they're like oh search engine
  824. 25:00optimization there you go a little
  825. 25:03seo on the exact using the term camel
  826. 25:06and i just have to say that
  827. 25:07my wife refers to them as kimblets
  828. 25:09because that's the way they're
  829. 25:11they're spelled but at any rate
  830. 25:12commandlets now the
  831. 25:14the how a commandlet looks is also kind
  832. 25:16of bizarre
  833. 25:17if you've never been at the the command
  834. 25:20i mean if you've been at the command
  835. 25:21line
  836. 25:21you see dir but now you're seeing these
  837. 25:24well we've got verbs and we've got this
  838. 25:26dash and we've got this now and
  839. 25:27why did you so a lot of people take a
  840. 25:30look at powershell and they say oh you
  841. 25:31know ver looks very much like unix right
  842. 25:33and by the way it's just you know we
  843. 25:35actually tried to to use unix right we
  844. 25:37didn't uh
  845. 25:38start off wanting to invent something we
  846. 25:40started off saying i gotta solve a
  847. 25:41customer problem
  848. 25:43and so there were some really great
  849. 25:44tools out there the unix tools so my
  850. 25:46first effort was to get those tools
  851. 25:47available on windows
  852. 25:49but it turned out that that didn't work
  853. 25:51and the reason why is because unix
  854. 25:53is very much of a document oriented
  855. 25:56operating system which is a lot of the
  856. 25:58management is done through
  857. 25:59documents or files whereas windows is an
  858. 26:02api oriented operating system
  859. 26:05okay now both have their advantages but
  860. 26:07here's the thing the management's
  861. 26:09completely different
  862. 26:10so when i got bash and awk and sudden
  863. 26:13grep available on windows okay
  864. 26:16it didn't help that much right why
  865. 26:18because then you go and you say awk
  866. 26:20awk doesn't work against the registry
  867. 26:22grep doesn't work against
  868. 26:24wmi sed doesn't work against uh uh
  869. 26:27active directory and so in in unix those
  870. 26:30those tools those text manipulation
  871. 26:32tools
  872. 26:32are management tools but on windows
  873. 26:34they're just text manipulation tools and
  874. 26:36there's not much text so
  875. 26:38they didn't help so we had to invent our
  876. 26:40our own stuff
  877. 26:41and so then the question is okay well we
  878. 26:43want to invent as little as possible
  879. 26:46uh and so we leveraged a lot of the
  880. 26:48technology a lot of the
  881. 26:49the concepts of unix the compositional
  882. 26:51model
  883. 26:52but unix you love unix guys did a great
  884. 26:55job
  885. 26:56on the other hand it has weaknesses as
  886. 26:58well and this is an area where we
  887. 27:00looked more to vms dcl or the as400
  888. 27:04they have very good production-oriented
  889. 27:06environments
  890. 27:07and they were extraordinarily regular in
  891. 27:10their environments
  892. 27:11which is to say you had verb-noun
  893. 27:14and then this well-defined set of of
  894. 27:17parameters and what happened the first
  895. 27:19time i learned it right
  896. 27:20i was a unix guy for a long time and
  897. 27:22then i had to do
  898. 27:23vms and i got on i was like i hate this
  899. 27:26thing i despise this thing it's a piece
  900. 27:28of
  901. 27:29junk and i would go around telling
  902. 27:31everyone this and it's like okay but i
  903. 27:32got to do it for my job and i try
  904. 27:34somewhere and i just i
  905. 27:35hate it and at some point i just had to
  906. 27:37like
  907. 27:38sit myself down and like put your big
  908. 27:40boy pants on jeffrey
  909. 27:42you gotta learn this and says like okay
  910. 27:44stop
  911. 27:45get out of your head condemning things
  912. 27:47just like
  913. 27:48experience it and so about an hour later
  914. 27:51i'm like hey you know this thing's
  915. 27:52pretty cool
  916. 27:53and then all of a sudden two hours later
  917. 27:55it's like something new comes up and
  918. 27:57and having learned a set of things i
  919. 27:58said boy i wonder if that works and it
  920. 28:00worked
  921. 28:00so what happened was you learned this
  922. 28:02schema right
  923. 28:04verb dash noun or slash is there but
  924. 28:06then
  925. 28:07it was the schema you learned it once
  926. 28:08and then you were able to do it over and
  927. 28:10over and over again
  928. 28:11and that was the joke at deck at deckley
  929. 28:14used to say hey
  930. 28:15somebody put a fish finder on the vax
  931. 28:16can you manage it and they're like sure
  932. 28:18show fish finder get fish finder slash
  933. 28:20no log slash confirm
  934. 28:22and i think that's really i mean that's
  935. 28:24the epitome of what's going to help us
  936. 28:25all out
  937. 28:26not only today but going forward is the
  938. 28:28fact that you get used to
  939. 28:30i want to work with x well i know that
  940. 28:32i've got these common verbs that i'm
  941. 28:34going to use i'm going to be able to get
  942. 28:35this i'm going to be able to set this
  943. 28:37you know change it i'm going to be able
  944. 28:38to new create something new
  945. 28:41and i think that's very important and i
  946. 28:43started out in as400 and my
  947. 28:45my my first um well i was being trained
  948. 28:48my first
  949. 28:48there was a problem and my first thing
  950. 28:50was can't we just reboot it
  951. 28:52and i thought the operator was going to
  952. 28:54punch me when i
  953. 28:56said so yeah he should have so hey guys
  954. 28:58let me show you uh what these
  955. 28:59commandments are take a look at my
  956. 29:00current directory location now if i was
  957. 29:02in
  958. 29:03something like dos you guys know that i
  959. 29:04could do cd backslash but we have
  960. 29:06commandlets now so watch set dash
  961. 29:08location c calling backslash
  962. 29:11yeah that's cool now if i wanted to get
  963. 29:14something like a directory listing in
  964. 29:16dos you guys know you can do dir but
  965. 29:18here's the interesting thing we have
  966. 29:19commandlets for this so get
  967. 29:20child item will give me a directory
  968. 29:23listing if i want to clear the screen if
  969. 29:24this was dos we'd do cls but we have a
  970. 29:26commandlet for that called clear
  971. 29:28dash host please tell me that you're not
  972. 29:32impressed yet
  973. 29:34yeah i think we got the guys in the back
  974. 29:35there going yeah that was
  975. 29:38let's start to take the fear out of
  976. 29:39powershell one of the the things that
  977. 29:41helped me tremendously
  978. 29:42especially when i got started with
  979. 29:44powershell was that
  980. 29:46yes there are commandlets and yes we're
  981. 29:48going to show you how to discover
  982. 29:49and learn and use those commandlets but
  983. 29:51you can start using powershell right now
  984. 29:54even if you don't know those commands
  985. 29:55let me show you this is kind of
  986. 29:56interesting i'm going to close my shell
  987. 29:58and reopen it again
  988. 30:01and so if i want to change from this
  989. 30:03directory location back to the root of c
  990. 30:06cd oh it worked if i want to get a
  991. 30:08directory listing
  992. 30:11dir worked just perfect if i want to
  993. 30:13clear the screen
  994. 30:14cls see it's working as i would expect
  995. 30:17and here's the interesting thing
  996. 30:19let's see if i was a unix guy how would
  997. 30:21i get a directory listing
  998. 30:22um ls um how would i clear the screen
  999. 30:25well
  1000. 30:26clear it's it's it's
  1001. 30:29doing unix stuff and it's doing windows
  1002. 30:31stuff and it's
  1003. 30:32it's making me happy because i can be a
  1004. 30:35windows guy and i can sit down and start
  1005. 30:36using powershell
  1006. 30:38a unix guy can sit down and start being
  1007. 30:40using powershell
  1008. 30:41my question is is why is that working
  1009. 30:43yeah so what we do is we got a regular
  1010. 30:45uh experience right
  1011. 30:47so you've got get child items set
  1012. 30:50location etc
  1013. 30:51and you can always back use those things
  1014. 30:53and then what we did was we put
  1015. 30:54personalities on it which is to say we
  1016. 30:57knew that unix guys would be coming to
  1017. 30:58this we knew that dos guys would come
  1018. 31:00into this
  1019. 31:00and so we have aliases and so uh the
  1020. 31:03aliases
  1021. 31:04uh as much as possible we wanted
  1022. 31:05people's first experience to not be a
  1023. 31:08frustrating one that they try a set of
  1024. 31:09things and they just work ps
  1025. 31:11continues to work exactly and i think
  1026. 31:13this is one of the interesting things is
  1027. 31:16is that they're aliases and they just
  1028. 31:17think of them as shortcuts
  1029. 31:19to real commandlets okay so we're we're
  1030. 31:22not
  1031. 31:23using the actual ls command or anything
  1032. 31:26it's pointing to a powershell commander
  1033. 31:28but the idea was i love your use of the
  1034. 31:30term personalities
  1035. 31:31we built personalities into this is that
  1036. 31:33it makes it comfortable for whatever
  1037. 31:35environment you're coming from so that
  1038. 31:36you can get started right away
  1039. 31:38as a matter of fact let me just kind of
  1040. 31:39show you get dash alias
  1041. 31:42gives you a list of the current aliases
  1042. 31:45by the way you guys should print this
  1043. 31:46out and memorize this in the next few
  1044. 31:47minutes so
  1045. 31:48it's you have all the aliases but this
  1046. 31:51is what allows you to
  1047. 31:52start working and you know things like
  1048. 31:54making a directory i can make a
  1049. 31:55directory oh boy
  1050. 31:56see i can go right to work right away
  1051. 31:58and this starts to bring us to another
  1052. 31:59oh
  1053. 32:00we're going to talk if you're if you're
  1054. 32:01a unix guy you'd use
  1055. 32:03victor right right so let's see let's
  1056. 32:05see make
  1057. 32:06dirt this works jeffrey
  1058. 32:10awesome it's it's
  1059. 32:14it's all that easy um so basically your
  1060. 32:18normal command line experience you can
  1061. 32:20bring right to powershell but wait
  1062. 32:22there's more okay yes there's more
  1063. 32:26there's more get a ginsu knife out of
  1064. 32:28this
  1065. 32:28even better than against a knife now
  1066. 32:30first of all i just want to kind of
  1067. 32:31point out that
  1068. 32:32we're going to talk about help
  1069. 32:34extensively but if you want to get help
  1070. 32:36you can type help and if you're a unix
  1071. 32:39person and want to type help you can
  1072. 32:40type man now personally i think
  1073. 32:42you know unix is kind of sexist for the
  1074. 32:44whole man thing but in powershell if you
  1075. 32:46want to get a list of
  1076. 32:47if you want to get a list of aliases you
  1077. 32:49can type get dash alias
  1078. 32:51but there's an alias for get alias
  1079. 32:53called called gal and see this is what
  1080. 32:55makes me so happy is that
  1081. 32:56powershell isn't sexist so you should
  1082. 32:57use this um anyways
  1083. 33:00let me show you stupid but
  1084. 33:03so here's where it gets really cool
  1085. 33:08you know what i can do from powershell
  1086. 33:09besides working in an environment that
  1087. 33:11already kind of feels comfortable
  1088. 33:12with me i can i can use windows native
  1089. 33:15commands i love this ping
  1090. 33:20a computer and it works this is so
  1091. 33:23awesome yeah
  1092. 33:24i can run notepad i can i can i oh yeah
  1093. 33:27i know everybody's impressed now i can
  1094. 33:28oh look calculator
  1095. 33:30and oh hey you know what i haven't tried
  1096. 33:31this yet on windows 8 i should try this
  1097. 33:33can i run do we still have ms paint oh
  1098. 33:36this is awesome so we still
  1099. 33:39okay but the point was this is that
  1100. 33:43you can still use your windows native
  1101. 33:44commands in here you guys are always
  1102. 33:46checking you know ipconfig and all that
  1103. 33:48stuff
  1104. 33:49don't don't be that guy or that gal i i
  1105. 33:52have to tell you this is one of the
  1106. 33:53funniest things i have
  1107. 33:54i was teaching an advanced scripting
  1108. 33:56class for for powershell this guy
  1109. 33:57i've known him a long time was writing
  1110. 33:58this magnificent tool
  1111. 34:00to go out and do a bunch of things to a
  1112. 34:02couple of computers
  1113. 34:04and he said you're going oh my script's
  1114. 34:06broke can you help me and i'm like
  1115. 34:07what's your problem he says well the
  1116. 34:09scripts broke and because
  1117. 34:10it's getting those two machines but it's
  1118. 34:12not getting anything from that machine
  1119. 34:14and one time i said well first of all
  1120. 34:16don't forget you're an engineer
  1121. 34:18what do you what do you usually do if a
  1122. 34:20machine's not responding how do you
  1123. 34:22test that and he says oh oh
  1124. 34:25i'll ping it i'm like yeah see if it's
  1125. 34:27even turned on very good very good
  1126. 34:29so he's sitting at a powershell console
  1127. 34:31no
  1128. 34:32you know what he did yes start programs
  1129. 34:35accessories opened up command
  1130. 34:37prompt to type ping i literally looked
  1131. 34:40at him
  1132. 34:40and went get out
  1133. 34:42[Laughter]
  1134. 34:44so the idea guys is you have your
  1135. 34:46windows native commands
  1136. 34:49and they work the way that you expect
  1137. 34:50them to work so that you have an
  1138. 34:52environment to get started in so
  1139. 34:54between aliases helping you out and
  1140. 34:57between running windows native commands
  1141. 34:59the idea is open up powershell don't
  1142. 35:01open up the command prompt
  1143. 35:02open up powershell and start using
  1144. 35:04powershell because you're going to start
  1145. 35:06then learning the commandlets and
  1146. 35:08which we're going to do today but you're
  1147. 35:10going to start learning the commandlets
  1148. 35:11and make your learning curve much
  1149. 35:12easier this way it was designed for you
  1150. 35:14to do it this way
  1151. 35:16and so make your life easy and just go
  1152. 35:18ahead and start using it and make sure
  1153. 35:19you show your other administrative
  1154. 35:20friends
  1155. 35:21open up the shell and start using it
  1156. 35:23it's going to work
  1157. 35:24for you so at least that's taking a
  1158. 35:27little bit of the fear out of it
  1159. 35:28let's hope so besides having aliases and
  1160. 35:32all that kind of good stuff folks we
  1161. 35:34want to do kind of a reminder for you
  1162. 35:37oh wait can you go back oh yeah i can go
  1163. 35:38back yeah can i can can i show you
  1164. 35:39something
  1165. 35:40you can go to my screen okay
  1166. 35:44hoo-ha perfect let's see okay so i don't
  1167. 35:47know if you know this but uh so
  1168. 35:48the aliases right so you saw aliases for
  1169. 35:51gal pwd right okay
  1170. 35:55so they're these personalities yeah okay
  1171. 35:58but
  1172. 35:58if you take a look there's just a ton of
  1173. 36:01these things
  1174. 36:02yeah and so so you notice like what are
  1175. 36:04they alias too it's all verb noun verb
  1176. 36:06noun
  1177. 36:06sorry yeah okay uh but the aliases are
  1178. 36:09very regular as well
  1179. 36:11okay so take a look at this let's say
  1180. 36:13gal well gal
  1181. 36:14g star okay notice wild cards
  1182. 36:17so notice all the g's start with get
  1183. 36:21okay you know what i i don't think i've
  1184. 36:23actually ever noticed that
  1185. 36:24okay now here's the thing now that's
  1186. 36:26that's sort of obvious right
  1187. 36:27but apparently not because but
  1188. 36:30here's the interesting thing look at
  1189. 36:32this one g as v okay let's let's see if
  1190. 36:34i can zoom it working here
  1191. 36:36okay oh look at that okay so get service
  1192. 36:39gsv so then the question is well geez
  1193. 36:42what about if i did gal star sv
  1194. 36:47and look there okay so you've got some
  1195. 36:49so gsv
  1196. 36:51saesv start service spsv
  1197. 36:55stop service so look at this sasv
  1198. 36:58okay so let's see oh i'm getting good at
  1199. 37:01this
  1200. 37:01sasv is start service so
  1201. 37:05sv for service let's say gal sa star
  1202. 37:09and look start start starts so it's not
  1203. 37:11always the case right
  1204. 37:12cell al for alias but yeah sa
  1205. 37:15jb so we've even been tried to be
  1206. 37:19thoughtful and and schematize the
  1207. 37:22the um the aliases as well and you made
  1208. 37:24them easy to
  1209. 37:26search through and this has become
  1210. 37:28really important when we get to
  1211. 37:29start talking about using the help
  1212. 37:31system which is what we're going to do
  1213. 37:32next
  1214. 37:33but you've made them easy to search
  1215. 37:34through to find aliases and one of the
  1216. 37:36things
  1217. 37:37guys i want to show you is a is on to
  1218. 37:39what jeffrey was showing you
  1219. 37:40is with those aliases um
  1220. 37:44a lot of times get alias a lot of times
  1221. 37:46you're going to have a commandlet and
  1222. 37:48you're going to want to know what the
  1223. 37:49alias is for the commandlet
  1224. 37:51there is a way to do this and we're
  1225. 37:52going to explain what parameters are
  1226. 37:54they alter the command and there's a
  1227. 37:56parameter called definition and if i
  1228. 37:57were to type in
  1229. 38:00a particular commandlet it'll tell me
  1230. 38:02what the aliases are available for
  1231. 38:03notice in this case there's a couple of
  1232. 38:05them ps and gps for it
  1233. 38:07um so there's a couple of different ways
  1234. 38:09to find and work with your aliases i
  1235. 38:11find it much easier if you just memorize
  1236. 38:12the list
  1237. 38:12no just kidding don't memorize the list
  1238. 38:15as a matter of fact don't
  1239. 38:16memorize anything but we'll we'll talk
  1240. 38:18about that more yeah
  1241. 38:19good um so because we don't want you
  1242. 38:21memorizing stuff yeah that just takes
  1243. 38:23the pain out of it
  1244. 38:24so questions or comments make sure that
  1245. 38:27you're in the chat rooms you're asking
  1246. 38:29questions
  1247. 38:29and we're going to be checking on you
  1248. 38:31guys as we go throughout this
  1249. 38:33to see if you have any questions and
  1250. 38:35there will be a recording of this later
  1251. 38:37i know a lot of people are asking if
  1252. 38:39there's going to be a recording of this
  1253. 38:40absolutely and it will be available for
  1254. 38:42you online with mba
  1255. 38:44so and i'm going to remind you with this
  1256. 38:45slide often to ask questions
  1257. 38:47and stuff like that
  1258. 39:04[Music]
  1259. 39:13so you're ready to uh do a little help
  1260. 39:16and help me out and
  1261. 39:18do a little help help help yeah because
  1262. 39:21guys this is probably the most important
  1263. 39:24section of the entire day and it may not
  1264. 39:27even seem like it at first but i swear
  1265. 39:29to god that this is the most important
  1266. 39:31thing and here's why it's so important
  1267. 39:34when you go to powershell you're going
  1268. 39:36to stare at that console and go
  1269. 39:38now what do i do yeah this is the answer
  1270. 39:41so
  1271. 39:42kicker girl card called that the
  1272. 39:44dizziness of freedom
  1273. 39:45you look at that prompt and you can do
  1274. 39:46anything you're like uh
  1275. 39:48what do i do and that is that a lot of
  1276. 39:50it it affects all of us and
  1277. 39:52a lot of us you know you get past that
  1278. 39:54with what we're going to do
  1279. 39:56now yeah it's a help system um but i
  1280. 39:58think for a lot of folks i see it all
  1281. 40:00the time that
  1282. 40:02okay it made sense when you were doing
  1283. 40:04it but now i'm staring at that console
  1284. 40:06and
  1285. 40:06i just don't know what to do and i don't
  1286. 40:09know where to go
  1287. 40:10and they created a solution for you this
  1288. 40:12is a beautiful solution so what we're
  1289. 40:13going to start off with
  1290. 40:14is looking at the help system
  1291. 40:17showing you how to get it updated and
  1292. 40:19this is actually a fascinating feature
  1293. 40:20in v3 remember i was saying you're going
  1294. 40:22to want to be using v3 and this is going
  1295. 40:23to be one of them
  1296. 40:24the most important thing is the
  1297. 40:25discoverability that the help system
  1298. 40:27provides you
  1299. 40:29basically it is your it is your bang for
  1300. 40:32power shell it is your
  1301. 40:33it is it is answers all of your needs
  1302. 40:35and all of your questions
  1303. 40:37and also we're going to show you how to
  1304. 40:39read syntax and so forth so
  1305. 40:41let's get started with the help stuff
  1306. 40:43and here in about 10 minutes we'll take
  1307. 40:44a break and then we'll come back in and
  1308. 40:46look at all the syntax and
  1309. 40:47start getting into it so first of all
  1310. 40:49why you need
  1311. 40:51help well i just want to go to bullet
  1312. 40:54number two
  1313. 40:56exactly can can we talk about this i
  1314. 40:59don't
  1315. 40:59i'm a smart guy but i'm not smart enough
  1316. 41:02to just know everything
  1317. 41:04absolutely so tell me what the idea here
  1318. 41:06is yeah so
  1319. 41:07one of my jokes although it's actually
  1320. 41:08true is that uh powershell is such a
  1321. 41:10great product because i'm such a deeply
  1322. 41:12flawed human
  1323. 41:14okay it's true i'm a deeply flooded
  1324. 41:17human and i was in a position to say hey
  1325. 41:20let's build a tool that helps me
  1326. 41:22right so concretely you know i i can't
  1327. 41:25remember all that stuff either i'm a
  1328. 41:26terrible typist
  1329. 41:28uh et cetera so you'll see there's a ton
  1330. 41:30of stuff in powershell
  1331. 41:31that helps for those things so really is
  1332. 41:34a goal to not be able to memorize things
  1333. 41:36actually there's a great story they
  1334. 41:38recently did a study
  1335. 41:40of unix admins and came out with this
  1336. 41:42report and i was
  1337. 41:43really amused by this because basically
  1338. 41:45about 25
  1339. 41:4630 years ago they had done exactly the
  1340. 41:49same study
  1341. 41:50and produced exactly the same results
  1342. 41:52and here's what they did
  1343. 41:53they took a bunch of beginner unix
  1344. 41:55admins and
  1345. 41:56expert unix admins and they said hey
  1346. 41:58here's a test
  1347. 42:00if you want to do this how do you do it
  1348. 42:01a written test and what was interesting
  1349. 42:04was
  1350. 42:04that there when you scored these uh
  1351. 42:06there wasn't very much of a difference
  1352. 42:08between the
  1353. 42:09expert unix admins and the beginning of
  1354. 42:11unix admins
  1355. 42:12and so then it's like oh why are we
  1356. 42:14paying these experts so much money you
  1357. 42:15know they can't uh
  1358. 42:17objectively they're not that much better
  1359. 42:20than just some
  1360. 42:21beginner right and so then so then they
  1361. 42:24said okay
  1362. 42:24well now let's put them in front of a
  1363. 42:26machine and give them a set of tasks
  1364. 42:28and what you saw was this huge
  1365. 42:31difference in performance
  1366. 42:32that the experts were able to perform
  1367. 42:34amazing things
  1368. 42:35that the beginners struggled with and
  1369. 42:37the conclusion was
  1370. 42:39that what expert unix guys are great at
  1371. 42:42is not
  1372. 42:42knowing things but in figuring things
  1373. 42:45out
  1374. 42:46okay and so that's the deal this is not
  1375. 42:49about you sitting there saying
  1376. 42:50hey um it should work this way
  1377. 42:53right no no that's not the deal the deal
  1378. 42:55is hey let me figure out
  1379. 42:58how to do things and so that's what it's
  1380. 43:00all about what you're going to learn
  1381. 43:01is a schema right you're going to learn
  1382. 43:03a set of things you're going to learn
  1383. 43:05how to learn
  1384. 43:06and then you're going to use those
  1385. 43:07techniques over and over again
  1386. 43:09and that's why once you learn how to use
  1387. 43:11powershell and you're managing say
  1388. 43:13exchange
  1389. 43:14then when someone says oh we got this
  1390. 43:16link server it's like well let me have
  1391. 43:17at it
  1392. 43:18and you'll be able to go and you'll be
  1393. 43:20able to learn and learn and learn
  1394. 43:21and just figure stuff out so basically
  1395. 43:23what you're telling me is is that
  1396. 43:25the first time i walked up to a unix guy
  1397. 43:27and i said hey how'd you do that and he
  1398. 43:28turned around
  1399. 43:29and usually barked uh barked at me going
  1400. 43:33rtfm yeah he was actually trying to
  1401. 43:35educate me
  1402. 43:36he wasn't just being a terrible person
  1403. 43:39no both
  1404. 43:40oh okay but i think
  1405. 43:43and this is really the moral of the
  1406. 43:44story is you're not gonna be able to
  1407. 43:46memorize stuff guys
  1408. 43:47we you know powershell v2 had like 236
  1409. 43:50core commandlets
  1410. 43:52okay i might be able to memorize those
  1411. 43:53but here's the deal when you start
  1412. 43:54working with products
  1413. 43:56you know exchange has depending on your
  1414. 43:58version of exchange has between 535 and
  1415. 44:00610 commandments
  1416. 44:02you got 500 some odd commandlets for
  1417. 44:03sharepoint you've got a hundred and some
  1418. 44:05odd commandlets for active directory
  1419. 44:08in server 2012 you have thousands of
  1420. 44:11commandlets now there's no way
  1421. 44:15to memorize them so what they did is
  1422. 44:17they created a help system now
  1423. 44:19before you go oh no not another help
  1424. 44:21system
  1425. 44:23because i know if you've and i'm i'm not
  1426. 44:25okay maybe i am if you've used the help
  1427. 44:27system in
  1428. 44:28in in a particular product before and
  1429. 44:30have found it unuseful
  1430. 44:32well just remember it wasn't spent a lot
  1431. 44:36of time on this was spent a lot of time
  1432. 44:38on by people who
  1433. 44:39wanted you to be successful knew that
  1434. 44:41the only way that you're going to be
  1435. 44:42successful is to have
  1436. 44:44a great help system we all of us use
  1437. 44:47this
  1438. 44:48every single day and i want to point out
  1439. 44:50that as jeffrey was saying it's about
  1440. 44:52using the help system reading and
  1441. 44:53comprehending it
  1442. 44:55and then figuring it out we're i.t pros
  1443. 44:58that's what we do we figure things out
  1444. 45:00this is actually fun when you get start
  1445. 45:03working with
  1446. 45:04it but one of the challenges that we
  1447. 45:05have is the rtfm
  1448. 45:07side i mean as an it pro one of the
  1449. 45:09reasons i got into it is because i was
  1450. 45:10really good at sitting down at a
  1451. 45:12computer and just figuring it out
  1452. 45:13i didn't have to read the manual well
  1453. 45:16that's not going to work here we're
  1454. 45:17going
  1455. 45:18to have to use and read and comprehend
  1456. 45:20the manual and they've made it
  1457. 45:21really easy for us so let's start doing
  1458. 45:24a little get
  1459. 45:24help stuff first of all and guys
  1460. 45:28some of this stuff is in the slides and
  1461. 45:30so we're just going to demonstrate it
  1462. 45:31first of all let's talk about
  1463. 45:33um update help versus the way that we
  1464. 45:35used to have it
  1465. 45:36yeah okay so we used to ship the help uh
  1466. 45:38with the product
  1467. 45:39and uh turned out that that was there
  1468. 45:41were all sorts of problems with that
  1469. 45:42so basically the way microsoft works uh
  1470. 45:45because we ship
  1471. 45:46to hundreds of millions of people right
  1472. 45:49um
  1473. 45:49it really matters that the release is
  1474. 45:51buttoned up right which is to say that
  1475. 45:53you stop
  1476. 45:54changing things and then you test and
  1477. 45:56you test and you test and you test and
  1478. 45:58then you release it
  1479. 45:59so what ended up happening was um that
  1480. 46:01just as soon as you're
  1481. 46:02like finishing putting the finishing
  1482. 46:04bits on the the code
  1483. 46:05the documentation has to be done and and
  1484. 46:08of course that doesn't work
  1485. 46:10but now it's cooked like hey don't
  1486. 46:11change it because you might break
  1487. 46:12something
  1488. 46:13so then it gets shipped and and the
  1489. 46:16documentation there's differences
  1490. 46:17between the documentation and the
  1491. 46:19and the product and the answer used to
  1492. 46:21be well you know hey just hang in there
  1493. 46:23you know we'll release again in three
  1494. 46:24years and we'll fix that well that's
  1495. 46:25kind of a crummy answer
  1496. 46:27and then there was a second problem the
  1497. 46:28second problem is guess what the help
  1498. 46:30is huge right because there's a ton of
  1499. 46:32it
  1500. 46:34and then would you say well geez i'm now
  1501. 46:36going to a
  1502. 46:37cloud world where i've got a gazillion
  1503. 46:39machines i get a gazillion servers won't
  1504. 46:42want to
  1505. 46:42to use those be as efficient as possible
  1506. 46:45with those servers
  1507. 46:46and you don't need the help on all those
  1508. 46:48servers right you need the help on the
  1509. 46:49machine you're managing them from
  1510. 46:51and to put the help on all those systems
  1511. 46:53is just load you know bogging down those
  1512. 46:55servers with
  1513. 46:56stuff that you're not going to use so
  1514. 46:58because of those two problems in windows
  1515. 47:00or certain powershell version three
  1516. 47:01we move to an updatable help model which
  1517. 47:04is to say
  1518. 47:05we ship and there's some very uh kind of
  1519. 47:07like structural help
  1520. 47:08that we generate based upon metadata
  1521. 47:11you'll see some examples of that
  1522. 47:13but then all the help text is available
  1523. 47:16from download from
  1524. 47:17from the internet so that's the way that
  1525. 47:19works and and let me just say that
  1526. 47:21in v2 one of the challenges was if
  1527. 47:23you're using the help system and there's
  1528. 47:24an example in there there was a
  1529. 47:25possibility you know that maybe that
  1530. 47:27example was wrong
  1531. 47:28and i'll show you a way around that if
  1532. 47:30you're in v2
  1533. 47:31um to get the latest information for it
  1534. 47:34but really the joy here with v3 is
  1535. 47:36is as soon as microsoft updates a helper
  1536. 47:39they find an issue
  1537. 47:40my help gets updated on my management
  1538. 47:42station so the first thing that we're
  1539. 47:44going to do and then we're going to take
  1540. 47:45a break here and just like
  1541. 47:46can i give an example yeah so i don't
  1542. 47:47know if you ever use wql
  1543. 47:49yeah okay right so i can never remember
  1544. 47:51wql
  1545. 47:52i just can't it's one of those things
  1546. 47:54well there's certain things that just
  1547. 47:55never sink in for me wql is one of them
  1548. 47:59and so constantly whenever i want to use
  1549. 48:01that i'd have to do search and there's
  1550. 48:02something about the
  1551. 48:04search the content i can never find it
  1552. 48:06on the internet either
  1553. 48:07right and so at some point somebody had
  1554. 48:09this exactly the same problem so they
  1555. 48:10went
  1556. 48:11on microsoft connect and said you ought
  1557. 48:13to have an about topic for
  1558. 48:15for wql and guess what they went and
  1559. 48:18wrote one
  1560. 48:18and so now we have an about wql and it's
  1561. 48:21just there
  1562. 48:21point was you didn't have to wait for
  1563. 48:23another release you had a problem
  1564. 48:26you told us about your problem and we
  1565. 48:28responded and then in a matter of like
  1566. 48:30well i forget how long that one took but
  1567. 48:32there was one where somebody complained
  1568. 48:34about an error in the documentation two
  1569. 48:36days later we had an update
  1570. 48:38so this is pretty pretty peppy it's
  1571. 48:39continuous publishing and so what you
  1572. 48:41want to make sure that you're doing is
  1573. 48:43you're updating help and let me show you
  1574. 48:44how to do that first of all
  1575. 48:46you're going to need an internet
  1576. 48:47connection now there is a way around
  1577. 48:48that but let's just start off with the
  1578. 48:49basic update help here and so we've got
  1579. 48:51a commandlet for that called
  1580. 48:52update as update get it dash
  1581. 48:55what would you have how did you want to
  1582. 48:57update yeah what do you want to update
  1583. 48:58the help
  1584. 48:59so the verb the noun so that's working
  1585. 49:01out and i like to use dash force and
  1586. 49:03guys
  1587. 49:04this is something that you can run every
  1588. 49:05single day to make sure you have the
  1589. 49:07latest and greatest help
  1590. 49:08and what it's going to do it's going to
  1591. 49:09go out to the internet and it's going to
  1592. 49:10download
  1593. 49:11all of the help files that you need for
  1594. 49:13all of the stuff that you have on your
  1595. 49:14system see that progress
  1596. 49:16bar says ooh which is what it should say
  1597. 49:19in powershell
  1598. 49:21so cool now look if you have a siri a
  1599. 49:24bunch of machines that don't have direct
  1600. 49:25access to the internet you can
  1601. 49:27save this help with save
  1602. 49:30help you can save this help you figured
  1603. 49:33it out
  1604. 49:34as a set of files and then you can
  1605. 49:36update
  1606. 49:37from that set of files but having the
  1607. 49:39internet connection sure does make your
  1608. 49:40life a lot easier
  1609. 49:41now here's the idea we're going to take
  1610. 49:44a break here
  1611. 49:45and so what we want to do is make sure
  1612. 49:47that you've got a powershell console up
  1613. 49:49and make sure that
  1614. 49:50you've updated help because when we come
  1615. 49:53back we're going to start using
  1616. 49:55my favorite things and let me just show
  1617. 49:56them to you real quick
  1618. 49:58get dash help which yep that's going to
  1619. 50:01get us help on stuff
  1620. 50:02but it's also going to help us search
  1621. 50:05for stuff and so that's its most
  1622. 50:06important thing
  1623. 50:07before though we go i want to show you
  1624. 50:10there's a difference you're going to see
  1625. 50:11people use get
  1626. 50:12dash help you're going to see people use
  1627. 50:14help
  1628. 50:15and you can see people use man and i
  1629. 50:16want to show you that there's a
  1630. 50:17difference between these two
  1631. 50:19get dash help and i'm just going to pick
  1632. 50:21a commandlet and what i'm going to do is
  1633. 50:22i'm going to keep things real simple
  1634. 50:23right now
  1635. 50:24and i want you to notice my screen it
  1636. 50:25scrolled all the way to the bottom
  1637. 50:27now this is not a complete help file but
  1638. 50:30we'll get to that
  1639. 50:30after break but i want you to notice it
  1640. 50:32scrolled all the way down to the bottom
  1641. 50:34now watch the difference between
  1642. 50:36using help on the same thing
  1643. 50:40look at the bottom of the screen see how
  1644. 50:42i've got that little more
  1645. 50:44so i can and you probably heard that i
  1646. 50:46can spacebar now and
  1647. 50:48and move through the help file man does
  1648. 50:50the same thing
  1649. 50:51so man and i'll do get service
  1650. 50:55gives you that same you know like you
  1651. 50:57pipe to more kind of deal
  1652. 50:58where you can pound your way through it
  1653. 51:02use whichever one makes you happiest and
  1654. 51:04probably today you should experiment i
  1655. 51:06know i've got friends that are
  1656. 51:08just help i always only use help i
  1657. 51:12happen to be a get dash help kind of guy
  1658. 51:14because i like it to scroll to the
  1659. 51:16bottom of the screen the help system is
  1660. 51:18a super discoverable
  1661. 51:20great tool to help me find things
  1662. 51:23and and let's do a couple of examples
  1663. 51:25i'll start off and then you can join in
  1664. 51:27guys this is this is going to be really
  1665. 51:29awesome because and don't memorize
  1666. 51:32or write down anything that we do yep i
  1667. 51:34swear to god don't
  1668. 51:35do it because that's kind of the whole
  1669. 51:37point so let me give you an example
  1670. 51:39first of all help
  1671. 51:40has the ability to discover stuff and
  1672. 51:42i'm gonna i'm gonna get help get dash
  1673. 51:43help kind of guys so i'm gonna use git
  1674. 51:45dash help
  1675. 51:46and i wanna find out here's here's my
  1676. 51:48here's my i wanna see if there's
  1677. 51:49any commandlets that could help me work
  1678. 51:51with
  1679. 51:52services so i'm going to do star service
  1680. 51:56star
  1681. 51:57yeah by the way star is your friend star
  1682. 51:59is a wild card and it says
  1683. 52:01find anything at the beginning or find
  1684. 52:03anything at the end match anything at
  1685. 52:04the beginning or then
  1686. 52:05yeah and make sure that when you mean
  1687. 52:08wild card you use a wild card because
  1688. 52:10some commandlets will let you
  1689. 52:12not use the wild card and that's not a
  1690. 52:14good practice to get into so
  1691. 52:16oh my gosh look at all of these
  1692. 52:17commandlets so many commandlets that
  1693. 52:19have
  1694. 52:19service in them whoa but now is where
  1695. 52:22the fun begins
  1696. 52:24look is there a commandlet that in this
  1697. 52:27list that looks like
  1698. 52:28it might retrieve or i don't know get me
  1699. 52:31a list of services on my computer so
  1700. 52:35yeah there happens to be one right here
  1701. 52:37see get dash service
  1702. 52:38it would probably get me a list of
  1703. 52:41services
  1704. 52:42show them the up arrow oh show me up
  1705. 52:44here
  1706. 52:46you can just use the up arrow now watch
  1707. 52:48this now use the right arrow
  1708. 52:50right left arrow left arrow and put a g
  1709. 52:52in front of the star
  1710. 52:53check this out now do it
  1711. 52:57oh got a short list these wild cards are
  1712. 52:59great the wild cards are great and
  1713. 53:00actually knowing how to do a good search
  1714. 53:02is really good
  1715. 53:03oh this is great this is great so here's
  1716. 53:06the idea and we're going to do this a
  1717. 53:07couple times the idea is you
  1718. 53:08search for and probably by noun you
  1719. 53:11search for the thing that you want to
  1720. 53:13find
  1721. 53:13i want to know something about processes
  1722. 53:15or i want to know something about
  1723. 53:17services which are the examples i'm
  1724. 53:18going to use a lot but it could be as
  1725. 53:20simple as
  1726. 53:21ad computers or something like that you
  1727. 53:24search for what you want and when you
  1728. 53:25find it
  1729. 53:27well there's a help file for it so let's
  1730. 53:28go in and take a look i'm going to do
  1731. 53:30get help
  1732. 53:31get dash service now this is the simple
  1733. 53:34view of the help file and let me just
  1734. 53:36show this to you real quick
  1735. 53:37it gives you the name synopsis syntax
  1736. 53:40which we're going to talk about here
  1737. 53:41shortly
  1738. 53:42gives you a description of what the
  1739. 53:43commandlet does and some related
  1740. 53:45links and information now this is not
  1741. 53:48the full help so don't panic we're going
  1742. 53:49to do the
  1743. 53:50the full help but let's try this
  1744. 53:52discovery thing again i want to do
  1745. 53:53let's see get help and i want to find
  1746. 53:56something that would oh and i'm going to
  1747. 53:57use your trick i'm going to say that
  1748. 53:58would uh
  1749. 54:00g star something with
  1750. 54:03a d computer in it because i want to
  1751. 54:06i want to work with active directory
  1752. 54:08computers oh
  1753. 54:10look there's there's a command there get
  1754. 54:12a d computer you know what i'm thinking
  1755. 54:14i'm thinking in my head
  1756. 54:15that's probably gonna solve my problem
  1757. 54:16but to be sure what i'm gonna do is
  1758. 54:19do get help get ad computer
  1759. 54:23and take a look at it
  1760. 54:27and again this is the simple help view
  1761. 54:30and we'll get to a
  1762. 54:31better ones here in just a second but so
  1763. 54:33the concept is is pretty simple what you
  1764. 54:36want to do
  1765. 54:36is you want to discover what you want to
  1766. 54:39work with
  1767. 54:40and then look at the help for what you
  1768. 54:41want to work with now the concept is
  1769. 54:43simple but doing this
  1770. 54:45seems to be a big challenge for a lot of
  1771. 54:47folks i you have to become
  1772. 54:49trusting in that this is how we do it
  1773. 54:52and this
  1774. 54:52actually works no matter what product
  1775. 54:54you're working with
  1776. 54:55think of what is it that you want to do
  1777. 54:58something to what
  1778. 54:58what's the noun that you want to find
  1779. 55:01and
  1780. 55:02then have help search for it yep sounds
  1781. 55:05like a great way to get help to work for
  1782. 55:06it yeah we very much
  1783. 55:07tried to create a world where you could
  1784. 55:09think about what you want
  1785. 55:11type it and get it okay so let's just
  1786. 55:13say you wanted to assign something well
  1787. 55:15you'd look for a sign you wouldn't find
  1788. 55:17that and you'd
  1789. 55:18then quickly learn that we use the word
  1790. 55:20set
  1791. 55:21and so you'd say well okay so there's an
  1792. 55:23infinite number of nouns
  1793. 55:25but the verbs are pretty regular so
  1794. 55:26imagine you wanted to get the help on
  1795. 55:29the verbs like yeah you type you type
  1796. 55:32who are go ahead okay so what you do is
  1797. 55:35you say
  1798. 55:36you say get verb
  1799. 55:40and it shows you all the verbs and so
  1800. 55:42these are all the verbs that you you
  1801. 55:44you're going to learn and you see well
  1802. 55:46how many are there so you might want to
  1803. 55:47say well i'd get the verb
  1804. 55:49i'd like to measure them and you see
  1805. 55:51that there are 98 verbs
  1806. 55:53and here you see we break them up into
  1807. 55:55into
  1808. 55:56you know um whether they're security
  1809. 55:58verbs or communication verbs etc
  1810. 56:01anyway so those you're going to learn
  1811. 56:02those 98 things and then
  1812. 56:04and then you're going to be able to
  1813. 56:05think type and get what you want
  1814. 56:07and what what happens often is you're
  1815. 56:10not even going to learn all 98 of those
  1816. 56:12you're just going to learn
  1817. 56:13a few of them because you'll know that
  1818. 56:14what the verbs will do for you and you
  1819. 56:15end up looking for the nouns so
  1820. 56:17it becomes a very easy process to follow
  1821. 56:19through but let's start getting into
  1822. 56:21what this help can do for us so once
  1823. 56:23again i'm going to do this
  1824. 56:24get help i want to find commandlets
  1825. 56:27that'll
  1826. 56:28retrieve me some services now notice
  1827. 56:32well there's get service and so i want
  1828. 56:33to take a look at what this
  1829. 56:35can do for me so i'm going to do get
  1830. 56:37help and get
  1831. 56:39service again this is the simplified
  1832. 56:41help view but there's more to help than
  1833. 56:42just this
  1834. 56:43once you've updated help this help can
  1835. 56:46be extended or expanded upon and let me
  1836. 56:48show you a couple of things this is
  1837. 56:49where it gets oh
  1838. 56:50just so happy for me because
  1839. 56:53watch i'm going to do get help on git
  1840. 56:55service but
  1841. 56:56we have a parameter that will allow us
  1842. 56:59to get
  1843. 57:00detailed ooh detailed help
  1844. 57:03and here's what detailed help is going
  1845. 57:04to show us i'm going to scroll all the
  1846. 57:05way back to the top
  1847. 57:06and get service gives you the synopsis
  1848. 57:10again the syntax which we're going to
  1849. 57:11talk about in a second and the
  1850. 57:12description this is what we saw before
  1851. 57:14but here's this when we talk about
  1852. 57:16syntax we're going to start talking
  1853. 57:17about what these things are
  1854. 57:18parameters these parameters change how
  1855. 57:21the commandlet
  1856. 57:22acts well i don't necessarily know what
  1857. 57:25these things
  1858. 57:26mean well when you go to detailed help
  1859. 57:29look
  1860. 57:30the parameters are listed here with an
  1861. 57:32explanation of
  1862. 57:34what they mean and so what you'll do is
  1863. 57:36you'll
  1864. 57:37actually be up here looking and going i
  1865. 57:38have no idea what that is and then you
  1866. 57:40can just scroll down and get a
  1867. 57:41definition of the parameters
  1868. 57:43also as i scroll down here i want you to
  1869. 57:45notice something really interesting
  1870. 57:48now we start to get examples now i want
  1871. 57:50you to think about this for a second
  1872. 57:51i've got a command called get dash
  1873. 57:53service so let's think about what it's
  1874. 57:54probably going to do i haven't run it
  1875. 57:56yet
  1876. 57:56it's good probably going to give me and
  1877. 57:58if i read the description
  1878. 57:59a list of all of the services on my
  1879. 58:01computer
  1880. 58:02whether they're running stopped or
  1881. 58:04paused and it'll tell me about that
  1882. 58:06how many examples of that do you really
  1883. 58:08think we need
  1884. 58:10well we need 11 of them and here's
  1885. 58:13here's here's why i want to point this
  1886. 58:15out we
  1887. 58:16apparently we need 11 examples of this
  1888. 58:18and there's a reason for this
  1889. 58:20because the people that worked so hard
  1890. 58:22on these help files
  1891. 58:23knew that there were going to be all
  1892. 58:25kinds of different ways that you're
  1893. 58:27going to want to try to use this and
  1894. 58:28they wanted to give you examples
  1895. 58:29what happens is this is oftentimes
  1896. 58:31you'll be thinking of a business problem
  1897. 58:33or trying to solve a business problem
  1898. 58:34and you'll say gee whiz let me go i
  1899. 58:36found the command let me go look at the
  1900. 58:37example
  1901. 58:37you'll find an example that is really
  1902. 58:40close
  1903. 58:41to probably exactly what you wanted to
  1904. 58:43do
  1905. 58:44which is one of the cool things so a big
  1906. 58:45shout out to all the folks that work on
  1907. 58:47you know the other thing we did was
  1908. 58:49there were a few of the ones we knew
  1909. 58:50people were going to use a lot like get
  1910. 58:51process boy you always want to spend
  1911. 58:53time looking at get process
  1912. 58:55because there what we did was we said
  1913. 58:57hey get process get serviced people are
  1914. 58:59going to use these a lot
  1915. 59:00and so in our help and our examples we
  1916. 59:02show you not just how to use get process
  1917. 59:04and get
  1918. 59:05service but we also show you some very
  1919. 59:07common powershell techniques that then
  1920. 59:09help you
  1921. 59:10you kind of lead you to the next step
  1922. 59:12you start off saying oh i'd like to get
  1923. 59:13something to get services what do i want
  1924. 59:15to do
  1925. 59:16and then you say well geez actually i'd
  1926. 59:17like to format it a little differently
  1927. 59:19or i'd like to find these things filter
  1928. 59:21and so we use those high volume topics
  1929. 59:24to kind of go a little bit deeper to
  1930. 59:26teach you the next level of powershell
  1931. 59:28which is you're going to as we take you
  1932. 59:30through learning all of this deep level
  1933. 59:31part of powershell you're going to look
  1934. 59:32at these help files in a totally new way
  1935. 59:34and you'll see that
  1936. 59:35examples of sorting and filtering and
  1937. 59:38getting the kinds of information that
  1938. 59:39you want and changing the kinds of
  1939. 59:41information you want
  1940. 59:42a lot of times writing the examples a
  1941. 59:44lot of people the first thing they do
  1942. 59:46is they go to examples as a matter of
  1943. 59:47fact there is rather than detailed
  1944. 59:49you have a parameter called examples
  1945. 59:52that will take you right into just the
  1946. 59:54examples if you want to get there real
  1947. 59:55quick
  1948. 59:56something else that you can do and this
  1949. 59:59is going to become
  1950. 1:00:00a big deal this afternoon as we work
  1951. 1:00:02through this
  1952. 1:00:03there's also full help i don't know
  1953. 1:00:06jeffrey i don't know if they can handle
  1954. 1:00:07the full help
  1955. 1:00:08i mean that's that's that's an awful lot
  1956. 1:00:10that's stress testing that says
  1957. 1:00:12here we go full help put your seat belts
  1958. 1:00:14on put your seat belts on
  1959. 1:00:16um full help guys i'm going to tell you
  1960. 1:00:18right now the full help is very similar
  1961. 1:00:20to detailed except when you're in the
  1962. 1:00:22parameters
  1963. 1:00:23there's some special information and
  1964. 1:00:24this is going to make in the next
  1965. 1:00:26section when we're going to talk about
  1966. 1:00:28what this information means to you it's
  1967. 1:00:29actually very important to us
  1968. 1:00:31and this will help us understand how the
  1969. 1:00:33commands work in the pipeline and so
  1970. 1:00:35we're going to talk about
  1971. 1:00:36that stuff in a little bit so right now
  1972. 1:00:38when you're running get help
  1973. 1:00:40you can use detailed or you can use
  1974. 1:00:42examples but
  1975. 1:00:43a little bit later on you'll always end
  1976. 1:00:45up using full
  1977. 1:00:46now i want i promised you earlier that
  1978. 1:00:48for the you folks that are running
  1979. 1:00:49powershell v2
  1980. 1:00:51and even if you're running v3 um
  1981. 1:00:53sometimes if you're running v2
  1982. 1:00:55your help files they're not up to date
  1983. 1:00:57and you want the latest
  1984. 1:00:59i need the latest and greatest
  1985. 1:01:00information well you can't run update
  1986. 1:01:03help if you're in v2 which is
  1987. 1:01:04why on your admin box you should be
  1988. 1:01:06running v3
  1989. 1:01:08however let me just show you this is how
  1990. 1:01:09we used to get around that
  1991. 1:01:11microsoft helped us with this dash
  1992. 1:01:15online i love this dash online
  1993. 1:01:18looking what it just did takes me opens
  1994. 1:01:20up a browser and takes me out look
  1995. 1:01:22updated shows you when it was last
  1996. 1:01:24updated and here's the full help
  1997. 1:01:27for whatever it is that i was looking
  1998. 1:01:29for in this case get service
  1999. 1:01:31so again don't close that i'll lose the
  2000. 1:01:34chat
  2001. 1:01:35dash online now i can't show my favorite
  2002. 1:01:38yeah because
  2003. 1:01:39you i that oh i hope you do now this i
  2004. 1:01:41was confused by this at first but
  2005. 1:01:43go ahead but what well yeah i'll show
  2006. 1:01:45you you go okay
  2007. 1:01:46so let's talk to mine so here we do get
  2008. 1:01:50get help help
  2009. 1:01:53get service so here's the thing you can
  2010. 1:01:56say
  2011. 1:01:57examples right examples
  2012. 1:02:00and they say oh that's cool let's let's
  2013. 1:02:02let's run this let's let's let's let's
  2014. 1:02:04uh
  2015. 1:02:05let's do one of these okay and type that
  2016. 1:02:08and by the way so you do you do enter
  2017. 1:02:11and then left mouse button and okay
  2018. 1:02:14great now you want to do the next one
  2019. 1:02:16oh well so you see the workflow's all
  2020. 1:02:20messed up
  2021. 1:02:21so what you can do is you can say
  2022. 1:02:25get help minus show show window
  2023. 1:02:29and look here comes up in a window okay
  2024. 1:02:32now this has all sorts of great stuff
  2025. 1:02:35one of these is
  2026. 1:02:36settings and you say hey i want to just
  2027. 1:02:39see
  2028. 1:02:40i don't want to see all this stuff i
  2029. 1:02:42just want to see
  2030. 1:02:44the examples look at all the stuff you
  2031. 1:02:46can have control over
  2032. 1:02:48it's amazing to me so now you just go
  2033. 1:02:50here
  2034. 1:02:51cut paste sorry paste
  2035. 1:02:56and do that and then the next one
  2036. 1:03:01cut paste and so it's a very nice
  2037. 1:03:04workflow
  2038. 1:03:05much nicer workflow so again that is
  2039. 1:03:08this
  2040. 1:03:08this show window
  2041. 1:03:12and you'll see there's some really fun
  2042. 1:03:14stuff with show window can i spend some
  2043. 1:03:15more time with you
  2044. 1:03:16absolutely okay so now let's turn all
  2045. 1:03:17this back on there
  2046. 1:03:19okay so you see it's got lots of stuff
  2047. 1:03:22here
  2048. 1:03:24okay so now in the show window you can
  2049. 1:03:27do things like remember i said what is
  2050. 1:03:29it
  2051. 1:03:29anyway you've got to find here right so
  2052. 1:03:32you can find stuff like
  2053. 1:03:33dependent depend
  2054. 1:03:36okay and so notice it gets highlighted
  2055. 1:03:38and it says here
  2056. 1:03:39it says 18
  2057. 1:03:43matches okay and
  2058. 1:03:46and it could search i don't do that very
  2059. 1:03:48well anyway so then you can start
  2060. 1:03:50searching for these things
  2061. 1:03:51and so it's it's super nice i and i
  2062. 1:03:54think the addition of this this was
  2063. 1:03:55added to v3 and i think the addition of
  2064. 1:03:57this
  2065. 1:03:58is really phenomenal because guys let me
  2066. 1:03:59show you um traditionally
  2067. 1:04:02you're going to spend so much time in
  2068. 1:04:04the help file and you're going to want
  2069. 1:04:06to do just that you're going to want to
  2070. 1:04:07cut and paste from a help file or you're
  2071. 1:04:09going to want to read a help file while
  2072. 1:04:11you're working in powershell
  2073. 1:04:12that a lot of times what a lot of guys
  2074. 1:04:14would do is if you take a look at my
  2075. 1:04:15screen i'm gonna
  2076. 1:04:16well yeah i'm just gonna launch two
  2077. 1:04:18powershell sessions now if you have two
  2078. 1:04:19monitors
  2079. 1:04:20this is great right so you do help in
  2080. 1:04:22one
  2081. 1:04:23and then you can work in another one but
  2082. 1:04:25with v3
  2083. 1:04:27having the show window stuff
  2084. 1:04:32well first of all it fits better on your
  2085. 1:04:33screen it's easier to move around
  2086. 1:04:35you can have the help it's easier to get
  2087. 1:04:37stuff out the part that always confuses
  2088. 1:04:39me is
  2089. 1:04:40and then we're going to fix this later
  2090. 1:04:41when we start talking about the magical
  2091. 1:04:43ise but it's it's the cut in the pace
  2092. 1:04:46man
  2093. 1:04:47it's that whole yeah it's that right
  2094. 1:04:49clicking and
  2095. 1:04:50stuff in the console why can't we fix
  2096. 1:04:52that why can't we fix that why can't we
  2097. 1:04:53fix
  2098. 1:04:54that that that console because it's
  2099. 1:04:57horrible
  2100. 1:04:58yes that's the answer no so here's the
  2101. 1:05:01thing
  2102. 1:05:01here's the thing so let me give you a
  2103. 1:05:03little
  2104. 1:05:04tutorial about some of the behind the
  2105. 1:05:07scenes stuff at microsoft so
  2106. 1:05:08there was some point where people said
  2107. 1:05:10oh you know microsoft stopped
  2108. 1:05:13advancing i.e you know oh that just
  2109. 1:05:15proves what bad guys they are
  2110. 1:05:17there's no competition they stop
  2111. 1:05:19innovating no no no my friends honestly
  2112. 1:05:21that's not what happened
  2113. 1:05:22what happened was um was that it got to
  2114. 1:05:25the point where every time we made a
  2115. 1:05:27change
  2116. 1:05:28uh we broke a bunch of people right
  2117. 1:05:30right and so then it's like well
  2118. 1:05:31people are like hey jerks stop breaking
  2119. 1:05:34us
  2120. 1:05:35and so and so they stopped doing that
  2121. 1:05:38and then all of
  2122. 1:05:38a sudden some competitors got up there
  2123. 1:05:40and so now they went and started
  2124. 1:05:42doing things even though sometimes
  2125. 1:05:44things break
  2126. 1:05:45same thing happens with the console
  2127. 1:05:46window the console window man
  2128. 1:05:48every time you change that thing you
  2129. 1:05:50break tons of people
  2130. 1:05:52you just break tons of them and so you
  2131. 1:05:54don't want to change that thing very
  2132. 1:05:56much now here's the thing
  2133. 1:05:57actually i'm pretty hostile to the
  2134. 1:06:00console window
  2135. 1:06:01okay so that's it i'm trying to make
  2136. 1:06:02this thing die i'll just be
  2137. 1:06:05straight up about it make it y die and
  2138. 1:06:07why is that and the answer is
  2139. 1:06:09that there are these things called
  2140. 1:06:10console apps okay now a console app
  2141. 1:06:13only works in the console now here's why
  2142. 1:06:16i want to kill the console because i
  2143. 1:06:18want to kill
  2144. 1:06:18console apps and it turns out that the
  2145. 1:06:21reason i want to kill console apps is
  2146. 1:06:23you go and you write you do something on
  2147. 1:06:24the console app and it writes directly
  2148. 1:06:26onto the console
  2149. 1:06:28which means you cannot automate it okay
  2150. 1:06:30you can't
  2151. 1:06:31run something get its output process the
  2152. 1:06:34output and do something with it because
  2153. 1:06:36it writes directly on the screen
  2154. 1:06:38so this is just evil incarnate it is the
  2155. 1:06:41enemy of automation so we're trying to
  2156. 1:06:42get rid of those things
  2157. 1:06:44so we're trying to uh get everybody on
  2158. 1:06:46to powershell ise
  2159. 1:06:48which is a much richer investment so by
  2160. 1:06:50the way stop
  2161. 1:06:51asking me to fix the console i'm not
  2162. 1:06:53going to fix the console
  2163. 1:06:54and that's the point that i want is that
  2164. 1:06:56the console and look i know cut and
  2165. 1:06:58pasting in the console and some guys ago
  2166. 1:07:00the console's driving me nuts a little
  2167. 1:07:01bit later on today we're going to help
  2168. 1:07:02you with
  2169. 1:07:04well he hates it and so there's actually
  2170. 1:07:06a really cool solution to it but i want
  2171. 1:07:07you to wait till we get there with the
  2172. 1:07:08isc
  2173. 1:07:10so to cut and paste in the console is
  2174. 1:07:13if you haven't done it yep it's you
  2175. 1:07:15highlight it you right click
  2176. 1:07:17and then you can right click again so no
  2177. 1:07:20control c no control v
  2178. 1:07:22in this puppy i think we
  2179. 1:07:25may have something cooler for you later
  2180. 1:07:26on but right now
  2181. 1:07:28that's how you do it so right click and
  2182. 1:07:30right click will take care of it for you
  2183. 1:07:32jeffrey you know what we need to do we
  2184. 1:07:33need to start to take a look at
  2185. 1:07:36and explaining syntax because here's the
  2186. 1:07:40thing
  2187. 1:07:40everybody wants to work with uh
  2188. 1:07:43commandlet but
  2189. 1:07:44you know commandlet's going to do great
  2190. 1:07:45stuff for you but sometimes you want the
  2191. 1:07:47commandlet to
  2192. 1:07:48alter its output or change what it's
  2193. 1:07:51actually doing for you you know get
  2194. 1:07:52service is great but it's going to give
  2195. 1:07:54you a list of all your services
  2196. 1:07:56i maybe i just want the one called bits
  2197. 1:07:58or something like that
  2198. 1:08:00so the syntax of the command will
  2199. 1:08:02explain to you the options that you have
  2200. 1:08:04available
  2201. 1:08:05to control the commandlet and so at
  2202. 1:08:07first it looks very very confusing now
  2203. 1:08:09we've got slides for this and so it's
  2204. 1:08:12all in the slide deck
  2205. 1:08:13but let's take a look here i've got get
  2206. 1:08:15service up right now and i'm going to
  2207. 1:08:16take a look at something pretty simple
  2208. 1:08:17you know
  2209. 1:08:18if you do this in show window it comes
  2210. 1:08:19out better you like it in show window
  2211. 1:08:21better yeah
  2212. 1:08:21cause watch do it oh you oh no you're
  2213. 1:08:23doing it let's see
  2214. 1:08:26let's do show window see because one you
  2215. 1:08:29got the zoom there
  2216. 1:08:31down at the bottom did you ever notice
  2217. 1:08:33that
  2218. 1:08:35oh yeah yeah
  2219. 1:08:38let's see and so the nice thing is that
  2220. 1:08:39it highlights some things so it's a
  2221. 1:08:41little i think it's a little bit easier
  2222. 1:08:42to read
  2223. 1:08:42very easy and it's easier to select and
  2224. 1:08:45say
  2225. 1:08:47okay so we're going to use we're going
  2226. 1:08:48to use this instead this is much better
  2227. 1:08:50so take a look at this right here see
  2228. 1:08:52the thing with the dash in front of it
  2229. 1:08:54so you'll notice that i've got a command
  2230. 1:08:56lit
  2231. 1:08:57and then it starts followed by all of
  2232. 1:08:58this magical characters we're going to
  2233. 1:08:59explain what all these characters are
  2234. 1:09:01but the first thing i want you to notice
  2235. 1:09:02is look how many times under syntax
  2236. 1:09:05i see the name of this command line i
  2237. 1:09:06see it three times now jeffrey
  2238. 1:09:08technically this is called
  2239. 1:09:09parameter sets but parameter sets why am
  2240. 1:09:12i seeing three of these
  2241. 1:09:13yes so here's the thing imagine uh take
  2242. 1:09:15a look at the net command
  2243. 1:09:17right there's net use and net view
  2244. 1:09:20et cetera these are different parameter
  2245. 1:09:23sets
  2246. 1:09:23and what happens is when you type net
  2247. 1:09:25view you get one set of functionality
  2248. 1:09:27when you type net use you get a
  2249. 1:09:29different set of functionality
  2250. 1:09:30so what happens is that that then they
  2251. 1:09:33reuse the word the command net
  2252. 1:09:35now that's essentially what a parameter
  2253. 1:09:38set is now we take a different take on
  2254. 1:09:40it
  2255. 1:09:40net use is extremely different
  2256. 1:09:43functionality than net
  2257. 1:09:44use okay so we don't like that we want
  2258. 1:09:47to be
  2259. 1:09:48clear but the point about get service is
  2260. 1:09:50that there are different parameter sets
  2261. 1:09:52sometimes you want to say
  2262. 1:09:53get service based upon its name or
  2263. 1:09:56you're going to say i want to get
  2264. 1:09:57service based upon its display name
  2265. 1:10:00okay so those are two different
  2266. 1:10:01parameter sets so a better example would
  2267. 1:10:03be
  2268. 1:10:03get process sometimes you want to say
  2269. 1:10:05get process
  2270. 1:10:06whose name is this sometimes you want to
  2271. 1:10:09say get process whose id
  2272. 1:10:11is this or sometimes you're going to
  2273. 1:10:13just say get process
  2274. 1:10:14and get them all and get them all yeah
  2275. 1:10:16so those are different parameter
  2276. 1:10:17sets and let me show you what jerry's
  2277. 1:10:19talking about is notice in these
  2278. 1:10:21three different get services and yeah
  2279. 1:10:22don't worry we'll take a look at get
  2280. 1:10:23process too
  2281. 1:10:24and these three different get services
  2282. 1:10:25look at this one this one has dash name
  2283. 1:10:28down here in these other two you don't
  2284. 1:10:30see dash name
  2285. 1:10:31this one has dash display name you don't
  2286. 1:10:33see that in the other two so that's what
  2287. 1:10:36makes that particular parameter set
  2288. 1:10:39unique and matter of fact i'm going to
  2289. 1:10:40demonstrate these here in just a second
  2290. 1:10:42but again look at these dashes
  2291. 1:10:45these dashes indicate that they're
  2292. 1:10:47parameters
  2293. 1:10:49dashes parameters parameters will allow
  2294. 1:10:52you to change the results of what the
  2295. 1:10:54command is going to do and i want to do
  2296. 1:10:55an example for you let's take a look at
  2297. 1:10:57dash
  2298. 1:10:57name i want you to notice it's followed
  2299. 1:10:59by these characters here i just kind of
  2300. 1:11:01go like this call them chihuahuas or
  2301. 1:11:03something like this
  2302. 1:11:05that's the technical term not many
  2303. 1:11:08people knew that i
  2304. 1:11:09i didn't realize that the official
  2305. 1:11:11technical term now is
  2306. 1:11:13um and what this is is this is the kind
  2307. 1:11:16of values that you can
  2308. 1:11:18give this we're getting in trouble with
  2309. 1:11:20hr on that one really
  2310. 1:11:22okay these things well no
  2311. 1:11:25like pac-man pac-man pac-man so these
  2312. 1:11:28can can be now these are the values
  2313. 1:11:32that you can give to the parameter and
  2314. 1:11:34i'm going to show you so let me let me
  2315. 1:11:35give you a quick example here let me
  2316. 1:11:37lower this uh well i'm not going to
  2317. 1:11:38lower it down i'll just do it here watch
  2318. 1:11:40i'm going to do git service and i'm
  2319. 1:11:41going to use one of the parameters now
  2320. 1:11:43parameters always begin with a dash
  2321. 1:11:45so make sure you always put a dash in
  2322. 1:11:47front of the parameters and now i'm
  2323. 1:11:48going to put in
  2324. 1:11:49a value that would be inside those
  2325. 1:11:51chihuahuas and it said that the value
  2326. 1:11:52type was string which means alphanumeric
  2327. 1:11:55and i'm going to put in the name or
  2328. 1:11:57which is a short name of a service i'm
  2329. 1:11:58going to do
  2330. 1:11:59bits instead of getting the entire
  2331. 1:12:02service list
  2332. 1:12:03this parameter now is going to allow me
  2333. 1:12:05to just get the service that i want so
  2334. 1:12:08here's the idea parameters can have
  2335. 1:12:11these arguments on them
  2336. 1:12:12and a lot of parameters can take
  2337. 1:12:14multiple arguments let me show you what
  2338. 1:12:16that looked like let's say
  2339. 1:12:17i wanted two services notice the comma
  2340. 1:12:21in between now the space is optional but
  2341. 1:12:23see if you put a space there makes it
  2342. 1:12:24easier to read
  2343. 1:12:26now i get those two let me show you how
  2344. 1:12:29that looks
  2345. 1:12:29in the syntax and so let's go back here
  2346. 1:12:32notice up here at dash name
  2347. 1:12:34that's the parameter then we have the
  2348. 1:12:36chihuahuas with the
  2349. 1:12:38type of data that we can put in there
  2350. 1:12:40the value type see these guys inside
  2351. 1:12:43these guys and they've got to be doing
  2352. 1:12:44close together because we've got
  2353. 1:12:46these guys and we've got these guys
  2354. 1:12:48these chihuahuas
  2355. 1:12:50i just call them bankies because they're
  2356. 1:12:51inside yeah so you've got chihuahuas and
  2357. 1:12:54inside the chihuahuas you have these
  2358. 1:12:56binkies if you see binkies in there
  2359. 1:12:59that means it can take multiple values
  2360. 1:13:01separated by a comma
  2361. 1:13:03now i'll show you some stuff later where
  2362. 1:13:05you won't see the internal binky
  2363. 1:13:07and so boy there's going to be a whole
  2364. 1:13:09phrase book now
  2365. 1:13:10um and so can only take one value and
  2366. 1:13:13this is very important for you to be
  2367. 1:13:14able to know
  2368. 1:13:15but here's the part where it starts to
  2369. 1:13:16get a little confusing let me do
  2370. 1:13:19a a little demonstration here of dash
  2371. 1:13:22name
  2372. 1:13:24with multiple values which i just did
  2373. 1:13:25but let me show you something else
  2374. 1:13:28this isn't the confusing part i'm going
  2375. 1:13:29to ask jeffrey about this confusing part
  2376. 1:13:31again you can do wild cards so dash name
  2377. 1:13:34b star means i'm going to get all the
  2378. 1:13:36services listed
  2379. 1:13:37that begin with b by the way there's no
  2380. 1:13:39conflict between
  2381. 1:13:40wild cards and arrays or collections
  2382. 1:13:43so do this do that up arrow now do oh
  2383. 1:13:47now comma c star
  2384. 1:13:50oh yeah yeah this is oh yeah that's a
  2385. 1:13:51great point yeah great point so now i
  2386. 1:13:53get both
  2387. 1:13:54the ones that begin with b's and with
  2388. 1:13:56c's and c that's awesome that's totally
  2389. 1:13:58awesome
  2390. 1:13:59so oh i closed my show window so let me
  2391. 1:14:01go up here
  2392. 1:14:03and open up the show window here's the
  2393. 1:14:06part where i start getting kind of
  2394. 1:14:07confused here and
  2395. 1:14:08this this originally kind of threw me
  2396. 1:14:10off as i want you guys to notice this
  2397. 1:14:11guy down here
  2398. 1:14:13computer name and i want you to notice
  2399. 1:14:14what's around computer name
  2400. 1:14:16see these brackets that surround both
  2401. 1:14:19the parameter
  2402. 1:14:20and the argument there so it's not the
  2403. 1:14:22internal binkies inside of chihuahuas
  2404. 1:14:24it's these things that surround
  2405. 1:14:26either the parameter or the parameter
  2406. 1:14:28and its argument
  2407. 1:14:30this means you don't have to use it it's
  2408. 1:14:32optional
  2409. 1:14:33but wait we're not done yet and a great
  2410. 1:14:36example is is
  2411. 1:14:37take a look at this first syntax
  2412. 1:14:40this uh syntax up here
  2413. 1:14:44notice that everything has these
  2414. 1:14:47around it which means that there's
  2415. 1:14:49nothing
  2416. 1:14:50actually required that i type in notice
  2417. 1:14:53i've got them around here
  2418. 1:14:54got them around here and every single
  2419. 1:14:57one of them
  2420. 1:14:58optional that means alls i need to do
  2421. 1:15:02or all i have to do is type get service
  2422. 1:15:07and it gives me a whole list in other
  2423. 1:15:08words no parameters were required
  2424. 1:15:11but take a look at this
  2425. 1:15:16inside the syntax look at this second
  2426. 1:15:18syntax
  2427. 1:15:20i want you to notice look at this guy
  2428. 1:15:21down here
  2429. 1:15:24see how display name doesn't have these
  2430. 1:15:27around it well that means if you're
  2431. 1:15:29going to use display name
  2432. 1:15:31you you've got to put it in and then
  2433. 1:15:33you've got to give me a value for it
  2434. 1:15:35now here's an example display name by
  2435. 1:15:38the way
  2436. 1:15:39is the long name
  2437. 1:15:42so it's this really long name
  2438. 1:15:45and i can get services by that display
  2439. 1:15:48name but i want you to notice that
  2440. 1:15:49you've got a choice dash name or
  2441. 1:15:53dash display name so get service
  2442. 1:15:56dash display name and now i can type in
  2443. 1:16:00whatever long
  2444. 1:16:01lengthy and i'm just making it up
  2445. 1:16:03display name that i want to type in but
  2446. 1:16:06if you're going to use display name now
  2447. 1:16:07you have to use display name and the
  2448. 1:16:10value that goes with it that's what gets
  2449. 1:16:12you into that other syntax
  2450. 1:16:14let's do something else let's do stop
  2451. 1:16:17wait you didn't
  2452. 1:16:17you know yeah so here's the thing yeah
  2453. 1:16:19so imagine
  2454. 1:16:21you wanted to get like do a get service
  2455. 1:16:24b star
  2456. 1:16:26just v star b oh b star
  2457. 1:16:30okay so look at this the name for
  2458. 1:16:32bitlocker drive encryption
  2459. 1:16:34service is bdesv now remember we said oh
  2460. 1:16:38well you want to create a world where
  2461. 1:16:40you think about what you want you type
  2462. 1:16:41it and you get it
  2463. 1:16:42how many of you are thinking oh i want
  2464. 1:16:44to get the bde
  2465. 1:16:46svc service right like wow
  2466. 1:16:49so no you want bidlocker okay so then
  2467. 1:16:52you want to say okay well get service
  2468. 1:16:54might display
  2469. 1:16:55bit no you can't type bitlocker it's
  2470. 1:16:58bitlocker
  2471. 1:16:59drive encryption service so
  2472. 1:17:02so remember powershell is great because
  2473. 1:17:06i'm flawed i can't remember b d
  2474. 1:17:09e s v c and i'm definitely not going to
  2475. 1:17:12remember
  2476. 1:17:12bitlocker drive encryption service and
  2477. 1:17:14look even if i could
  2478. 1:17:16remember it i can guarantee you i cannot
  2479. 1:17:18i'm like
  2480. 1:17:19incapable of typing that correctly so
  2481. 1:17:23what you do is you type display name
  2482. 1:17:26bit star no just bits oh just bit star
  2483. 1:17:29yeah dead star
  2484. 1:17:31something to do with bitlocker a doom
  2485. 1:17:33and it just works
  2486. 1:17:34it got us by the long name which
  2487. 1:17:36actually makes more human
  2488. 1:17:37sense than those little tiny short names
  2489. 1:17:39see one of the things we said was
  2490. 1:17:41with powershell it's like programming
  2491. 1:17:43with with uh
  2492. 1:17:44hand grenades versus sniper rifles you
  2493. 1:17:47know
  2494. 1:17:47it's just sort of just sort of like over
  2495. 1:17:49there i don't know if i ever told you
  2496. 1:17:50that story
  2497. 1:17:52my buddy out of college i uh
  2498. 1:17:55my roommate used to be in vietnam he was
  2499. 1:17:57vietnam 18
  2500. 1:17:58special forces and no it's actually the
  2501. 1:18:01other guy i worked with he was a navy
  2502. 1:18:02seal
  2503. 1:18:02and the navy seals get their own weapons
  2504. 1:18:05right so everybody else like you're this
  2505. 1:18:06kind of guy you get this kind of weapon
  2506. 1:18:08the navy seals
  2507. 1:18:09like the the gun manufacturers would
  2508. 1:18:11make them guns and he talked about this
  2509. 1:18:12thing
  2510. 1:18:13i never quite got it in focus but it's
  2511. 1:18:15basically sort of like a machine gun
  2512. 1:18:17shotgun a machine shotgun he said and
  2513. 1:18:20the great thing about that was is
  2514. 1:18:21in vietnam you hit the the jungle and
  2515. 1:18:24you sort of only had to know what like
  2516. 1:18:26was my problem
  2517. 1:18:26over there or over there and you'd set
  2518. 1:18:29up with this thing
  2519. 1:18:30and he says you'd let loose with it and
  2520. 1:18:32three seconds later your problem was
  2521. 1:18:34gone or everything between you and your
  2522. 1:18:35problem was
  2523. 1:18:36gone you could focus in on your problem
  2524. 1:18:38well that's the same sort of thing you
  2525. 1:18:39just sort of like
  2526. 1:18:40hey bit locker is something to do with
  2527. 1:18:43bitlocker bit
  2528. 1:18:44star star and so that's the kind of the
  2529. 1:18:47model we're trying to go for
  2530. 1:18:48is you know just sort of over here or
  2531. 1:18:50sort of over there now there are times
  2532. 1:18:52when you need to be precise
  2533. 1:18:53and you can be precise and there are
  2534. 1:18:55times where just sort of like over there
  2535. 1:18:56is good enough and by the way
  2536. 1:18:58when you need both uh you'll see how we
  2537. 1:19:00deal with that so through something
  2538. 1:19:01called minus
  2539. 1:19:02what if and minus confirm yeah yeah yeah
  2540. 1:19:04and so oh and jeffrey what i need
  2541. 1:19:06you to help me with is this is the um
  2542. 1:19:11this is the one that seems to throw most
  2543. 1:19:13people off
  2544. 1:19:14so a dash means that you have a
  2545. 1:19:18parameter and if it's followed by
  2546. 1:19:19chihuahuas that means you can put
  2547. 1:19:21arguments on it and you get the value
  2548. 1:19:23type of the argument string
  2549. 1:19:24and that kind of thing and if it's got
  2550. 1:19:26binkies in there you can take multiple
  2551. 1:19:28arguments
  2552. 1:19:29separated by a comma you see plenty of
  2553. 1:19:31examples of us doing that
  2554. 1:19:32and if you're surrounded by these
  2555. 1:19:34brackets i you don't have to it's
  2556. 1:19:36optional you don't have to do it at all
  2557. 1:19:38but there's something tricky here in
  2558. 1:19:40this view yeah
  2559. 1:19:41let's look at this guy look at this dash
  2560. 1:19:43name this guy's it
  2561. 1:19:44throws everybody off so i it i don't
  2562. 1:19:46have to type this in i don't type
  2563. 1:19:47anything in because
  2564. 1:19:48we all know that i can just run get
  2565. 1:19:49service and get all of them but
  2566. 1:19:52if i'm using dash name and i want to
  2567. 1:19:54specify a name of a service
  2568. 1:19:56like bits what is it with these little
  2569. 1:19:59duders inside here yeah
  2570. 1:20:00this is something we call positional
  2571. 1:20:02parameters okay
  2572. 1:20:03and so that means that if you just
  2573. 1:20:05specify the value
  2574. 1:20:07uh you don't have to specify dash name
  2575. 1:20:10so
  2576. 1:20:11so this makes so watch
  2577. 1:20:14get service i can do this
  2578. 1:20:18you might be saying i gotta type a lot
  2579. 1:20:22actually you don't have to type a lot
  2580. 1:20:23but here's what positional means
  2581. 1:20:26if you're gonna give me a bunch of names
  2582. 1:20:29of services
  2583. 1:20:30you don't have to use dash name see
  2584. 1:20:32works the same way which means
  2585. 1:20:34so those brackets around the parameters
  2586. 1:20:36simply mean you don't have to use the
  2587. 1:20:38parameter but you got to give me the
  2588. 1:20:39argument that's what makes it
  2589. 1:20:40oh and it gets even better because now
  2590. 1:20:42you can just type gsv
  2591. 1:20:44oh yeah you can use the alias to even
  2592. 1:20:47shorten it up even for so watch
  2593. 1:20:49do you want to go ahead and do that is
  2594. 1:20:51it gsv
  2595. 1:20:53bits and so here's kind of a key kind of
  2596. 1:20:56principle of powershell
  2597. 1:20:57okay the principle is we want to have
  2598. 1:20:59this very regular
  2599. 1:21:01very uh self-describing surface okay
  2600. 1:21:04so when it's three o'clock in the
  2601. 1:21:06morning and things didn't go the way you
  2602. 1:21:08wanted to
  2603. 1:21:09and uh during some it upgrade and you
  2604. 1:21:11bring up some script
  2605. 1:21:13you want that script to be absolutely
  2606. 1:21:16readable you want to know what's going
  2607. 1:21:17on
  2608. 1:21:18okay and so that's why powershell is
  2609. 1:21:20very clear you know
  2610. 1:21:21get dash service dash name et cetera so
  2611. 1:21:24that when you're reading it you know
  2612. 1:21:25exactly what's going on
  2613. 1:21:26on the other hand when you're
  2614. 1:21:28interactive
  2615. 1:21:30you can type that if you want and we
  2616. 1:21:31make it easier to type that with things
  2617. 1:21:33like tap completion but sometimes you
  2618. 1:21:35just want to go go go go
  2619. 1:21:36and so we have all these uh shortcuts
  2620. 1:21:39and aliases so that you can be
  2621. 1:21:40very very productive as a high-speed
  2622. 1:21:43advanced interactive user
  2623. 1:21:45but then when you go and write scripts
  2624. 1:21:47we encourage the more verbose style
  2625. 1:21:50as a matter of fact let's just to
  2626. 1:21:51emphasize on that a little bit further
  2627. 1:21:54so when you're writing scripts this is
  2628. 1:21:55the way that you're going to want to do
  2629. 1:21:56it here in the top example you're going
  2630. 1:21:57to want to be
  2631. 1:21:58very uh explanatory of what you're doing
  2632. 1:22:02but as jeffrey was saying when you're at
  2633. 1:22:03the console
  2634. 1:22:05free reign i mean if you can use aliases
  2635. 1:22:07and shorten this up with the positional
  2636. 1:22:09parameters so that you can quickly get
  2637. 1:22:11things done you're going to see examples
  2638. 1:22:12of that today because
  2639. 1:22:13jeffrey uses an awful lot of aliases and
  2640. 1:22:16i usually
  2641. 1:22:17because i'm getting ready to automate it
  2642. 1:22:19sometimes i just do the whole thing the
  2643. 1:22:21first time through
  2644. 1:22:22where i use all the parameters and all
  2645. 1:22:24the arguments so you're going to see
  2646. 1:22:26that contrast between
  2647. 1:22:27working quickly interactively with the
  2648. 1:22:29short
  2649. 1:22:30you know short versions and then the
  2650. 1:22:32long versions that you're going to want
  2651. 1:22:33to see in a script but let me give you a
  2652. 1:22:34hint and then we'll do another example
  2653. 1:22:36and and then
  2654. 1:22:37take a look at how to work with all of
  2655. 1:22:38this um
  2656. 1:22:40um have you guys been hitting the tab
  2657. 1:22:42key you take your pinky
  2658. 1:22:44take a pinky if you're a touch typist
  2659. 1:22:47this is this is probably not
  2660. 1:22:48for you but this pinky she's showing you
  2661. 1:22:51the official flexing
  2662. 1:22:53moves yeah yeah you want to make sure
  2663. 1:22:54you stretch you want to warm it up at
  2664. 1:22:55the beginning of every day
  2665. 1:22:56stretch it stretch the pinky and you
  2666. 1:22:58want this pinky to hover
  2667. 1:23:00right over the tab key always because
  2668. 1:23:02what you want to do is
  2669. 1:23:03watch get s e i i'm going to start
  2670. 1:23:05hitting attack key look look look look
  2671. 1:23:07let's start going through the
  2672. 1:23:08commandments we've got so many
  2673. 1:23:09commandments now it's a lot of them to
  2674. 1:23:10go through
  2675. 1:23:11there we go wait a minute shift tab goes
  2676. 1:23:12backwards watch dash
  2677. 1:23:14i'm going to hit the tab key it'll cycle
  2678. 1:23:16through the parameters for me
  2679. 1:23:18this oh this is cool remember i said we
  2680. 1:23:20make it easier to help type this stuff
  2681. 1:23:22out that's what he's talking about and
  2682. 1:23:23so
  2683. 1:23:23look in just about as many keystrokes
  2684. 1:23:26as doing like gsv uh bits
  2685. 1:23:30just a couple of more and i can bang
  2686. 1:23:32this out and get it to look
  2687. 1:23:34really nice and clean so that if i'm
  2688. 1:23:36going to use this in a script so the tab
  2689. 1:23:37key is your friend
  2690. 1:23:39use the tab you're going to see us use
  2691. 1:23:40it all the time today
  2692. 1:23:42let me show you another example of
  2693. 1:23:43finding something as kind of a summary
  2694. 1:23:45here of finding a commandlet
  2695. 1:23:48and then taking a look at its syntax and
  2696. 1:23:50then we're going to show you how to
  2697. 1:23:51start to put commandments together on
  2698. 1:23:52the pipeline so
  2699. 1:23:53let's do this i have this business
  2700. 1:23:56problem
  2701. 1:23:57business problem time and my business
  2702. 1:23:59problem is
  2703. 1:24:00i need to get um
  2704. 1:24:03i need some errors i need the i need the
  2705. 1:24:06newest errors
  2706. 1:24:08the newest five errors um out of my
  2707. 1:24:11system log
  2708. 1:24:11oh yeah so i need to be able to look at
  2709. 1:24:13my event the log file
  2710. 1:24:14yeah the log file so i'm thinking i need
  2711. 1:24:16to look at my event logs i wonder if
  2712. 1:24:19powershell
  2713. 1:24:20has a commandlet that can help me with
  2714. 1:24:23my event logs so get help
  2715. 1:24:24star well let's see do you have anything
  2716. 1:24:27with event logs
  2717. 1:24:28oh and lo and behold there are plenty
  2718. 1:24:32as a matter of fact this is a great time
  2719. 1:24:33now you can take a look at the verbs
  2720. 1:24:36you can just guess what what do you
  2721. 1:24:37think clear event log's going to do
  2722. 1:24:39would you
  2723. 1:24:40clear it i i i bet it would clear it too
  2724. 1:24:42you know what do you think get event log
  2725. 1:24:44is going to do
  2726. 1:24:46ta-da it's going to i know it seems
  2727. 1:24:48ridiculous but this is the point is
  2728. 1:24:50you're looking at the verbs and figuring
  2729. 1:24:52out what they're going to do and it's
  2730. 1:24:53not that difficult at this point
  2731. 1:24:55now what we're going to do is i want to
  2732. 1:24:57get an event lock now i can just try to
  2733. 1:24:59run this but
  2734. 1:24:59i want to take a look at the help file
  2735. 1:25:01first so i'm going to do get help on get
  2736. 1:25:03event log and i want to take a look at
  2737. 1:25:06the syntax
  2738. 1:25:07and i also if i have questions about the
  2739. 1:25:09parameters i want to be able to see the
  2740. 1:25:10definitions of those parameters so i'm
  2741. 1:25:12going to do dash detailed right now
  2742. 1:25:14and i'm going to go up here and go hey
  2743. 1:25:17here's git event log
  2744. 1:25:20take a look at the syntax look get event
  2745. 1:25:22log look at all of these parameters see
  2746. 1:25:24the dashes
  2747. 1:25:26see the arguments that they can have
  2748. 1:25:27whether they can have multiple values
  2749. 1:25:29and if you don't know what something is
  2750. 1:25:31like
  2751. 1:25:32i wonder what newest means you can
  2752. 1:25:34scroll down and you can take a look down
  2753. 1:25:36here and the reason i'm going through
  2754. 1:25:37this is
  2755. 1:25:38this is what we all have end up doing is
  2756. 1:25:40i don't know necessarily what all the
  2757. 1:25:42parameters mean so a lot of times i go
  2758. 1:25:43to the list and i
  2759. 1:25:44read the list of parameters first
  2760. 1:25:47just to find out what capabilities i
  2761. 1:25:49have i know that seems like it may take
  2762. 1:25:51a few extra minutes but it's worth it
  2763. 1:25:53because i found
  2764. 1:25:54that newest means i can get the newest
  2765. 1:25:57entries in the log but also take a look
  2766. 1:26:00at something else in this syntax
  2767. 1:26:01oops where'd he go look at all of the
  2768. 1:26:04things that are
  2769. 1:26:05optional but i want you to notice
  2770. 1:26:07something looking up here
  2771. 1:26:09i want you to notice that dash log name
  2772. 1:26:12isn't required but
  2773. 1:26:14this guy is i want you to see what
  2774. 1:26:16happens when
  2775. 1:26:18something is mandatory and you try to
  2776. 1:26:20run it so if i just tried to run get
  2777. 1:26:22event like i want you to think about
  2778. 1:26:23this if this worked just like this
  2779. 1:26:25think about all of the it's going to go
  2780. 1:26:27through all the logs and spit all of the
  2781. 1:26:29logs out on my screen
  2782. 1:26:31could that be a little performance issue
  2783. 1:26:34especially if you're doing it
  2784. 1:26:36to 50 machines at once that's now called
  2785. 1:26:38big data
  2786. 1:26:39yeah that's right big data
  2787. 1:26:45so watch i'm going to strike enter and
  2788. 1:26:48powershell smart enough to go hey look
  2789. 1:26:51you need to know what log you want to
  2790. 1:26:52look in so we're going to
  2791. 1:26:54make you tell us what log so i'm going
  2792. 1:26:56to say system now of course it's now
  2793. 1:26:58going to give me the entire system log
  2794. 1:27:00but let me just show you by using the
  2795. 1:27:03help file
  2796. 1:27:04looking at the examples reading the
  2797. 1:27:05parameters you can start to make
  2798. 1:27:07solutions
  2799. 1:27:08like this get event log i know once a
  2800. 1:27:11log name
  2801. 1:27:11i want the log name system i also know
  2802. 1:27:13that i want the newest i think you can
  2803. 1:27:15tab complete that too
  2804. 1:27:18i think you can now too yeah wait a
  2805. 1:27:19minute let's try it didn't used to be
  2806. 1:27:21able to do that let's see
  2807. 1:27:23oh look is that cool that is totally
  2808. 1:27:25cool
  2809. 1:27:26i noticed that a lot in v3 that you can
  2810. 1:27:28now tab complete on a lot of the things
  2811. 1:27:29that the system has i think
  2812. 1:27:31another reason you should be using v3
  2813. 1:27:32yeah um yeah right that's a v3 is on
  2814. 1:27:35not on v2 ism yeah so i know that by
  2815. 1:27:38looking at the help file the newest will
  2816. 1:27:40let me get the newest i'm just going to
  2817. 1:27:41say
  2818. 1:27:41three entries but here's the thing you
  2819. 1:27:43guys know this in a log file there's a
  2820. 1:27:45lot of that information
  2821. 1:27:46stuff and i don't want that just so
  2822. 1:27:48happens if you look at the help file
  2823. 1:27:50you'll find that entry type error
  2824. 1:27:53that's going to give me the three latest
  2825. 1:27:56errors now you might be thinking to
  2826. 1:27:58yourself
  2827. 1:27:59well that's not you know that's cool but
  2828. 1:28:01you know i had to do a lot of reading i
  2829. 1:28:02could have just
  2830. 1:28:03opened up you know the graphical for
  2831. 1:28:05this
  2832. 1:28:06oh yeah but watch this
  2833. 1:28:10thing is this there's a parameter here
  2834. 1:28:13called computer name
  2835. 1:28:14i want the latest three errors from
  2836. 1:28:18three different computers um
  2837. 1:28:21here's the thing i i you need to kind of
  2838. 1:28:24get from all of this you can't open the
  2839. 1:28:27graphical
  2840. 1:28:28fast enough more or less get that data
  2841. 1:28:31that quick
  2842. 1:28:33so in this one command that i figured
  2843. 1:28:36out
  2844. 1:28:37i can get errors from multiple computers
  2845. 1:28:41on my display now it's on my display
  2846. 1:28:45and we're going to fix that here in this
  2847. 1:28:46next section because maybe i don't want
  2848. 1:28:48it on my display
  2849. 1:28:49maybe i want it i don't know in a web
  2850. 1:28:52page
  2851. 1:28:53or a csv or something like that but
  2852. 1:28:56they missed the look show that again a
  2853. 1:28:59web page
  2854. 1:29:00that's why i turned it differently
  2855. 1:29:03so so i've used the help file to build
  2856. 1:29:07one great command
  2857. 1:29:08and now we want to start doing more with
  2858. 1:29:10it so
  2859. 1:29:11to kind of wrap this up here i've got
  2860. 1:29:13some slides in here and like i said
  2861. 1:29:15everything that we've been doing is
  2862. 1:29:16is in the slide deck so let me just kind
  2863. 1:29:18of thumb through here the slides again
  2864. 1:29:20questions you missed something crucial
  2865. 1:29:22did i yeah what are you going to go back
  2866. 1:29:24to that uh
  2867. 1:29:25the wild card help go interactive
  2868. 1:29:28all right would you which good lord here
  2869. 1:29:30go to mine
  2870. 1:29:33he said get help help star
  2871. 1:29:36event log okay and pointed out oh look
  2872. 1:29:39here you got clear you got get
  2873. 1:29:41limit but look here about oh i forgot to
  2874. 1:29:45talk about the about hell yeah no this
  2875. 1:29:47is like one of the most important things
  2876. 1:29:49it's about event logs okay
  2877. 1:29:51so these are what we call conceptual
  2878. 1:29:53topics okay
  2879. 1:29:54so you say okay clear screen and then by
  2880. 1:29:57the way here's a trick i do right so if
  2881. 1:29:59i did
  2882. 1:29:59clear here's thing so now i want to see
  2883. 1:30:01this if i do clear screen
  2884. 1:30:03and then what was it i was going to do
  2885. 1:30:05oh shoot so what you do
  2886. 1:30:07all right because again i'm flawed right
  2887. 1:30:09now it's about
  2888. 1:30:10something okay so here so what you do is
  2889. 1:30:13you do clear screen
  2890. 1:30:14and then semicolon semicolon is a
  2891. 1:30:16statement separator that says
  2892. 1:30:18do this and then do something else so
  2893. 1:30:21it's a way to do two things at once then
  2894. 1:30:23we say
  2895. 1:30:24get let's just say help about
  2896. 1:30:28event by the way tab return event logs
  2897. 1:30:31so then it clears the screen
  2898. 1:30:33and shows me about and so here notice it
  2899. 1:30:35gives me a short description
  2900. 1:30:37describes things viewing the event logs
  2901. 1:30:40goes through the
  2902. 1:30:41the discussion about the topic tells you
  2903. 1:30:44about the commands etc and so there's
  2904. 1:30:46quite a bit here and then
  2905. 1:30:48clear screen if you just say help about
  2906. 1:30:51underscore star yeah that's there you go
  2907. 1:30:55you'll see lots of about topics i mean
  2908. 1:30:58look at them
  2909. 1:30:58there's a and there's just a ton of
  2910. 1:31:00really good stuff here like
  2911. 1:31:02wild cards hey about wild card
  2912. 1:31:06about wild cards about powershell
  2913. 1:31:08version four guess which one i'm using
  2914. 1:31:10about the isc about wmi and there's the
  2915. 1:31:13one i mentioned remember
  2916. 1:31:14remember about wql yeah so so i got to
  2917. 1:31:18tell you this is one of the best
  2918. 1:31:19investments you can make is to go and do
  2919. 1:31:22this
  2920. 1:31:22help about and spend some time reading
  2921. 1:31:25them i mean
  2922. 1:31:25there's really great great stuff there
  2923. 1:31:27yeah and i think i think the
  2924. 1:31:29the important side to this is that
  2925. 1:31:30there's actually two help systems the
  2926. 1:31:31help
  2927. 1:31:32the help will help you discover out of
  2928. 1:31:34both of them
  2929. 1:31:35you've got help system for the
  2930. 1:31:36commandlets and then you have this about
  2931. 1:31:38underscore help system which as
  2932. 1:31:40jeffrey just said is a conceptual stuff
  2933. 1:31:42as we go through today we're going to be
  2934. 1:31:44pointing out oh yeah you need more
  2935. 1:31:45information go to the about underscore
  2936. 1:31:47blah blah blah blah
  2937. 1:31:48oh no there's more information in it no
  2938. 1:31:50there's more than that what's more than
  2939. 1:31:52that oh so you don't know about category
  2940. 1:31:54category yeah so get help last category
  2941. 1:31:59and here here's a trick right so you say
  2942. 1:32:01um
  2943. 1:32:02i know that category takes a value but i
  2944. 1:32:04don't know what value it is right and so
  2945. 1:32:06sometimes we have to have completion
  2946. 1:32:07sometimes we don't here's what i have to
  2947. 1:32:09do
  2948. 1:32:09i just like give a bad value and then
  2949. 1:32:12often what it'll do
  2950. 1:32:13is it'll tell you what categories the
  2951. 1:32:15argument blah blah blah
  2952. 1:32:17does not belong to the set and it tells
  2953. 1:32:20you the set of things that you can type
  2954. 1:32:22oh so you can get specifically for like
  2955. 1:32:24the providers
  2956. 1:32:26that's the key now i'll tell you here we
  2957. 1:32:28we did this and set this up and we had
  2958. 1:32:30quite ambitious things for the help
  2959. 1:32:32subsystem and we haven't fully
  2960. 1:32:33implemented all of them
  2961. 1:32:35some of our partners have implemented
  2962. 1:32:36some of them but we didn't like we were
  2963. 1:32:38going to have
  2964. 1:32:38faqs and glossary terms so so if you say
  2965. 1:32:41help faq it's not there
  2966. 1:32:43okay i'd like to get around to that but
  2967. 1:32:45in particular
  2968. 1:32:46notice here it says where it is
  2969. 1:32:49provider right so what you can do is you
  2970. 1:32:52can say
  2971. 1:32:55by the way tab works
  2972. 1:32:58and tells you oh look here are the
  2973. 1:33:00various providers now we're going to
  2974. 1:33:02talk about this topic
  2975. 1:33:03later but if you did that and you said
  2976. 1:33:06oh get help
  2977. 1:33:09certificate certificate
  2978. 1:33:13certificate okay
  2979. 1:33:18it'll give you information about a
  2980. 1:33:19provider when we get to the topic about
  2981. 1:33:20providers this will make more sense
  2982. 1:33:22but it's a very very rich health system
  2983. 1:33:24yeah very rich help system
  2984. 1:33:42[Music]
  2985. 1:33:50so our third topic for the day is
  2986. 1:33:52getting connected with the pipeline
  2987. 1:33:54and the first thing is is um yeah we're
  2988. 1:33:56going to go through all of this so
  2989. 1:33:57there's the cute module overview
  2990. 1:33:59but take a look at this what's the
  2991. 1:34:01pipeline first of all look at the
  2992. 1:34:02character here
  2993. 1:34:03see this character okay this is located
  2994. 1:34:06above like it says right here located
  2995. 1:34:07above your enter key
  2996. 1:34:09and the reason i say it like that is
  2997. 1:34:11because a lot of folks don't even know
  2998. 1:34:13where this character is let me give you
  2999. 1:34:14an example
  3000. 1:34:17so get service
  3001. 1:34:21pipe what's going to happen is is get
  3002. 1:34:24service is going to go out and get
  3003. 1:34:26a collection of service objects they're
  3004. 1:34:29technically called service controllers
  3005. 1:34:30and you're going to see what all that is
  3006. 1:34:32later but it's going to grab all of
  3007. 1:34:34those services
  3008. 1:34:36and then it's going to send them and i'm
  3009. 1:34:39i'm not talking about a text
  3010. 1:34:40representation
  3011. 1:34:41i'm talking about the actual service
  3012. 1:34:43objects themselves it's going to send
  3013. 1:34:45them
  3014. 1:34:45one at a time across this pipeline what
  3015. 1:34:48do you want to do
  3016. 1:34:50next to these services well let's narrow
  3017. 1:34:53this down a little bit let's just do
  3018. 1:34:55the name bits take a look it's running
  3019. 1:35:00take a guess what i could do if i wanted
  3020. 1:35:01to stop this service you probably
  3021. 1:35:03could guess that there's a commandlet
  3022. 1:35:05called stop service and you would be
  3023. 1:35:07correct
  3024. 1:35:07there is there's one called stop service
  3025. 1:35:09and you can specify a name but
  3026. 1:35:11here's the interesting thing
  3027. 1:35:15i can pipe it to stop service
  3028. 1:35:18if i could type it here's what's going
  3029. 1:35:21to happen
  3030. 1:35:22we're going to take that bit service
  3031. 1:35:23we're going to send it across that
  3032. 1:35:24pipeline stop service is going to grab
  3033. 1:35:26hold of that
  3034. 1:35:27and do exactly what it says it's going
  3035. 1:35:29to do it's going to stop the service now
  3036. 1:35:30we're going to talk
  3037. 1:35:31a little bit later in more detail about
  3038. 1:35:33how this pipeline works because it's
  3039. 1:35:35crucially important in troubleshooting
  3040. 1:35:37but just take a look
  3041. 1:35:39well i wonder what it did well let's run
  3042. 1:35:42ah i stopped it
  3043. 1:35:43now i can pipe and i can even say start
  3044. 1:35:46service and
  3045. 1:35:46i'm going to use a pass through on here
  3046. 1:35:49that will show me the results of what
  3047. 1:35:50i'm doing
  3048. 1:35:52and now it started again now i know
  3049. 1:35:53that's a simple pipeline
  3050. 1:35:55but that concept of taking something
  3051. 1:35:57sending across the pipeline
  3052. 1:35:59to have something else act on it is very
  3053. 1:36:02important and we can continue we can
  3054. 1:36:04pipe from one thing to the next thing to
  3055. 1:36:06the next thing
  3056. 1:36:07so as an example let's start out with a
  3057. 1:36:10couple of cool things
  3058. 1:36:11oh hey first of all jeffy what do you
  3059. 1:36:12think i just love to ask people this oh
  3060. 1:36:15don't be careful with the inner key
  3061. 1:36:19what do you think jeffrey is that going
  3062. 1:36:22to do what i think it's going to do
  3063. 1:36:24yeah don't you want you don't want to do
  3064. 1:36:25that i don't don't want to do that
  3065. 1:36:27guys we we're going to show you the
  3066. 1:36:29pipeline is very powerful
  3067. 1:36:30it can also allow you to make silly
  3068. 1:36:33mistakes
  3069. 1:36:34so it's worth pointing out powershell is
  3070. 1:36:37a powerful tool a powerful tool like a
  3071. 1:36:40really sharp knife um if really sharp
  3072. 1:36:43knife is super super useful
  3073. 1:36:45probably don't want to give it to your
  3074. 1:36:46kids right or or you want
  3075. 1:36:48you know you want to be thoughtful about
  3076. 1:36:50this stuff powershell you can do some
  3077. 1:36:53damaging things and so often we you know
  3078. 1:36:55give you techniques to deal with that
  3079. 1:36:57but
  3080. 1:36:58indeed you know don't complain if if you
  3081. 1:37:00say oh well geez i
  3082. 1:37:01removed all the files from my file
  3083. 1:37:02system power darn
  3084. 1:37:05by the way i did that actually i was i
  3085. 1:37:07was i was i was giving an example of how
  3086. 1:37:09to do this
  3087. 1:37:10and and the guards that we have and i
  3088. 1:37:12forgot to put that in and i hit carriage
  3089. 1:37:14turn
  3090. 1:37:14and it turns out if you kill lsass bad
  3091. 1:37:17things happen
  3092. 1:37:17bad things bad things especially when
  3093. 1:37:19you're in front of like 700 people
  3094. 1:37:21doing a demo very bad things happen
  3095. 1:37:24strongly
  3096. 1:37:25not recommended because i've hit the
  3097. 1:37:26inter on the get service stop service
  3098. 1:37:28and it's just not cool powershell
  3099. 1:37:30doesn't ask you are you sure
  3100. 1:37:32until later when we show you how you can
  3101. 1:37:34get it to but it doesn't so
  3102. 1:37:35it assumes you know what you're doing um
  3103. 1:37:38let me do an
  3104. 1:37:39example here of another pipeline thing
  3105. 1:37:41let's talk about csvs for a second a lot
  3106. 1:37:43of times
  3107. 1:37:44export here's a command export csv guess
  3108. 1:37:47what export
  3109. 1:37:48csv is going to do it's going to take
  3110. 1:37:49this information and
  3111. 1:37:51export it to a csv and so i'm going to
  3112. 1:37:54put in a path of c
  3113. 1:37:55colon let's just call it service dot csv
  3114. 1:37:58you guys know what a csv is comma
  3115. 1:38:00separated file and yes
  3116. 1:38:02you can change the delimiters if you
  3117. 1:38:03look at the help file for export csv
  3118. 1:38:05you can change the delimiters and modify
  3119. 1:38:07how it works but
  3120. 1:38:08let's take a look at this csv i'm going
  3121. 1:38:10to open this up in notepad
  3122. 1:38:12not the correct tool for looking at a
  3123. 1:38:14csv
  3124. 1:38:15because it's going to look at this text
  3125. 1:38:17bob but i just want you to see see all
  3126. 1:38:18that yep it's all comma
  3127. 1:38:19comma separated but here's here's one of
  3128. 1:38:21the interesting rules about powershell
  3129. 1:38:23is
  3130. 1:38:23if you can export it you're going to
  3131. 1:38:25want to import it at some point
  3132. 1:38:27you're going to want to work with that
  3133. 1:38:28data again so if you can export it
  3134. 1:38:32you can import the csv so import
  3135. 1:38:36csv
  3136. 1:38:39i forgot what i called it but not that
  3137. 1:38:41there we go
  3138. 1:38:42and now all that data comes back and
  3139. 1:38:44it's formatted correctly and it's
  3140. 1:38:46attached correctly so i can actually
  3141. 1:38:47work with it now
  3142. 1:38:48now these are simple examples of the
  3143. 1:38:50pipeline but we're also showing you some
  3144. 1:38:52some great export stuff so besides
  3145. 1:38:55exporting
  3146. 1:38:57like to a csv there's my favorite
  3147. 1:39:02oops command line xml
  3148. 1:39:05i love xml xml is greatest thing since
  3149. 1:39:07the automation is sliced bread
  3150. 1:39:10great example you guys used to do online
  3151. 1:39:12banking years ago
  3152. 1:39:14you go to the uh you buy something swipe
  3153. 1:39:16your credit card
  3154. 1:39:17three days later it would show up in
  3155. 1:39:19your account today you swipe it when's
  3156. 1:39:21it show up in your account
  3157. 1:39:22just as it finishes swiping it's xml
  3158. 1:39:25baby it's xml um so let's
  3159. 1:39:28uh export to xml and here's what i'm
  3160. 1:39:30gonna do instead of doing uh get service
  3161. 1:39:34i'm gonna do get process i like that
  3162. 1:39:37and i'm gonna make a little i'm going to
  3163. 1:39:39pretend i'm going to do this call this
  3164. 1:39:41good xml i want you to pretend something
  3165. 1:39:45for a second i want you to pretend that
  3166. 1:39:47i've just taken a snapshot of a
  3167. 1:39:49perfectly running a perfectly good
  3168. 1:39:51running machine
  3169. 1:39:52runs perfectly and i've just
  3170. 1:39:55snapshotted its processes now if you
  3171. 1:39:58blink your eyes
  3172. 1:40:00pretend for a moment that now i'm
  3173. 1:40:01working on a non-perfectly running
  3174. 1:40:03machine
  3175. 1:40:07and what i'd like to do is i'd like to
  3176. 1:40:09compare
  3177. 1:40:12the good machine to the non-good machine
  3178. 1:40:16yeah imagine those instead of notepad
  3179. 1:40:17and calc imagine that was some malware
  3180. 1:40:20yeah exactly i'm just using notepad
  3181. 1:40:23now the the compare object i'm just
  3182. 1:40:26giving an example of how
  3183. 1:40:27the pipeline and how using commandlets
  3184. 1:40:29can can
  3185. 1:40:30be very useful to you so i've got a
  3186. 1:40:32reference object now i want you to
  3187. 1:40:33notice i'm going to use
  3188. 1:40:34uh parentheses we're going to talk more
  3189. 1:40:36about parentheticals but this means
  3190. 1:40:38do this first and what i need to do is i
  3191. 1:40:40need to import
  3192. 1:40:41the good xml file that represents the
  3193. 1:40:44good machine
  3194. 1:40:47and then i want to compare that to
  3195. 1:40:51this currently running machine now when
  3196. 1:40:53you run get process
  3197. 1:40:54there's a lot of information that comes
  3198. 1:40:56up what i want is i just wanted to
  3199. 1:40:58compare
  3200. 1:40:59the names of the processes right now and
  3201. 1:41:01see if there's a difference
  3202. 1:41:03so what i've done is i've exported my
  3203. 1:41:05process information with the pipeline
  3204. 1:41:07and now i'm just going to compare it
  3205. 1:41:10notice the site indicator points to the
  3206. 1:41:13bad machine
  3207. 1:41:14and is saying hey look calc and notepad
  3208. 1:41:17are running on that
  3209. 1:41:18and as opposed to what's on the good
  3210. 1:41:19machine this is an example of how you're
  3211. 1:41:22going to start to be able to build
  3212. 1:41:23commands
  3213. 1:41:24with the pipeline to do something and
  3214. 1:41:26then
  3215. 1:41:27use other commands to achieve your
  3216. 1:41:28results imagine comparing two machines
  3217. 1:41:32the software that's installed on them
  3218. 1:41:33and making you want to make one machine
  3219. 1:41:35look
  3220. 1:41:35just like another so there's a lot of
  3221. 1:41:37things that we can do with building a
  3222. 1:41:39pipeline
  3223. 1:41:40one last example and then we'll take a
  3224. 1:41:41shortcut oh yeah you know so what jason
  3225. 1:41:43just showed you
  3226. 1:41:44is freakishly powerful and we're going
  3227. 1:41:46to drill into it
  3228. 1:41:47in in the future so what we did was we
  3229. 1:41:50took a set of live
  3230. 1:41:51objects and we compared them against an
  3231. 1:41:54xml
  3232. 1:41:54file like how do you do that and the
  3233. 1:41:57answer is
  3234. 1:41:58the magic of powershell and the things
  3235. 1:42:00we call objects and object adapters
  3236. 1:42:02and of course if you just try to compare
  3237. 1:42:04these things it would say they're
  3238. 1:42:05completely different so he didn't he
  3239. 1:42:07said
  3240. 1:42:07i just want to compare them based upon
  3241. 1:42:09their name and so what you've done
  3242. 1:42:12okay we've really kind of led you to is
  3243. 1:42:14again you
  3244. 1:42:15think about what you want to do you type
  3245. 1:42:17it and the magic of powershell is able
  3246. 1:42:19to take these
  3247. 1:42:20incredibly complex stuff and present it
  3248. 1:42:24to you in a very simple world
  3249. 1:42:26so let me show you a couple other
  3250. 1:42:27command line things and and jeffrey will
  3251. 1:42:29be
  3252. 1:42:29adding in um stuff here just so you can
  3253. 1:42:31get the idea of kind of what's going on
  3254. 1:42:34besides exporting out to like csvs and
  3255. 1:42:37xml there's some other things you can do
  3256. 1:42:39so get service
  3257. 1:42:40everybody always wants to know how do i
  3258. 1:42:42put something into
  3259. 1:42:44just a text file well you know first of
  3260. 1:42:46all you could have found
  3261. 1:42:47out file by looking for get help star
  3262. 1:42:50file or
  3263. 1:42:51something like that which is totally
  3264. 1:42:53awesome and you'll find out file out
  3265. 1:42:55file has
  3266. 1:42:56if you look at the help file for it
  3267. 1:42:57wants you to give it a path
  3268. 1:42:59and um and you give it a path to what
  3269. 1:43:02you want to use as
  3270. 1:43:03a for your text file so test dot
  3271. 1:43:07text and you can get the content
  3272. 1:43:11did i say get the content you can get
  3273. 1:43:13the content from a text file
  3274. 1:43:15you know i wonder if there's anything
  3275. 1:43:17that could help me
  3276. 1:43:18with getting content from a text
  3277. 1:43:22file oh lookie get content the help
  3278. 1:43:25system
  3279. 1:43:26help systems your friend so you can get
  3280. 1:43:28the content
  3281. 1:43:30from a text file by just using get
  3282. 1:43:32content
  3283. 1:43:35and and i think i call that test.text
  3284. 1:43:38and there's all that get service content
  3285. 1:43:40that i just put in a text file but
  3286. 1:43:42wait there's more you can send stuff out
  3287. 1:43:45to a printer
  3288. 1:43:46out to a printer out printer out
  3289. 1:43:49printer so there's a set of things you
  3290. 1:43:51could set it out to
  3291. 1:43:52there's i wonder i wonder how we could
  3292. 1:43:55find
  3293. 1:43:56a list of the things that we could
  3294. 1:43:59send stuff out to
  3295. 1:44:02yeah no just out just start without
  3296. 1:44:05start without
  3297. 1:44:06yeah well but here look there's a ton of
  3298. 1:44:08stuff that we can send for
  3299. 1:44:10out um so again the help file
  3300. 1:44:14is your friend besides sending stuff out
  3301. 1:44:16there's also creative
  3302. 1:44:18ways to do stuff so get service i love
  3303. 1:44:21this
  3304. 1:44:21this is one of my favorite things we
  3305. 1:44:22also have convert to commandlets
  3306. 1:44:25convert to csv now this is gonna make
  3307. 1:44:28more sense later but
  3308. 1:44:29well you just had an export csv yeah
  3309. 1:44:32and we have a convert to csv the
  3310. 1:44:34difference being for right now
  3311. 1:44:36when you do an export csv you're done
  3312. 1:44:39you're you're done when you do a convert
  3313. 1:44:41to csv we're going to leave that stuff
  3314. 1:44:43in the pipeline in case you want to
  3315. 1:44:44pipeline it and do other things to it so
  3316. 1:44:47the way i think about it yeah is uh
  3317. 1:44:49export is convert
  3318. 1:44:50coupled with output it to a file yeah i
  3319. 1:44:53uh
  3320. 1:44:54excellent excellent because if you do an
  3321. 1:44:57export csv
  3322. 1:44:58you have a mandatory where you have to
  3323. 1:44:59send it to a file so think of it as
  3324. 1:45:01a convert with an out file already built
  3325. 1:45:05right in
  3326. 1:45:05so we have the converts but i want to
  3327. 1:45:07show you one of my favorite ones
  3328. 1:45:10he he he
  3329. 1:45:15um did i mention as a web guide uh
  3330. 1:45:16anyways the uh
  3331. 1:45:18and i want to pick just a couple of
  3332. 1:45:19properties for this i'm going to take
  3333. 1:45:21name
  3334. 1:45:21and status the reason i knew that
  3335. 1:45:23convert to html has a dash property
  3336. 1:45:25parameter
  3337. 1:45:26and it had chihuahuas that would take
  3338. 1:45:29multiple arguments is because i
  3339. 1:45:30looked at the help file so it's going to
  3340. 1:45:32convert it to as you would expect html
  3341. 1:45:35and at this point
  3342. 1:45:36there it did it it's the cleanest html
  3343. 1:45:38by the way
  3344. 1:45:40it did exactly what i asked it to do but
  3345. 1:45:42here's an example of me saying look
  3346. 1:45:44i i don't want it to my screen i now
  3347. 1:45:47want it in a
  3348. 1:45:48file i want it out to a file so let's
  3349. 1:45:50pipe it out
  3350. 1:45:52file and let's call this just test.htm
  3351. 1:45:56and you guys know if you haven't
  3352. 1:45:58can you reduce your go down a little bit
  3353. 1:46:00more oh yeah yeah yeah yeah
  3354. 1:46:02yeah thanks guys for telling us about
  3355. 1:46:03that in the discussion thing i want to
  3356. 1:46:04lower my
  3357. 1:46:05command down so that's that's picture in
  3358. 1:46:07all its glory in all of its
  3359. 1:46:09beautiful glory and you guys know that
  3360. 1:46:11if you double click
  3361. 1:46:13did i say double click yes i said double
  3362. 1:46:15click on an htm it'll pop we'll see
  3363. 1:46:17no more double clicking no more mouse no
  3364. 1:46:19more mouse so what i'm going to do is
  3365. 1:46:20just say
  3366. 1:46:21c colon test htm and powershell will
  3367. 1:46:25launch it up there for me do you get i
  3368. 1:46:28just
  3369. 1:46:28made a web page how many developers did
  3370. 1:46:32that take
  3371. 1:46:33and if you look at the help for
  3372. 1:46:37convert to html you're going to find
  3373. 1:46:40that you have a lot of options to make
  3374. 1:46:43this pretty
  3375. 1:46:44there's a lot of ways to make this very
  3376. 1:46:46pretty with tables and all kinds of
  3377. 1:46:48using style sheets and so forth so
  3378. 1:46:50it pays to look at the help but this is
  3379. 1:46:51a good example of piping
  3380. 1:46:54from one command to another to achieve a
  3381. 1:46:56certain result
  3382. 1:46:58so let's take a look at what else we got
  3383. 1:47:00going we got
  3384. 1:47:01to the web page and you know these are
  3385. 1:47:03just some examples of piping some stuff
  3386. 1:47:06oh we're going to have to talk about
  3387. 1:47:08stuff that kills because we almost i
  3388. 1:47:10almost screwed up earlier yeah
  3389. 1:47:12it's fun this is fun so let me and
  3390. 1:47:14jeffrey you can help me out here with
  3391. 1:47:16this one because i'm going to
  3392. 1:47:17get service and i'm going to do stop
  3393. 1:47:20service
  3394. 1:47:22and i want to know if this works or not
  3395. 1:47:24but seems kind of risky to me
  3396. 1:47:26yeah what can i do when in trouble fear
  3397. 1:47:30or doubt run in circles scream and shout
  3398. 1:47:33so no that's what they juiced
  3399. 1:47:38that's what they used to teach kids at
  3400. 1:47:39boy scouts when you go on a trip
  3401. 1:47:42oh so no here's the thing when you're
  3402. 1:47:44ever
  3403. 1:47:45so i once dealt with an admin who said
  3404. 1:47:47you know every now and again
  3405. 1:47:49it's late and doing something and i
  3406. 1:47:50realize i'm about to hit the carriage
  3407. 1:47:52return or enter key
  3408. 1:47:53and i realize if i get it wrong like
  3409. 1:47:55that's the end
  3410. 1:47:56right i'm i'm going to be fired muffy
  3411. 1:47:58and buffy are not going to go to college
  3412. 1:48:03what are we doing that we create an
  3413. 1:48:05environment where somebody that's the
  3414. 1:48:06world that they have to live with
  3415. 1:48:08and so in powershell if you ever have
  3416. 1:48:11something that you're uncertain of
  3417. 1:48:13you can always type minus what if like
  3418. 1:48:16what if i did this what would actually
  3419. 1:48:17happen
  3420. 1:48:18and you would get
  3421. 1:48:22[Music]
  3422. 1:48:23and it tells you what it would do but it
  3423. 1:48:25doesn't actually do it
  3424. 1:48:26now the the best part is that it tells
  3425. 1:48:30you what it would do
  3426. 1:48:31but it didn't actually do it and if you
  3427. 1:48:33look at my screen
  3428. 1:48:34it says yep i would have stopped these
  3429. 1:48:36services now
  3430. 1:48:37if you're thinking to yourself that oh
  3431. 1:48:39well this is a nice fast way to shut
  3432. 1:48:40down my computer
  3433. 1:48:41no no no no this is going to blue screen
  3434. 1:48:43way before
  3435. 1:48:44it gets shut down so it won't blue
  3436. 1:48:46screen but it's going to stop somewhere
  3437. 1:48:48around
  3438. 1:48:49power shell service host somewhere in
  3439. 1:48:51there muffy and buffy would not be going
  3440. 1:48:52to college after this one
  3441. 1:48:55so you're not going to want to do that
  3442. 1:48:56but something to keep in mind we also
  3443. 1:48:58besides what if and i use what if all
  3444. 1:49:00the time because you know
  3445. 1:49:02things can be dangerous that you're
  3446. 1:49:03trying out we also have dash
  3447. 1:49:06confirm and dash confirm is a what if
  3448. 1:49:10with do you actually want to do this now
  3449. 1:49:13i'm obviously not going to say yes to
  3450. 1:49:15anything and certainly not yes to all
  3451. 1:49:17so let's just i'm going to put my finger
  3452. 1:49:19on the l right now so that
  3453. 1:49:21nothing happens but i want you to notice
  3454. 1:49:23it is showing you both what it will do
  3455. 1:49:25and then asking you do you want me to do
  3456. 1:49:27this so people ask all the time
  3457. 1:49:29powershell doesn't ask me are you sure
  3458. 1:49:30yeah because powershell's not for
  3459. 1:49:31sissies but
  3460. 1:49:32sometimes you need that capability
  3461. 1:49:36so i'm going to hit l and please don't
  3462. 1:49:39don't actually do anything yeah that'd
  3463. 1:49:40be good hey can i show them something
  3464. 1:49:42yeah
  3465. 1:49:42okay so remember so at some level this
  3466. 1:49:45isn't that interesting right get
  3467. 1:49:47service pipe to stop service right
  3468. 1:49:50uh what if i mean okay but who is gonna
  3469. 1:49:53do that right you're just not gonna do
  3470. 1:49:55that right
  3471. 1:49:56but remember what i said earlier right
  3472. 1:49:58about this like
  3473. 1:49:59programming with hand grenades thing
  3474. 1:50:01what i said was
  3475. 1:50:02okay so let's see there's this bits
  3476. 1:50:05thing
  3477. 1:50:05and i i don't remember what the heck it
  3478. 1:50:07was so what i'm gonna say is display
  3479. 1:50:09name
  3480. 1:50:10something to do with bits and or maybe
  3481. 1:50:12it was something to do with bi
  3482. 1:50:14right and then and then stop service
  3483. 1:50:18service now did i get that one right now
  3484. 1:50:20this is the more
  3485. 1:50:21realistic thing did i get that one right
  3486. 1:50:23because maybe bi star
  3487. 1:50:25maps to bipp's service and maybe it
  3488. 1:50:27doesn't so what you do here is you say
  3489. 1:50:29what if
  3490. 1:50:30and you're like yeah oh oh oh no
  3491. 1:50:33good thing i didn't do that now at this
  3492. 1:50:36point you could go and say okay
  3493. 1:50:38why did that match oh i see biometric
  3494. 1:50:41and then oh i see compatibility
  3495. 1:50:43now if you wanted to you could go in
  3496. 1:50:44here and try and like tweak this thing
  3497. 1:50:46right and do this but instead you can
  3498. 1:50:49just say no
  3499. 1:50:49you know what it's close enough confirm
  3500. 1:50:53and you say bitlocker yep that's the one
  3501. 1:50:55i want to do it to so you you stop that
  3502. 1:50:57and then this one you say no that was
  3503. 1:50:59the only one so you say
  3504. 1:51:01no to the rest and now i've stopped
  3505. 1:51:05g s v b i oh
  3506. 1:51:08oh i got the wrong one oh you know what
  3507. 1:51:11i shouldn't stop that locker that was a
  3508. 1:51:12bad thing yeah i think that might have
  3509. 1:51:13been
  3510. 1:51:16well great example of a practical use of
  3511. 1:51:20that's confirmed i know that's perfect
  3512. 1:51:22i'm now out of compliance with corporate
  3513. 1:51:24policy there you are
  3514. 1:51:25these doors might come bursting open but
  3515. 1:51:28well so hopefully they will not burst
  3516. 1:51:31open
  3517. 1:51:32so guys this is our first introduction
  3518. 1:51:34to the pipeline we're going to go much
  3519. 1:51:36deeper into this pipeline but the
  3520. 1:51:37concept again
  3521. 1:51:38is you have a commandlet you're going to
  3522. 1:51:41pipe the results of that commandlet to
  3523. 1:51:43the next one so
  3524. 1:51:44do this then do this then do this then
  3525. 1:51:47do this
  3526. 1:51:48until your needs are done and what
  3527. 1:51:49you're going to notice is as we go
  3528. 1:51:50through this and you get more and more
  3529. 1:51:52commandlets
  3530. 1:51:53you're going to see that the way you're
  3531. 1:51:54thinking about the solving the problem
  3532. 1:51:57is the way that you'll actually be
  3533. 1:51:58building the commands in the pipeline
  3534. 1:52:01now you don't have to do everything as a
  3535. 1:52:03one-liner and one-liners are great we're
  3536. 1:52:05going to do a lot of them in here
  3537. 1:52:06but we're also going to do scripting
  3538. 1:52:08where you know a one-liner is you know
  3539. 1:52:10when it's when it's half the page
  3540. 1:52:12you're probably a little out of control
  3541. 1:52:13at that point but
  3542. 1:52:15you can is the idea now
  3543. 1:52:18before we go too much further into the
  3544. 1:52:21pipeline
  3545. 1:52:22jeffrey let's let's do this uh you know
  3546. 1:52:24i've got a slide here so let me show
  3547. 1:52:26everybody where we're at
  3548. 1:52:28so guys again make sure you're asking
  3549. 1:52:30questions all that kind of stuff and and
  3550. 1:52:31for all the people out in the support
  3551. 1:52:32the mvps and everybody who's
  3552. 1:52:34contributing
  3553. 1:52:35thank you so much for helping us out and
  3554. 1:52:37answering all of these questions
  3555. 1:52:39uh that are out there um let's go into
  3556. 1:52:42extending the shell a little bit and
  3557. 1:52:43there's i
  3558. 1:52:44this is a fascinating conversation for
  3559. 1:52:45me because
  3560. 1:52:47i can't remember the exact number but i
  3561. 1:52:48think when powershell 100 came out i
  3562. 1:52:50think there's like 192 commandlets
  3563. 1:52:53that's right that's all we could do was
  3564. 1:52:54like 190 things yeah yeah then
  3565. 1:52:56powershell v2 came out and there was 236
  3566. 1:52:59well there's only 236 things
  3567. 1:53:01that we could do but we need to do more
  3568. 1:53:05than that
  3569. 1:53:05i mean we we need something that's
  3570. 1:53:08extensible so that we can do
  3571. 1:53:09so how do we get more than just the core
  3572. 1:53:12powershell command lines who's
  3573. 1:53:13responsible for all of that kind of
  3574. 1:53:15stuff
  3575. 1:53:15it takes a village my friend it takes a
  3576. 1:53:17village it's a village
  3577. 1:53:20that's exactly the point so the
  3578. 1:53:22powershell team is responsible for the
  3579. 1:53:24core powershell
  3580. 1:53:25environment the language etc and then
  3581. 1:53:28you have plug-ins
  3582. 1:53:29right or snap-ins or we now call modules
  3583. 1:53:32and this is where you know like trust me
  3584. 1:53:35you don't want me writing the link
  3585. 1:53:36commandlets right that's not
  3586. 1:53:39that doesn't end well and so we do is we
  3587. 1:53:41create an
  3588. 1:53:42environment where it's very easy for the
  3589. 1:53:44individual feature teams to write their
  3590. 1:53:46stuff and ship their stuff and that's
  3591. 1:53:48why when you say
  3592. 1:53:49oh well i i want to do some stuff with
  3593. 1:53:52powershell
  3594. 1:53:53uh where are the link commandlets well
  3595. 1:53:55do you have link installed because you
  3596. 1:53:56don't have link installed you're not
  3597. 1:53:57going to get the link commandlets
  3598. 1:53:59so the idea is that the commandlets ship
  3599. 1:54:02with the thing that needs to be managed
  3600. 1:54:04okay so we do this through modules also
  3601. 1:54:07in the
  3602. 1:54:08originally they were snap-ends right so
  3603. 1:54:10snap-ins and if you've got powershell
  3604. 1:54:12version one or powershell version two
  3605. 1:54:14you have this thing called snap-ins it
  3606. 1:54:16turns out there were a number of
  3607. 1:54:18limitations with snap-ins
  3608. 1:54:19the biggest you had to be administrator
  3609. 1:54:21to get them installed
  3610. 1:54:23and there's something else well oh you
  3611. 1:54:26couldn't xcopy deploy them
  3612. 1:54:28yeah and modules now modules is
  3613. 1:54:31basically uh
  3614. 1:54:32kind of conceptually modeled after the
  3615. 1:54:34module or
  3616. 1:54:35package modules of pearl and python and
  3617. 1:54:38ruby
  3618. 1:54:39but actually it's much richer than those
  3619. 1:54:41much richer than those
  3620. 1:54:42but the idea is you'll be able to
  3621. 1:54:44package up your stuff and then
  3622. 1:54:46x copy deploy it and then you import
  3623. 1:54:48your modules
  3624. 1:54:50so let's take a look first of all on
  3625. 1:54:52what jeffrey is saying is and i think
  3626. 1:54:54this is
  3627. 1:54:55it's a you guys all of you guys have run
  3628. 1:54:57the mmc before
  3629. 1:54:59and you know the mmc you can file
  3630. 1:55:02add remove snap in and you get a list of
  3631. 1:55:05stuff here that you can add in i want
  3632. 1:55:06you to notice on mine
  3633. 1:55:08i happen to have some of the active
  3634. 1:55:09directory snap-ins you guys know that
  3635. 1:55:12in order to get those i had to install
  3636. 1:55:15something and in this case i'd install
  3637. 1:55:17the remote server administration tools
  3638. 1:55:18to get the active directory ones
  3639. 1:55:20well it's the same concept when you're
  3640. 1:55:22working with powershell
  3641. 1:55:24do you have the product installed well i
  3642. 1:55:26have the remote server administration
  3643. 1:55:28tools installed and so
  3644. 1:55:30i'm going to get those modules let me
  3645. 1:55:33show you powershell
  3646. 1:55:35has a command called get module
  3647. 1:55:38this will show you what's currently
  3648. 1:55:40loaded up however
  3649. 1:55:41list available will show you the modules
  3650. 1:55:43that are available now i need to just
  3651. 1:55:44tell you right now i
  3652. 1:55:46this is very confusing in v2
  3653. 1:55:49yeah yeah in v2 first of all you're not
  3654. 1:55:52going to see what you're going to see on
  3655. 1:55:53my screen
  3656. 1:55:54in v2 you're not going to see it in
  3657. 1:55:57windows 7
  3658. 1:55:58either what you're seeing here is
  3659. 1:56:00windows 8 running the windows 8 remote
  3660. 1:56:02server administration tools and i get
  3661. 1:56:04more modules than you do
  3662. 1:56:06because he's cool well not because i'm
  3663. 1:56:08cool because i've
  3664. 1:56:10upgraded um so on i know your corporate
  3665. 1:56:13standard
  3666. 1:56:14you may not be doing it yet but your
  3667. 1:56:16admin box
  3668. 1:56:17needs to be running v3 and as you're
  3669. 1:56:20going to want
  3670. 1:56:20it needs to be running windows 8 okay so
  3671. 1:56:23but at any rate let me just show you
  3672. 1:56:26god i i'm not the guy that works for
  3673. 1:56:28microsoft and i'm the one over here
  3674. 1:56:30um so you can see i get this giant list
  3675. 1:56:34of modules and
  3676. 1:56:35notice one of the modules at the very
  3677. 1:56:36top here is called active directory the
  3678. 1:56:38reason i have that module
  3679. 1:56:40is because i installed the remote server
  3680. 1:56:41administration tools here's what that
  3681. 1:56:43module contains
  3682. 1:56:45commandlets commandlets that let me
  3683. 1:56:47manage active directory
  3684. 1:56:50and what and providers but we didn't
  3685. 1:56:52provide us we don't talk about providers
  3686. 1:56:53yet but yes and providers
  3687. 1:56:56if you have a module with commandlets
  3688. 1:56:58here's the beautiful thing about
  3689. 1:56:59powershell v3
  3690. 1:57:01you're going to love this when you use
  3691. 1:57:02get help
  3692. 1:57:04get help knows how to look through those
  3693. 1:57:06modules even if they're not loaded
  3694. 1:57:08so get help i want you to show me do i
  3695. 1:57:10have any
  3696. 1:57:11active directory commandlets
  3697. 1:57:15i want you to notice that yes there's a
  3698. 1:57:17lot of things with a.d in it and i could
  3699. 1:57:18have refined the search better but
  3700. 1:57:20that's kind of my point is i want you to
  3701. 1:57:21see that
  3702. 1:57:22there's a whole bunch of ad commandlets
  3703. 1:57:25here you'll recognize
  3704. 1:57:26ad computer as this will give me active
  3705. 1:57:29directory computers
  3706. 1:57:31that helps that help get help knows how
  3707. 1:57:33to look into these modules
  3708. 1:57:35find these commandments to show them so
  3709. 1:57:37you still have complete discoverability
  3710. 1:57:40and when you want help on the command
  3711. 1:57:42that you found
  3712. 1:57:43get help get ad computer
  3713. 1:57:47it'll give you the help for it when you
  3714. 1:57:50try to use the commandlet
  3715. 1:57:52this is one of the biggest features for
  3716. 1:57:54me personally in v3
  3717. 1:57:56is when you try to use the commandlet
  3718. 1:57:59and i think i may have used this one
  3719. 1:58:00earlier so you may not see it flash on
  3720. 1:58:02my screen but
  3721. 1:58:03take a look up it just ran but let me do
  3722. 1:58:07this i'm going to close my console and
  3723. 1:58:09reopen it because i i want you to see
  3724. 1:58:10this if you can catch it on my screen
  3725. 1:58:12real quick
  3726. 1:58:13let me the other way to do this is do it
  3727. 1:58:15do a get module
  3728. 1:58:18we'll show it yeah get module okay let's
  3729. 1:58:20do that we're gonna do
  3730. 1:58:22get module yeah character turn
  3731. 1:58:26so these are the currently loaded
  3732. 1:58:28modules right these are the currently
  3733. 1:58:29loaded
  3734. 1:58:30yes now do it and then and now yes thank
  3735. 1:58:32you thank you so these are the currently
  3736. 1:58:34loaded ones now watch what i'm going to
  3737. 1:58:35do i'm going to do get
  3738. 1:58:36ad computer and watch what flashes
  3739. 1:58:38across my screen real quick just
  3740. 1:58:40boy that was real quick i don't know if
  3741. 1:58:41you caught it it actually
  3742. 1:58:43dynamically loaded the module for me so
  3743. 1:58:46that i had the commandments and notice
  3744. 1:58:47the commandlet ran
  3745. 1:58:49i didn't have to do anything special the
  3746. 1:58:51reason i'm making a big deal about this
  3747. 1:58:53and here i'll show you and get module
  3748. 1:58:54get module now you'll see that
  3749. 1:58:56it automatically loaded the active
  3750. 1:58:58directory module for me
  3751. 1:59:00reason i'm making a big deal about this
  3752. 1:59:01in v2 your life sucks because it doesn't
  3753. 1:59:04work that way
  3754. 1:59:05let me tell you and i'm i'm sorry sir
  3755. 1:59:07but this
  3756. 1:59:08in v2 this was painful because in v2 get
  3757. 1:59:12help would not find the commandments
  3758. 1:59:13unless the module was
  3759. 1:59:14imported yes so you had to know what the
  3760. 1:59:17module was
  3761. 1:59:18first then import it then you could
  3762. 1:59:21discover
  3763. 1:59:22see it didn't quite work they fixed all
  3764. 1:59:24that with b3
  3765. 1:59:25now it works just like i need it to work
  3766. 1:59:28and when i run the command the module
  3767. 1:59:29loads
  3768. 1:59:30so i'm not loading modules unnecessarily
  3769. 1:59:33and
  3770. 1:59:33i'm um if i'm writing scripts that are
  3771. 1:59:36using the commands it just loads what it
  3772. 1:59:37needs
  3773. 1:59:38and i don't have to worry about it it's
  3774. 1:59:40a beautiful world
  3775. 1:59:41it's a beautiful world it's a beaut you
  3776. 1:59:43got any more on modules because that's
  3777. 1:59:45about all i got on modules
  3778. 1:59:46well you can do but would we get to this
  3779. 1:59:49now
  3780. 1:59:50what do what do you want to do modules
  3781. 1:59:51on other machines implicit remote
  3782. 1:59:53no oh no we'll do implicit oh boy we're
  3783. 1:59:55going to talk about the
  3784. 1:59:56we'll get to that later yeah it's so
  3785. 1:59:58cool it's so cool it's so cool so let me
  3786. 2:00:00show you the slides guys we've got all
  3787. 2:00:01this
  3788. 2:00:02so that's an after lunch thing they'll
  3789. 2:00:03need like high energy
  3790. 2:00:05and let me just warn you right now
  3791. 2:00:06because we're only about 30 minutes or
  3792. 2:00:08so away from
  3793. 2:00:09taking a meal break meal break that's
  3794. 2:00:11the international term for lunch
  3795. 2:00:13yeah meal because we're we're taking
  3796. 2:00:15lunch um is is that don't
  3797. 2:00:17don't eat a lot because you don't want
  3798. 2:00:19to fall asleep yeah
  3799. 2:00:20after lunch absolutely it's have some
  3800. 2:00:23coffee so we've got everything in the
  3801. 2:00:24slides and powershell three dynamically
  3802. 2:00:26uh
  3803. 2:00:27loads the modules for you and you can
  3804. 2:00:29you can discover all of your commands
  3805. 2:00:31thank god for v3 makes this
  3806. 2:00:33much easier and so uh you can work with
  3807. 2:00:36your commands
  3808. 2:00:37and off you go
  3809. 2:00:41[Music]
  3810. 2:00:55[Music]
  3811. 2:01:04now's when the fun starts to begin
  3812. 2:01:07before lunch i'm sorry to do this to you
  3813. 2:01:09no this is good yeah this is great i
  3814. 2:01:10know this is they can handle this this
  3815. 2:01:12is great all right
  3816. 2:01:14we're gonna we gotta talk about objects
  3817. 2:01:16we're gonna talk about objects
  3818. 2:01:17and what objects are and i'm gonna let
  3819. 2:01:20jeffrey talk as much about objects as he
  3820. 2:01:21wants to talk about
  3821. 2:01:22yeah so let me just show you something
  3822. 2:01:24here so so
  3823. 2:01:25so we've been lying to you
  3824. 2:01:31i'm leaving so here we've been saying
  3825. 2:01:35get
  3826. 2:01:35service services
  3827. 2:01:39star okay and and what do you see right
  3828. 2:01:42and what you see
  3829. 2:01:43is text okay but that's not what's
  3830. 2:01:46really going on
  3831. 2:01:47what's really going on is when i do get
  3832. 2:01:49service notice i didn't say get
  3833. 2:01:51service text i just said get service so
  3834. 2:01:53what i'm actually getting is
  3835. 2:01:55i'm getting service objects or service
  3836. 2:01:57controller objects okay
  3837. 2:01:58and and the point of that now don't
  3838. 2:02:00freak out when you hear the word object
  3839. 2:02:02right some people hear the word object
  3840. 2:02:03and they're like oh my
  3841. 2:02:04god you're like i'm not a developer i'm
  3842. 2:02:06not a developer no
  3843. 2:02:07no my friends no no no objects
  3844. 2:02:09dramatically
  3845. 2:02:10simplify your life okay uh now what is
  3846. 2:02:13an
  3847. 2:02:14object okay let's just try to deal with
  3848. 2:02:16that right simple because i'm over here
  3849. 2:02:17freaking out going no no no no no
  3850. 2:02:20but they're going to simplify my life
  3851. 2:02:21okay i'm good so uh one of the
  3852. 2:02:23uh i think it was an mvp or someone at
  3853. 2:02:25tech ed did a great explanation of
  3854. 2:02:27objects they said
  3855. 2:02:27look an object is just a thing right
  3856. 2:02:30it's a noun
  3857. 2:02:31that has properties and methods so think
  3858. 2:02:33about a bicycle
  3859. 2:02:34right a bicycle is an object and it has
  3860. 2:02:38properties it has handlebars it has
  3861. 2:02:42pedals it has wheels
  3862. 2:02:43okay and then there are things you can
  3863. 2:02:45do to it so
  3864. 2:02:47an object has things it has we call
  3865. 2:02:50those
  3866. 2:02:50properties it has a handlebar it has a
  3867. 2:02:52wheel it has a
  3868. 2:02:54um a frame and there are things it can
  3869. 2:02:56do
  3870. 2:02:57you can pedal you can steer and we call
  3871. 2:02:59those things
  3872. 2:03:00methods so objects are merely
  3873. 2:03:03things that have properties and things
  3874. 2:03:06you can do things too
  3875. 2:03:07okay i like that so far i like that i
  3876. 2:03:09like that
  3877. 2:03:10so here we show this thing and what
  3878. 2:03:12actually happens is i
  3879. 2:03:14got a set of objects now the trick is
  3880. 2:03:16and here's the magic
  3881. 2:03:17is that we spew these objects out and we
  3882. 2:03:20can then
  3883. 2:03:21work on them and when they finally get
  3884. 2:03:23to the display the display says oh i got
  3885. 2:03:26an object
  3886. 2:03:26what the hell am i going to do with that
  3887. 2:03:28like there's no way i'm going to
  3888. 2:03:30burp out this like binary stuff and
  3889. 2:03:32people are going to figure it out
  3890. 2:03:33so what the display does it says oh well
  3891. 2:03:36now
  3892. 2:03:36now i'll convert it to an object or
  3893. 2:03:39convert it to text
  3894. 2:03:41and the whole point about that is you
  3895. 2:03:42want to delay the conversion of text
  3896. 2:03:45as far as possible as long as possible
  3897. 2:03:47because once you have text
  3898. 2:03:49it's really hard to operate with now you
  3899. 2:03:52unix guys anybody with a unix background
  3900. 2:03:54you know what i'm talking about right
  3901. 2:03:56because imagine now let's go back to get
  3902. 2:03:57process i like get process so
  3903. 2:03:59get process star ss okay
  3904. 2:04:02now imagine you want to get all those
  3905. 2:04:05things where
  3906. 2:04:06the handles were greater than let's say
  3907. 2:04:09700 let's do this
  3908. 2:04:10get process okay so you see there's a
  3909. 2:04:13bunch of these things and some of them
  3910. 2:04:15are high so say you want to get all
  3911. 2:04:16those that were greater than a thousand
  3912. 2:04:18how would you do it
  3913. 2:04:19well in unix if this is text gets taxed
  3914. 2:04:23how do you do that well let's see you
  3915. 2:04:24got to cut off one
  3916. 2:04:26two three lines and then you got to go
  3917. 2:04:29and you say well i'm going to cut off
  3918. 2:04:30from zero to
  3919. 2:04:31let's see that's one two
  3920. 2:04:34three four five six
  3921. 2:04:38seven seven k i gotta cut off these
  3922. 2:04:40first seven characters
  3923. 2:04:41and then what do you get and the answer
  3924. 2:04:43is a string and so how do you do a
  3925. 2:04:45string comparison that's greater than a
  3926. 2:04:47thousand
  3927. 2:04:48well you could thousands actually easy
  3928. 2:04:49you could say well if the string
  3929. 2:04:51truncate all the spaces and then if the
  3930. 2:04:54length is greater than
  3931. 2:04:55three right then it's greater than a
  3932. 2:04:57thousand but if you wanted to do it
  3933. 2:04:59greater than 900
  3934. 2:05:00well then you got a sum okay so you get
  3935. 2:05:02where i'm going you unix guys
  3936. 2:05:04you know hats off to you i don't know
  3937. 2:05:05how the heck you've been coping all
  3938. 2:05:07these years
  3939. 2:05:08i mean it really is we call this
  3940. 2:05:09prayer-based parsing right
  3941. 2:05:12please work exactly and oddly you know
  3942. 2:05:15it sort of worked fine but in our world
  3943. 2:05:17you don't have to do that in our world
  3944. 2:05:19you have these objects okay now the
  3945. 2:05:22thing is
  3946. 2:05:22when i do get process i'm displaying an
  3947. 2:05:25object
  3948. 2:05:26each row is the object itself
  3949. 2:05:29and each one of these displays here each
  3950. 2:05:33one of the columns
  3951. 2:05:35reflects the properties okay
  3952. 2:05:38so what did i tell you i told you we're
  3953. 2:05:41trying to create a world
  3954. 2:05:42where you think about what you want you
  3955. 2:05:45type it
  3956. 2:05:45and you get it and the way that works is
  3957. 2:05:48because of objects
  3958. 2:05:49okay so what did i say i said i wanted
  3959. 2:05:52to get
  3960. 2:05:53the processes i wanted to get those
  3961. 2:05:56where the handle count was greater than
  3962. 2:05:595 or 900 or yeah some number so you pick
  3963. 2:06:02you pick your favorite number okay
  3964. 2:06:03so i want to say where the handles okay
  3965. 2:06:06remember where did i get handles
  3966. 2:06:09right there handles okay so where
  3967. 2:06:12handles
  3968. 2:06:15r greater than greater than equal
  3969. 2:06:17greater than
  3970. 2:06:18uh 900. and voila
  3971. 2:06:22it worked why did it work because of
  3972. 2:06:24objects
  3973. 2:06:25objects objects are so cool now wait not
  3974. 2:06:27like so this is still a little bit messy
  3975. 2:06:29here right
  3976. 2:06:30because these handles i mean look at
  3977. 2:06:32them they're all kind of like
  3978. 2:06:33all over the place right so really what
  3979. 2:06:35i want to do is i want to sort them by
  3980. 2:06:37now how are they going again you cut off
  3981. 2:06:40three lines and you do this and again
  3982. 2:06:42it's strings
  3983. 2:06:42so so but no no it's an object
  3984. 2:06:46so what you could do is again think
  3985. 2:06:48about what you want
  3986. 2:06:49type it and you get it you would say
  3987. 2:06:51well i want to sort it by handles
  3988. 2:06:56and then you get it okay which is
  3989. 2:06:59this if you're starting to get the
  3990. 2:07:01concept here this is
  3991. 2:07:02starting to become totally awesome look
  3992. 2:07:04at the difference of working with
  3993. 2:07:05objects
  3994. 2:07:06one thing that you can do to start off
  3995. 2:07:09is to show that
  3996. 2:07:10that these are objects is i'm just going
  3997. 2:07:12to grab a service real quick
  3998. 2:07:15and if you want to take a look at what
  3999. 2:07:18properties and notice when i run
  4000. 2:07:19just get service name bits notice that
  4001. 2:07:22there
  4002. 2:07:22are three what appear to be properties
  4003. 2:07:25displayed about this server but you know
  4004. 2:07:27what
  4005. 2:07:27i i'm pretty sure there's more
  4006. 2:07:30properties than just these three on a
  4007. 2:07:32service
  4008. 2:07:32and you know i'm not seeing any methods
  4009. 2:07:34here um but jeffrey just said that
  4010. 2:07:37objects have properties
  4011. 2:07:38and and they have methods well there's a
  4012. 2:07:41way
  4013. 2:07:42to show you everything that an object
  4014. 2:07:44has and it's going to become a crucial
  4015. 2:07:46part to working with powershell
  4016. 2:07:48so how do you find out what properties
  4017. 2:07:51and methods an object has
  4018. 2:07:53you pipe it to a very special command
  4019. 2:07:55and i'm going to
  4020. 2:07:57get member now i got to be honest with
  4021. 2:07:59you get member
  4022. 2:08:01we usually use the alias for this so i'm
  4023. 2:08:04just going to use the alias
  4024. 2:08:05pipe gm and you'll just hear me say pipe
  4025. 2:08:08gm
  4026. 2:08:08when you pipe something to get member it
  4027. 2:08:10takes the object and it
  4028. 2:08:11shows you all the meth so think of it
  4029. 2:08:15this way it's kind of like if i were to
  4030. 2:08:16walk in front of a mirror the mirror
  4031. 2:08:18shows me things like well you're six
  4032. 2:08:19foot two you're blonde you've got blue
  4033. 2:08:21eyes you're built
  4034. 2:08:22really well and you and you have methods
  4035. 2:08:25you have methods like you
  4036. 2:08:26you surf and you like karate what do you
  4037. 2:08:28think of my mirror
  4038. 2:08:29that's awesome i need one of those yeah
  4039. 2:08:32obviously my mirror does not work well
  4040. 2:08:34but
  4041. 2:08:35the powershell mirror being get member
  4042. 2:08:37works
  4043. 2:08:38very well so let me just show you if you
  4044. 2:08:40take a look here there's
  4045. 2:08:41a couple of pieces of information you're
  4046. 2:08:43going to want to pull out from get
  4047. 2:08:44member first of all
  4048. 2:08:45what kind of object it is this is going
  4049. 2:08:47to become very important to us
  4050. 2:08:48after lunch what kind of object is
  4051. 2:08:51your screen over a little bit it's
  4052. 2:08:53getting truncated a little bit oh yeah
  4053. 2:08:54let me get this
  4054. 2:08:56does that look better here we go so
  4055. 2:09:00system dot uh service process what you
  4056. 2:09:02really are interested in right now is
  4057. 2:09:03this period and what comes after its
  4058. 2:09:05service controller that's what kind of
  4059. 2:09:07object is being sent across that
  4060. 2:09:08pipeline
  4061. 2:09:09and then look at this list anything with
  4062. 2:09:11the word property in it i don't care if
  4063. 2:09:13it has some other word in front of it or
  4064. 2:09:15something anything with a property
  4065. 2:09:17is a property that you can use and look
  4066. 2:09:20at specifically
  4067. 2:09:21like jeffrey was doing handles on get
  4068. 2:09:23process i'm you know look at all these
  4069. 2:09:25properties down through here
  4070. 2:09:27we're going to start off working quite a
  4071. 2:09:28bit with properties but you also have
  4072. 2:09:30methods methods like oh look start
  4073. 2:09:34and stop getservice has a method to
  4074. 2:09:37start and stop a service we don't
  4075. 2:09:39need a commandlet necessarily because we
  4076. 2:09:41have a method
  4077. 2:09:42that we could use and we'll show you how
  4078. 2:09:43to do that too so get member is your
  4079. 2:09:46friend to show you the truth or what an
  4080. 2:09:48object actually contains
  4081. 2:09:50for its properties and its methods let
  4082. 2:09:52me give you an example using kind of off
  4083. 2:09:54of
  4084. 2:09:54jeffrey's example i'm going to do get
  4085. 2:09:56service
  4086. 2:09:57and here's what i want to do i want to
  4087. 2:10:00just select a couple of properties
  4088. 2:10:04the properties that i want to see right
  4089. 2:10:05now are name and status
  4090. 2:10:08we have a commandlet called select
  4091. 2:10:10object
  4092. 2:10:11now you usually see this as its alias of
  4093. 2:10:15select let me just show you it has a
  4094. 2:10:17parameter called property and you can
  4095. 2:10:19tell me
  4096. 2:10:20what properties you now want to see well
  4097. 2:10:23if i've gone to get member and i've
  4098. 2:10:24looked at the list of properties and
  4099. 2:10:26i've chosen the ones that i wanted i
  4100. 2:10:27just type them in i just want name
  4101. 2:10:30status so i've selected those particular
  4102. 2:10:33properties
  4103. 2:10:34now i also want you to notice and
  4104. 2:10:37jeffrey just did an example of this
  4105. 2:10:39i'm going to get child item or the alias
  4106. 2:10:41der is a great example
  4107. 2:10:42here's a list of files out of the out of
  4108. 2:10:45my c drive
  4109. 2:10:46files and folders right now look at how
  4110. 2:10:49it's sorting them
  4111. 2:10:50sorting them by name and it's sorting
  4112. 2:10:52them well looks to be alphabetically to
  4113. 2:10:54me
  4114. 2:10:54well i want to change the sort i'd like
  4115. 2:10:56to sort them by length
  4116. 2:10:58and the only thing i want displayed is
  4117. 2:11:00name and length so here's what i'm going
  4118. 2:11:02to do
  4119. 2:11:03i'm going to do get child item
  4120. 2:11:08i'm going to uh select
  4121. 2:11:11that the properties i want to see are
  4122. 2:11:13name and
  4123. 2:11:14length and this is right off of the
  4124. 2:11:16example that jeffrey was doing
  4125. 2:11:17i want to sort that by the property
  4126. 2:11:22length
  4127. 2:11:24this pipeline and the fact that objects
  4128. 2:11:27are crossing the pipeline and i can work
  4129. 2:11:28with
  4130. 2:11:29these properties and methods making my
  4131. 2:11:31life a lot easier look at that it's it's
  4132. 2:11:33folders first and then it's the files
  4133. 2:11:34but you know what notice
  4134. 2:11:35on my files it's small z's to big z's i
  4135. 2:11:39want it big z's to smallzies in other
  4136. 2:11:41words i want it descending
  4137. 2:11:43so let me hit my up arrow key and the
  4138. 2:11:46sort object
  4139. 2:11:47has a descending so now i can change the
  4140. 2:11:49sort order
  4141. 2:11:50and make it descending is that kind of
  4142. 2:11:52cool that's good that's that's kind of
  4143. 2:11:53cool that's kind of cool
  4144. 2:11:54that's kind of cool that's you know
  4145. 2:11:57working with the object so
  4146. 2:11:59working with objects is all about using
  4147. 2:12:02get member and we've shown you that you
  4148. 2:12:04can do sort
  4149. 2:12:06and you can do a select and we're going
  4150. 2:12:08to do these quite a bit of selecting and
  4151. 2:12:10sorting
  4152. 2:12:11but there's some other examples let's
  4153. 2:12:12see here
  4154. 2:12:14keep in mind get process
  4155. 2:12:17when you need to know more about an
  4156. 2:12:19object this is very important when you
  4157. 2:12:20need to know more about an object
  4158. 2:12:22because this afternoon we're going to
  4159. 2:12:23need to know more about an object
  4160. 2:12:24you pipe to gm which is get member
  4161. 2:12:28you'll get
  4162. 2:12:31the type of object it is which we're
  4163. 2:12:32going to need this later and you get
  4164. 2:12:35all of its properties and its methods
  4165. 2:12:36and it if it has the word property in it
  4166. 2:12:39you can use it with sword and select
  4167. 2:12:41like we just showed you
  4168. 2:12:42that you could use it with in fact it's
  4169. 2:12:45it's kind of interesting there's all
  4170. 2:12:46kinds of stuff you can do
  4171. 2:12:48so back to an earlier example get event
  4172. 2:12:50log
  4173. 2:12:53log name system and we're going to do
  4174. 2:12:55newest
  4175. 2:12:57let's just do new toolboost 5 and i want
  4176. 2:13:00to
  4177. 2:13:01if i just run this you can see i'm
  4178. 2:13:02getting all this information across here
  4179. 2:13:04i'd like to take a look at the object
  4180. 2:13:06itself so what i'm going to do
  4181. 2:13:08is because i want to see what all the
  4182. 2:13:10properties are
  4183. 2:13:11i'm going to pipe it to gm wow there's a
  4184. 2:13:13lot more properties out here
  4185. 2:13:15than i was seeing in the original
  4186. 2:13:17display time generated time written so
  4187. 2:13:20you know what i think i'd like i think
  4188. 2:13:21i'd like
  4189. 2:13:22um event id and time generated
  4190. 2:13:26and i think i would like oh
  4191. 2:13:29what else would be a good property maybe
  4192. 2:13:31um
  4193. 2:13:33a message that would be perfect that
  4194. 2:13:35would be perfect
  4195. 2:13:36so i'm going to up arrow
  4196. 2:13:40select the property event
  4197. 2:13:44id yup comma
  4198. 2:13:47and if you take a look at the help file
  4199. 2:13:48you'll see that dash property takes
  4200. 2:13:50multiple values so
  4201. 2:13:52i can do time generated or time written
  4202. 2:13:54let's do time written i think i can type
  4203. 2:13:56that one
  4204. 2:13:57you can hit tab version three
  4205. 2:14:00version three version three
  4206. 2:14:03see i just hit tab and it made my life
  4207. 2:14:05much easier in typing
  4208. 2:14:06so now i've selected those there we go
  4209. 2:14:09and now i'd actually like to sort them
  4210. 2:14:11on the on the time written
  4211. 2:14:13now guys this is a vm so there's not a
  4212. 2:14:16whole lot of stuff out here but you get
  4213. 2:14:18the idea i'm going to sort
  4214. 2:14:20on the property of okay now i'm not
  4215. 2:14:22getting my tab
  4216. 2:14:23time written and voila
  4217. 2:14:27and if i want to sort it descending i
  4218. 2:14:28can sort it descending but now
  4219. 2:14:31that i'm understanding the pipeline i
  4220. 2:14:33know how to find
  4221. 2:14:34the properties that i want not just the
  4222. 2:14:36ones that i saw on the display but
  4223. 2:14:38i can find all of the properties and
  4224. 2:14:40then just select the ones i want and
  4225. 2:14:42sort the ones i want
  4226. 2:14:44now that i have what i want well i don't
  4227. 2:14:46want it on the screen
  4228. 2:14:48i want it converted to an html file and
  4229. 2:14:54i just love this sql
  4230. 2:14:58errors dot htm and actually this will
  4231. 2:15:01take a unc
  4232. 2:15:02out file will take a unc so you just
  4233. 2:15:04throw it to a web server
  4234. 2:15:06dimension as a web guy that's uh anyways
  4235. 2:15:08uh and so here's the deal
  4236. 2:15:10so i've got this this this great
  4237. 2:15:13one-liner right now
  4238. 2:15:14that's grabbing the errors and right now
  4239. 2:15:16it's from the local machine but i can
  4240. 2:15:18throw a dash computer we get it from
  4241. 2:15:19multiple machines
  4242. 2:15:20it's selecting out just the information
  4243. 2:15:22i want it's sorting it the way that i
  4244. 2:15:23want it's stuffing it into a web file
  4245. 2:15:26i can now tell the other admins hey when
  4246. 2:15:28you get up in the morning
  4247. 2:15:29go check the web page and if there's any
  4248. 2:15:31errors in there
  4249. 2:15:33start trying to fix them because as
  4250. 2:15:35you're going to see later
  4251. 2:15:36we're going to automate this and
  4252. 2:15:38schedule this
  4253. 2:15:39and make this go for us so i don't have
  4254. 2:15:41to type it again so once i figured it
  4255. 2:15:43out
  4256. 2:15:43but you can see it's like figuring out a
  4257. 2:15:45puzzle and just to show you that it
  4258. 2:15:46actually worked
  4259. 2:15:47what did i call it error hdm
  4260. 2:15:53there's a woohoo even from the guys in
  4261. 2:15:55the back so you must
  4262. 2:15:56it's all good you must be a little
  4263. 2:15:58impressed with that what else should we
  4264. 2:16:00show them with
  4265. 2:16:00subjects right now okay so here's the
  4266. 2:16:02thing about objects i mentioned to you
  4267. 2:16:03that
  4268. 2:16:04objects dramatically simplify your life
  4269. 2:16:06it's true
  4270. 2:16:07okay so here's the thing what we've been
  4271. 2:16:09showing you
  4272. 2:16:10are net objects now these.net objects
  4273. 2:16:12are actually
  4274. 2:16:13very well behaved objects but you know
  4275. 2:16:15the world
  4276. 2:16:16the world is a messy place and not
  4277. 2:16:18everybody has your best interests in
  4278. 2:16:20mind
  4279. 2:16:21and so in particular there's a lot of
  4280. 2:16:23people who use net in a way
  4281. 2:16:25that is good for them but not good for
  4282. 2:16:27you
  4283. 2:16:28okay and in particular what they do is
  4284. 2:16:29they hide things
  4285. 2:16:31and this is ubiquitous right this
  4286. 2:16:32happens in wmi it happens in adsi
  4287. 2:16:35active directory happens in xml etc
  4288. 2:16:38now powershell we got exactly one
  4289. 2:16:41customer that's
  4290. 2:16:41you okay so i am focused in on making
  4291. 2:16:44your life
  4292. 2:16:45great okay and so what we do is we go
  4293. 2:16:47and we say
  4294. 2:16:48these guys didn't help you we'll help
  4295. 2:16:50you right we will take their stuff
  4296. 2:16:52and we'll adapt it for your needs now
  4297. 2:16:55let me just give you an example of this
  4298. 2:16:56okay
  4299. 2:16:57so here i have i've got this xml file
  4300. 2:17:01okay so r d dot j so let's see if i can
  4301. 2:17:05actually bring that up
  4302. 2:17:07so can i do this open can do an open
  4303. 2:17:11powershell.org yeah we'll talk about
  4304. 2:17:13that that's cool we are but
  4305. 2:17:14let's see can i do an open okay yeah so
  4306. 2:17:16i want to say c
  4307. 2:17:18uh jumpstart
  4308. 2:17:21slash r and here's my xml
  4309. 2:17:25and it is the tragedy of romeo and
  4310. 2:17:29juliet
  4311. 2:17:30oh it's beautiful and look here so you
  4312. 2:17:32got personas
  4313. 2:17:34you got you got ax and in the acts
  4314. 2:17:37you've got
  4315. 2:17:38speeches and you got oops sorry and you
  4316. 2:17:40got and you got speakers and you got
  4317. 2:17:42lines okay now by the way this next
  4318. 2:17:44thing i'm going to show you
  4319. 2:17:45i'm going to show you the way to do it
  4320. 2:17:47in powershell version
  4321. 2:17:493. okay in powershell version 2 you can
  4322. 2:17:51do it but it's
  4323. 2:17:52harder and and the stuff i'm going to
  4324. 2:17:54show you requires version three
  4325. 2:17:56okay so we have this thing we'll call it
  4326. 2:17:58dollar sign it's also an
  4327. 2:18:00x um and what we're going to do is we're
  4328. 2:18:03going to
  4329. 2:18:04cap that file a cat is the same as get
  4330. 2:18:06content but
  4331. 2:18:07remember i said i'm an old linux guy old
  4332. 2:18:10unix guy
  4333. 2:18:10so i'm going to say cat r d and what i'm
  4334. 2:18:13going to do here
  4335. 2:18:15is i'm going to cast it something called
  4336. 2:18:17casting it
  4337. 2:18:18as xml so i'm going to copy this file
  4338. 2:18:21and i'm going to cast it as xml and now
  4339. 2:18:24i have this
  4340. 2:18:25object dollar sign x which contains
  4341. 2:18:29the xml okay now this is really xml
  4342. 2:18:32right so
  4343. 2:18:32if i did the way you can tell that is
  4344. 2:18:35you can type get type
  4345. 2:18:37and you can see it's an xml document
  4346. 2:18:39okay so this is xml
  4347. 2:18:41now have you ever worked with xml not in
  4348. 2:18:44its raw form
  4349. 2:18:46it's hideous it is like kicking a dead
  4350. 2:18:49whale along the beach you know
  4351. 2:18:50all sorts of effort and it seems little
  4352. 2:18:53result
  4353. 2:18:54nothing ever ever happens it's just
  4354. 2:18:55hideous but not in powershell right so
  4355. 2:18:57in powershell
  4356. 2:18:58again i map this hideous world to your
  4357. 2:19:00world right so remember what does this
  4358. 2:19:02thing look like
  4359. 2:19:05blah like right okay well here when i
  4360. 2:19:07said oh i see dallas on x dot play
  4361. 2:19:10dot play okay oh look at that
  4362. 2:19:14so then here are the the x
  4363. 2:19:18oh look at that and so i could say well
  4364. 2:19:20hey give me act 0
  4365. 2:19:22and give me the scene and hear all the
  4366. 2:19:26scenes
  4367. 2:19:27and then i can say hey scene 0
  4368. 2:19:30give me the speech and there are all the
  4369. 2:19:34speeches
  4370. 2:19:35okay okay look at that is that cool or
  4371. 2:19:38what now wait wait wait it gets better
  4372. 2:19:39here if i get rid of this index so
  4373. 2:19:42remember
  4374. 2:19:43it gave me a set of of things and i
  4375. 2:19:46selected the first one
  4376. 2:19:47so now what i'm gonna do and because
  4377. 2:19:48powershell version three
  4378. 2:19:50i can go and i say hey i want all the
  4379. 2:19:52scenes and i want
  4380. 2:19:53all the acts and it gives you to them
  4381. 2:19:57all
  4382. 2:19:58okay now if you remember let's let me
  4383. 2:19:59just do something to select
  4384. 2:20:01first one okay so
  4385. 2:20:04now what i can do is i can say hey i
  4386. 2:20:06would like to group them
  4387. 2:20:08by the speaker and i would like to sort
  4388. 2:20:11them
  4389. 2:20:12by count and if you're gonna
  4390. 2:20:15if you're in theater you definitely want
  4391. 2:20:17to be romeo
  4392. 2:20:19right right that's not the third
  4393. 2:20:20musician because the third musician has
  4394. 2:20:22exactly one speech
  4395. 2:20:24whereas romeo has 163. now let's just
  4396. 2:20:28think about this a second
  4397. 2:20:30let's just think about this a second so
  4398. 2:20:32here i have this xml and the point is
  4399. 2:20:34that there's a bunch of xml in the world
  4400. 2:20:36right
  4401. 2:20:36like you didn't ask for it but somebody
  4402. 2:20:38decided hey i'm going to give you some
  4403. 2:20:40xml
  4404. 2:20:41thank you thank you so much but and so
  4405. 2:20:44it's like
  4406. 2:20:44uh like what what what what what this
  4407. 2:20:47hideous horrible world and again if
  4408. 2:20:49you've ever dealt with xml you know
  4409. 2:20:51exactly what i'm
  4410. 2:20:52talking about but what we do is we're
  4411. 2:20:54able to
  4412. 2:20:55by the way by the way if i wanted to get
  4413. 2:20:57the history of things that i
  4414. 2:20:59typed you would type get
  4415. 2:21:02history okay
  4416. 2:21:05and so here are the things that i typed
  4417. 2:21:07so what i did
  4418. 2:21:09was i
  4419. 2:21:12[Music]
  4420. 2:21:14okay so first was i got the content of
  4421. 2:21:17that file
  4422. 2:21:17and i cast it to xml here somewhere
  4423. 2:21:21somewhere somewhere here
  4424. 2:21:24right and then i showed you that it was
  4425. 2:21:27an xml document
  4426. 2:21:28here and then you're able to ask for the
  4427. 2:21:30play
  4428. 2:21:31we were able to see that it had an act i
  4429. 2:21:33drilled into act
  4430. 2:21:34one i saw that it had scenes i drilled
  4431. 2:21:37into scene one
  4432. 2:21:38and saw that it had speeches and i got
  4433. 2:21:40that speech and then
  4434. 2:21:41i removed all those and i got all the
  4435. 2:21:43speeches
  4436. 2:21:45and then i selected the first one to
  4437. 2:21:48find out what the properties of that
  4438. 2:21:49speech were
  4439. 2:21:50i saw that it had a speaker and so i
  4440. 2:21:53grouped it by speaker and sorted it by
  4441. 2:21:54count
  4442. 2:21:55and it's that simple and what's really
  4443. 2:21:58amazing about this is is notice that
  4444. 2:22:00we're utilizing the pipeline
  4445. 2:22:02and we're building these results as we
  4446. 2:22:04move along we're utilizing the objects
  4447. 2:22:06because it's an
  4448. 2:22:06object-based pipeline and so even
  4449. 2:22:10you know what he's right if you're in
  4450. 2:22:11version two we didn't use the pipeline
  4451. 2:22:13but that is actually the point
  4452. 2:22:14in version two you would have had to use
  4453. 2:22:16the pipeline back from
  4454. 2:22:18from this when we did this right
  4455. 2:22:21to get everything what you would have
  4456. 2:22:23had to have done was something like
  4457. 2:22:25because we fixed it right you would have
  4458. 2:22:27done something like
  4459. 2:22:28let's see i think it was this you would
  4460. 2:22:30have to say
  4461. 2:22:32through select minus expand
  4462. 2:22:39scene no
  4463. 2:22:42i think i even got that wrong through
  4464. 2:22:44select minus expand
  4465. 2:22:47speech and i did get this wrong anyway
  4466. 2:22:49so a bunch of pipelines very very
  4467. 2:22:51powerful stuff and in version three
  4468. 2:22:53we simplified it with the dot syntax and
  4469. 2:22:56the dot syntax you're going to see quite
  4470. 2:22:57a bit today as we start utilizing it but
  4471. 2:22:59combining that along with the pipeline
  4472. 2:23:02really makes it very powerful now a
  4473. 2:23:04couple of other things that jeffrey was
  4474. 2:23:05showing you that i want to highlight and
  4475. 2:23:07we're going to need this information for
  4476. 2:23:09this afternoon
  4477. 2:23:10so along with working with objects
  4478. 2:23:12jeffrey also showed
  4479. 2:23:13you showed you a filter so let me give
  4480. 2:23:16you an example get
  4481. 2:23:17service we have a commandlet called
  4482. 2:23:20where
  4483. 2:23:20object now where object is a way for you
  4484. 2:23:23to filter out only the data that you
  4485. 2:23:25want to see
  4486. 2:23:26usually you'll see it abbreviated down
  4487. 2:23:28to where it's
  4488. 2:23:29that's using the alias that way now
  4489. 2:23:32there is a parameter called
  4490. 2:23:34filter script that has a couple of
  4491. 2:23:37squigglies
  4492. 2:23:39squigglies whatever happens in the
  4493. 2:23:42squigglies
  4494. 2:23:43is your filter now i'm going to show you
  4495. 2:23:44a couple of ways to write a filter
  4496. 2:23:46because this is what you're going to see
  4497. 2:23:47on the internet
  4498. 2:23:48first of all almost nobody uses the
  4499. 2:23:51parameter name
  4500. 2:23:52filter script so it's the squigglies i
  4501. 2:23:55want you to see something
  4502. 2:23:56this is a special symbol now we're going
  4503. 2:23:58to talk about variables later but the
  4504. 2:23:59dollar
  4505. 2:24:00sign is a special indicator for you and
  4506. 2:24:02in this case
  4507. 2:24:03dollar sign underscore means
  4508. 2:24:06the current object crossing the pipeline
  4509. 2:24:09now
  4510. 2:24:10notice i've got get service that's got a
  4511. 2:24:12whole bunch of objects we're going to
  4512. 2:24:13send
  4513. 2:24:14one at a time across the pipeline i want
  4514. 2:24:16to grab hold of that for a second
  4515. 2:24:17because i want to do something to it
  4516. 2:24:20it's stored in dollar sign underscore
  4517. 2:24:22now in v3 there's another way that we
  4518. 2:24:26can show you to do this but hang on a
  4519. 2:24:27sec let me show you
  4520. 2:24:28i want to look at the property
  4521. 2:24:32status and if it's equal to
  4522. 2:24:36running as a filter i want you to think
  4523. 2:24:38about this
  4524. 2:24:39this is going to filter out only the
  4525. 2:24:41things that equal to running now i know
  4526. 2:24:44you might be saying
  4527. 2:24:45what the devil is this eq over here why
  4528. 2:24:47isn't it
  4529. 2:24:48why isn't it equals why isn't it equals
  4530. 2:24:52yeah so here's the thing bruce payette
  4531. 2:24:53superstar rockstar wrote this great book
  4532. 2:24:55powershell in action
  4533. 2:24:56where he goes and describes all the
  4534. 2:24:58reasons why we made the language choices
  4535. 2:25:01so if you ever get to the point where
  4536. 2:25:02you're asking deep questions like this
  4537. 2:25:05bruce's book powershell in action is the
  4538. 2:25:07book to answer it
  4539. 2:25:08here's the thing we struggled with this
  4540. 2:25:10one over and over and over again
  4541. 2:25:11honestly
  4542. 2:25:12as as we started and designed the
  4543. 2:25:14language in the system
  4544. 2:25:15we struggled with saying hey we want to
  4545. 2:25:17be interactive
  4546. 2:25:19and programmatic see in in linux where
  4547. 2:25:21we had all
  4548. 2:25:22unix where we had come from you have
  4549. 2:25:24these big separations right
  4550. 2:25:26you start off with one tool and then
  4551. 2:25:29that tool fails you and so you got to
  4552. 2:25:30throw everything away and you got to
  4553. 2:25:32pick up another tool right
  4554. 2:25:33try and write it in the shell script
  4555. 2:25:34it's not powerful enough so you throw
  4556. 2:25:36that away and start writing in
  4557. 2:25:37awk and grep and said that's not
  4558. 2:25:39powerful enough so you throw that away
  4559. 2:25:41and then you use it in pearl
  4560. 2:25:42and that's powerful enough but it's too
  4561. 2:25:44slow so then you throw it away and you
  4562. 2:25:46pick up
  4563. 2:25:47and write it in c right so that's my
  4564. 2:25:49joke right unix is a
  4565. 2:25:51sequence of failed tools what we wanted
  4566. 2:25:53to do is to have one tool
  4567. 2:25:55that would work whether you wanted to do
  4568. 2:25:57it interactively
  4569. 2:25:59or you want to do this rich systems
  4570. 2:26:01programming level
  4571. 2:26:02and it turns out that's hard never been
  4572. 2:26:04done before never been done before
  4573. 2:26:07and we did it and honestly we just
  4574. 2:26:09struggled with this
  4575. 2:26:10hey turns out there's a reason why
  4576. 2:26:12interactive shells have an interac have
  4577. 2:26:14a syntax the way they do
  4578. 2:26:15there's a reason why programming
  4579. 2:26:17languages have the language
  4580. 2:26:19the syntax that they do and so we
  4581. 2:26:21struggled with this
  4582. 2:26:22and uh and so we were able to finally
  4583. 2:26:24get this nice match between those two
  4584. 2:26:27and part of the ramification of that was
  4585. 2:26:29or part one of the ramifications of that
  4586. 2:26:31was
  4587. 2:26:32that we needed to use uh well by the way
  4588. 2:26:34when we chose a programming language
  4589. 2:26:35we chose the c style so there's c c
  4590. 2:26:39plus plus c sharp so we chose that style
  4591. 2:26:42of things
  4592. 2:26:42that's why you have squiggle brackets
  4593. 2:26:44versus begin and end or
  4594. 2:26:46do and done or do and od
  4595. 2:26:49always confuse me yeah exactly i like
  4596. 2:26:50the terse kind of language exactly
  4597. 2:26:52um and programmers do too and by going
  4598. 2:26:54guess who's going to write most of your
  4599. 2:26:56commandlets it's the programmers so you
  4600. 2:26:58want a world that's friendly to them
  4601. 2:27:00so um so that's what we did and it
  4602. 2:27:02turned out that uh
  4603. 2:27:03from the grammar from the parser uh if
  4604. 2:27:06you had equals there uh it got ambiguous
  4605. 2:27:08and we tried and tried to try it and you
  4606. 2:27:10couldn't resolve that one thing
  4607. 2:27:12and so that's why we have dash eq and
  4608. 2:27:14let me show you guys
  4609. 2:27:16it so let me i'll show this to you a
  4610. 2:27:18couple of ways dash eq means equals
  4611. 2:27:21and so as you can see i'm just getting
  4612. 2:27:22the services that are
  4613. 2:27:24i filtered out the ones that are stopped
  4614. 2:27:26just the ones that are equal
  4615. 2:27:27but here's the important thing you know
  4616. 2:27:30these are redirect characters
  4617. 2:27:32like file redirect at a in a shell in a
  4618. 2:27:35console you can't use them so
  4619. 2:27:37they created and you can find these by
  4620. 2:27:39doing get help
  4621. 2:27:40they're comparison operators so you can
  4622. 2:27:43either do it by
  4623. 2:27:44looking for comparison you'll find the
  4624. 2:27:45help file for it which is about
  4625. 2:27:47underscore comparison operators that
  4626. 2:27:49lists all of these and you're going to
  4627. 2:27:51see a lot of them in here
  4628. 2:27:53or to see all the operators get help
  4629. 2:27:56on operators because
  4630. 2:27:59this you're going to see us use these
  4631. 2:28:01you've got arithmetic assignment
  4632. 2:28:03comparison operators
  4633. 2:28:04let me just show you a couple of quick
  4634. 2:28:06examples with this
  4635. 2:28:08on this on this filter
  4636. 2:28:11so i've got status equals running let me
  4637. 2:28:14show you the v3 way to write this now
  4638. 2:28:16it's important that you get used to
  4639. 2:28:17seeing it as dollar sign underscore
  4640. 2:28:19because you can see it on the internet
  4641. 2:28:20this way
  4642. 2:28:22and guys like me still use it that way
  4643. 2:28:23but there's a new way to write this
  4644. 2:28:27called ps item
  4645. 2:28:30which makes a little bit more sense to a
  4646. 2:28:33lot of folks that this is current
  4647. 2:28:34holding the current item crossing that
  4648. 2:28:36pipeline so
  4649. 2:28:38get used to seeing it it works the same
  4650. 2:28:39way as dollar sign underscore as you can
  4651. 2:28:41see it'll come across
  4652. 2:28:44you're going to notice that i'm probably
  4653. 2:28:45going to use dollar sign underscore
  4654. 2:28:46because that's
  4655. 2:28:47just what i'm used to using but ps item
  4656. 2:28:49works but we can extend this filter even
  4657. 2:28:52further i want it that it is
  4658. 2:28:54equal to running and
  4659. 2:28:58dollar sign underscore and the name
  4660. 2:29:01is like and when you use like
  4661. 2:29:04now you can use wildcard so i want it
  4662. 2:29:06like
  4663. 2:29:09beast b star and i think i have some
  4664. 2:29:11services that ah
  4665. 2:29:13so this filter now lets me filter down
  4666. 2:29:16data now
  4667. 2:29:17i need you to think about something i'm
  4668. 2:29:18going to do some pseudo code somebody's
  4669. 2:29:20going to yell at me when i do this
  4670. 2:29:22the pseudo code means it's not really
  4671. 2:29:24doing anything so get stuff
  4672. 2:29:28sort then where
  4673. 2:29:33i just want some stuff
  4674. 2:29:36and then out to a file now i i let me
  4675. 2:29:39write this another way get stuff
  4676. 2:29:43by the way don't try that coming out it
  4677. 2:29:44doesn't work
  4678. 2:29:47where which i can't spell some stuff
  4679. 2:29:52sort and then out file which do you
  4680. 2:29:55think is going to be the best
  4681. 2:29:58performing way to write this if you
  4682. 2:30:01think about it think about what's
  4683. 2:30:02actually happening here i'm getting
  4684. 2:30:03stuff
  4685. 2:30:04and then in the first one i am sorting
  4686. 2:30:06it i'm sorting all of it
  4687. 2:30:10it's all sorted and then i'm handing it
  4688. 2:30:12to a filter that goes yeah but i just
  4689. 2:30:13wanted this
  4690. 2:30:14throw the rest of it away thanks for all
  4691. 2:30:16your hard work have a nice day
  4692. 2:30:18as opposed to the second one which is
  4693. 2:30:20get stuff well i just want this
  4694. 2:30:22uh-huh and now sort it done
  4695. 2:30:25so it does matter where you filter and
  4696. 2:30:28where you sort refer to this
  4697. 2:30:29as you filter as far left
  4698. 2:30:33as you possibly can and you can see
  4699. 2:30:35examples today where
  4700. 2:30:37the where object may not be the filter
  4701. 2:30:40that's furthest left as a matter of fact
  4702. 2:30:41you see some cool examples today where
  4703. 2:30:44you want to keep in mind filters far
  4704. 2:30:45left and sometimes that's with the
  4705. 2:30:46commandlet that's starting the process
  4706. 2:30:49so um you know jeffrey i think we're at
  4707. 2:30:51about
  4708. 2:30:52meal time yeah you know so by the way so
  4709. 2:30:54this where
  4710. 2:30:55command is someone you're going to want
  4711. 2:30:56to spend some time with
  4712. 2:30:58that is one of the most powerful things
  4713. 2:31:00like on the
  4714. 2:31:01face of the planet you guys are going to
  4715. 2:31:03have questions after this now i'm going
  4716. 2:31:05to give you some references to go to as
  4717. 2:31:07a matter of fact
  4718. 2:31:07don's got a great book out there that
  4719. 2:31:10you're really going to want to take a
  4720. 2:31:11look at and i'm going to mention a
  4721. 2:31:12little bit later on
  4722. 2:31:13but when you have questions when you
  4723. 2:31:15have things that um you are burning
  4724. 2:31:17desires for powershell
  4725. 2:31:19i have a place for you to go and i and
  4726. 2:31:20since don is here let me just show it to
  4727. 2:31:22you if i can figure out how to work
  4728. 2:31:25windows here here we go i'm so used to
  4729. 2:31:28the powershell stuff i forget the
  4730. 2:31:30so there's this place called
  4731. 2:31:33powershell.org.org
  4732. 2:31:35and look this is a centralized place for
  4733. 2:31:37you to find a ton of resources but one
  4734. 2:31:39of the most important things out there
  4735. 2:31:41is when you go out here you'll see the
  4736. 2:31:43forums you can go out there and you can
  4737. 2:31:44ask
  4738. 2:31:45questions and you can get answers and a
  4739. 2:31:47lot of mvps and a lot of super gurus are
  4740. 2:31:49out there
  4741. 2:31:49and it'd be even be great if someday you
  4742. 2:31:52decide to help answer some questions but
  4743. 2:31:54we've got forums we've got free e-books
  4744. 2:31:56out there to help you with some of the
  4745. 2:31:58specialized topics that we're going to
  4746. 2:31:59be getting into today
  4747. 2:32:00free powershell people's favorite word
  4748. 2:32:03in the world
  4749. 2:32:04free also i want to point out that we've
  4750. 2:32:08got
  4751. 2:32:08articles um there is a powershell summit
  4752. 2:32:11so there's information on the summit we
  4753. 2:32:12got a new summit coming up and tickets
  4754. 2:32:14are going to go on sale and
  4755. 2:32:16i'm not trying to be a sales guy or
  4756. 2:32:17anything just letting you know and also
  4757. 2:32:19one of the the podcast uh the
  4758. 2:32:21powerscripting podcast
  4759. 2:32:23it has a ton of information especially
  4760. 2:32:25over the last five years
  4761. 2:32:27of powershell and the power scripting
  4762. 2:32:28podcast is out there and an entire
  4763. 2:32:31script repository so go to
  4764. 2:32:32powershell.org
  4765. 2:32:33and ask questions after this event we'll
  4766. 2:32:36be happy to help you out and don's
  4767. 2:32:38the guy in charge of this and one of the
  4768. 2:32:40people responsible for this so
  4769. 2:32:42thanks don glad you're helping us out
  4770. 2:32:44today um before we get started into
  4771. 2:32:47uh chapter six there were some things
  4772. 2:32:49that we were noticing in chat
  4773. 2:32:51that we'd like to kind of talk about in
  4774. 2:32:52the next exactly yeah so one of the
  4775. 2:32:54questions had come up around case
  4776. 2:32:56sensitivity
  4777. 2:32:57and again whatever you yeah so whenever
  4778. 2:33:00you wonder hey
  4779. 2:33:01how does powershell do things think hey
  4780. 2:33:03what would somebody who's severely
  4781. 2:33:05flawed due
  4782. 2:33:06right and of course that's that's your
  4783. 2:33:09best predictor
  4784. 2:33:10and so we try and be as case insensitive
  4785. 2:33:13as possible right
  4786. 2:33:14so wherever we have the opportunity we
  4787. 2:33:17make things case insensitive
  4788. 2:33:18there are however uh certain you know
  4789. 2:33:21powershell commandlets you know other
  4790. 2:33:24teams that require case sensitivity if
  4791. 2:33:26that ever happens
  4792. 2:33:28uh it'll be highlighted in the
  4793. 2:33:29documentation but if it's not
  4794. 2:33:30highlighted in the documentation
  4795. 2:33:33you can assume case insensitivity that's
  4796. 2:33:35what my wife says she says you
  4797. 2:33:36you're very case insensitive i said no
  4798. 2:33:38i'm very case sensitive very case
  4799. 2:33:39sensitive and she says no
  4800. 2:33:40very case insensitive very case and then
  4801. 2:33:42i have to show her comparison operators
  4802. 2:33:44where you can
  4803. 2:33:45specify but yeah no i'm very sensitive
  4804. 2:33:48anyways that doesn't
  4805. 2:33:49anyways that almost worked it almost
  4806. 2:33:51worked so back to you though you wanted
  4807. 2:33:53to do some more stuff on wednesday yeah
  4808. 2:33:54i want to party on wear okay so
  4809. 2:33:56so here's the thing with wear right so
  4810. 2:33:58originally we uh uh tried to design
  4811. 2:34:00this where right so let's refresh our
  4812. 2:34:02memory so we had we have
  4813. 2:34:04get process right that's too many things
  4814. 2:34:08and so then what we said was we want to
  4815. 2:34:10filter this and so we pipe this to where
  4816. 2:34:13right and we have the squiggle brackets
  4817. 2:34:15now originally the way this worked was
  4818. 2:34:18um we hired we hired some smart guys and
  4819. 2:34:22we said hey
  4820. 2:34:22we need sql against objects against
  4821. 2:34:26live.net objects and they said uh-huh
  4822. 2:34:30i said go at it my friend this will be
  4823. 2:34:32straightforward
  4824. 2:34:33and like three months later they came
  4825. 2:34:35back and it was like and
  4826. 2:34:37they had only done a small subset and
  4827. 2:34:39the syntax was wonky
  4828. 2:34:41and it's just clear oh that's why
  4829. 2:34:44sql has like a couple hundred guys
  4830. 2:34:46working on this turns out it's a
  4831. 2:34:48hard problem and so we
  4832. 2:34:51we took a different approach and what we
  4833. 2:34:52did was we threw all that code away like
  4834. 2:34:54three months ago just threw it away
  4835. 2:34:56and literally literally we replaced it
  4836. 2:34:59with
  4837. 2:35:00three lines code three lines of code and
  4838. 2:35:03and here's the kicker does that mean we
  4839. 2:35:04can replace all the sql guys now too
  4840. 2:35:06and it's far more powerful than sql
  4841. 2:35:09basically three lines of code far more
  4842. 2:35:11powerful than sql i'm going to prove it
  4843. 2:35:13to you that's pretty bold right
  4844. 2:35:14so here's here are the three lines of
  4845. 2:35:16code okay so
  4846. 2:35:18where basically takes each object that
  4847. 2:35:21comes in the pipeline
  4848. 2:35:22it assigns it to a variable step number
  4849. 2:35:25one assign it to a variable
  4850. 2:35:26dollar sign under bar now it's dollar
  4851. 2:35:28sign under bar and dollar sign ps
  4852. 2:35:30item we assign it to a variable the
  4853. 2:35:33second
  4854. 2:35:34is we evaluate the code within the
  4855. 2:35:36squiggle brackets
  4856. 2:35:37we run the code and three
  4857. 2:35:41if the code returns true
  4858. 2:35:45we pass the object on and if it doesn't
  4859. 2:35:49we throw it away okay so it's that
  4860. 2:35:51simple it's truman's code
  4861. 2:35:53okay so now notice so that's why you're
  4862. 2:35:56able to do things like
  4863. 2:35:57hey um uh handles
  4864. 2:36:01greater than 1000 1000
  4865. 2:36:04okay so we grab the current object as
  4866. 2:36:07you notice here the first object here is
  4867. 2:36:10oh let's see
  4868. 2:36:11this thing and its handles is 82.
  4869. 2:36:14so we take this object which is the row
  4870. 2:36:17we assign it to dollar sign under bar
  4871. 2:36:20and then we
  4872. 2:36:20evaluate this hey is are the handles
  4873. 2:36:23greater than 1000. the answer is
  4874. 2:36:25false so you're going to see that object
  4875. 2:36:27doesn't get passed on
  4876. 2:36:29if ever it's true we then pass on the
  4877. 2:36:32object
  4878. 2:36:32as it is and you see
  4879. 2:36:36that all the things are greater than
  4880. 2:36:37hundred now remember the algorithm
  4881. 2:36:40it's important to memorize the algorithm
  4882. 2:36:42there are very few things that you
  4883. 2:36:43memorize in powershell
  4884. 2:36:44this is one of them assign the object to
  4885. 2:36:47dallas and underbar
  4886. 2:36:48evaluate the code if the code evaluates
  4887. 2:36:51to true
  4888. 2:36:52pass the object on if it evaluates to
  4889. 2:36:54false don't do that okay now
  4890. 2:36:58notice i never said that you had to use
  4891. 2:36:59the object in the expression
  4892. 2:37:01right so what's that mean so i could
  4893. 2:37:04have said
  4894. 2:37:05now here i'm going to limit this right
  4895. 2:37:06i'm going to say star ss
  4896. 2:37:08okay so we're going to do a subset
  4897. 2:37:09because it makes it a little easier
  4898. 2:37:11i can say where
  4899. 2:37:14dollar sign falls notice i didn't use
  4900. 2:37:17dollar sign under bar
  4901. 2:37:19nothing passed on because it always
  4902. 2:37:21evaluates to false
  4903. 2:37:22notice i can say dollar sign true
  4904. 2:37:26and it always succeeds okay so what i'm
  4905. 2:37:28really talking about so that's literally
  4906. 2:37:30how it works this isn't a joke that's
  4907. 2:37:32literally how it works now the point is
  4908. 2:37:34these are not very useful
  4909. 2:37:36and this is useful but the thing i want
  4910. 2:37:38to point out here is that you just run
  4911. 2:37:40the code the code can do
  4912. 2:37:41anything in this example it's a simple
  4913. 2:37:44expression
  4914. 2:37:45but you could have put a very complex
  4915. 2:37:47expression you could have put
  4916. 2:37:49a script you could have put 10 pages
  4917. 2:37:51worth of code here
  4918. 2:37:52you know calling up your mother to ask
  4919. 2:37:54her opinion on things looking things up
  4920. 2:37:56in active directory checking things in
  4921. 2:37:58sql you can do anything you want
  4922. 2:38:00at the end it has to evaluate to true or
  4923. 2:38:01evaluate to false and that's how it
  4924. 2:38:02works
  4925. 2:38:03so it is incredibly powerful now there's
  4926. 2:38:05one other thing i want to say about
  4927. 2:38:06where
  4928. 2:38:07and that is a lot of people who begin
  4929. 2:38:10with powershell look at these squiggle
  4930. 2:38:11brackets and they said
  4931. 2:38:12ah you know it's like mouse and so we
  4932. 2:38:16have
  4933. 2:38:16a very simplified version of wear now
  4934. 2:38:19this
  4935. 2:38:20isn't as rich as this wear you use with
  4936. 2:38:22the squiggle brackets you can do
  4937. 2:38:24anything
  4938. 2:38:24the simplified wear you can do very
  4939. 2:38:26subset of things you can do
  4940. 2:38:28things where a property operator value
  4941. 2:38:31so what you do and you don't have to
  4942. 2:38:33have the squiggle brackets so there you
  4943. 2:38:34go there's a deal
  4944. 2:38:35and you don't have dollar sign under bar
  4945. 2:38:38right so you get rid of that
  4946. 2:38:39and you can just say where handles
  4947. 2:38:42greater than
  4948. 2:38:431000 and voila it works
  4949. 2:38:47and i think for a lot of admins just
  4950. 2:38:48getting started especially with
  4951. 2:38:49filtering because filtering is going to
  4952. 2:38:51be one of the most important things that
  4953. 2:38:52you do
  4954. 2:38:53this simplified syntax can be really
  4955. 2:38:55helpful at first until you get more
  4956. 2:38:57used to the squiggly brackets now like
  4957. 2:39:00jeffrey said though
  4958. 2:39:01there are limitations there as soon as
  4959. 2:39:02you want to start doing
  4960. 2:39:04multiple criteria and as soon as you
  4961. 2:39:05wanted to call up your mother and check
  4962. 2:39:07with her first
  4963. 2:39:08that's going to require the squiggly
  4964. 2:39:10brackets but i really like the
  4965. 2:39:11simplified
  4966. 2:39:12yeah can i tell you i use this thing all
  4967. 2:39:13the time the simplified one
  4968. 2:39:15yeah so matter of fact when we look at
  4969. 2:39:17doing um some remoting stuff with
  4970. 2:39:18software and that i'll
  4971. 2:39:19i'll just do where installed yeah
  4972. 2:39:21exactly yeah make it real short and
  4973. 2:39:23sweet so
  4974. 2:39:24it's going to get really cool guys
  4975. 2:39:27that was awesome yeah okay
  4976. 2:39:30let's get serious for a moment no maybe
  4977. 2:39:33you ought to keep us both on screen
  4978. 2:39:34because we both have to have this
  4979. 2:39:36serious look on our face
  4980. 2:39:39we're going to go into the pipeline now
  4981. 2:39:41and but deeper
  4982. 2:39:43deep deeper deeper you were committing
  4983. 2:39:45all sorts h violated hr violations
  4984. 2:39:47today you were just like it was
  4985. 2:39:50inappropriate
  4986. 2:39:51whose is a pacman no inappropriate
  4987. 2:39:54so here's the deal what we're going to
  4988. 2:39:56show you is something that is very
  4989. 2:39:58advanced
  4990. 2:39:59and you you need to know this you you
  4991. 2:40:02need to know this but
  4992. 2:40:03what's going to happen is that you're
  4993. 2:40:04going to see the concept here and it's
  4994. 2:40:06going to happen really quick
  4995. 2:40:07and then you're going to need to
  4996. 2:40:08practice this and you're going to have
  4997. 2:40:09problems practicing this so i'm going to
  4998. 2:40:11give you a couple of references
  4999. 2:40:12right now before we get started first of
  5000. 2:40:15all you're going to want
  5001. 2:40:16chapter 9 out of don jones's book
  5002. 2:40:19lunches
  5003. 2:40:20uh uh sorry powershell in a month of
  5004. 2:40:23lunches yes learn windows powershell in
  5005. 2:40:25a month of lunches
  5006. 2:40:27you chapter nine you're going to want
  5007. 2:40:29that chapter and it'll take you through
  5008. 2:40:31everything that we're gonna do and you
  5009. 2:40:33will get a chance to try it now let me
  5010. 2:40:35tell you how important this was
  5011. 2:40:36i was sitting if you guys have been to a
  5012. 2:40:37conference before i'm sure you have been
  5013. 2:40:40i was sitting in a conference and you
  5014. 2:40:41know they they have the
  5015. 2:40:43the con you know like tech ed i mean
  5016. 2:40:45they're enormous
  5017. 2:40:46they put speaker they put the speaker
  5018. 2:40:48they put the rooms over there and rooms
  5019. 2:40:50over here and a football field
  5020. 2:40:51in the middle now that's where all the
  5021. 2:40:54sponsors go but
  5022. 2:40:55there's this there's this giant football
  5023. 2:40:57field and they don't put a lot of seats
  5024. 2:40:58in there
  5025. 2:40:59so you see all these people sitting up
  5026. 2:41:00against the wall and working on stuff
  5027. 2:41:03well i was sitting up against the wall
  5028. 2:41:05working on a problem
  5029. 2:41:06with getting two commandlets to work
  5030. 2:41:08together in exchange and i couldn't get
  5031. 2:41:10it to work
  5032. 2:41:10together and i said to myself i said
  5033. 2:41:15it it's it's a problem with the guys
  5034. 2:41:18that wrote the commandlets it's a
  5035. 2:41:19problem with powershell it just doesn't
  5036. 2:41:21work i'll just
  5037. 2:41:22i just can't solve that problem and not
  5038. 2:41:24but a few moments later
  5039. 2:41:26you and then shortly there after that
  5040. 2:41:28don jones
  5041. 2:41:30you taught me how to figure out how the
  5042. 2:41:32pipeline works
  5043. 2:41:33and suddenly by with this knowledge
  5044. 2:41:36suddenly
  5045. 2:41:37i could get that solution to work and i
  5046. 2:41:39guess what the moral of the story is
  5047. 2:41:41is that as soon as you understand this
  5048. 2:41:43the answer is
  5049. 2:41:44you can always get it to work so never
  5050. 2:41:47give up
  5051. 2:41:48it's just it's a little tricky at first
  5052. 2:41:50yeah this is one of those things my i
  5053. 2:41:52used to have a physics professor who
  5054. 2:41:53would say
  5055. 2:41:54this problem is simple once solved so
  5056. 2:41:58we're gonna help you solve it when you
  5057. 2:42:00first look at it you're like what the
  5058. 2:42:01heck what the heck
  5059. 2:42:02and then at some point there'll be this
  5060. 2:42:04moment of clarity and that's just super
  5061. 2:42:06super simple it really is
  5062. 2:42:23[Music]
  5063. 2:42:32here we go let me start you out with a
  5064. 2:42:33concept and jeffrey and i are going to
  5065. 2:42:35work through this we're going to talk
  5066. 2:42:36about how the pipeline works
  5067. 2:42:38and how things when objects get passed
  5068. 2:42:41how does the receiving commandlet know
  5069. 2:42:43what to do with them
  5070. 2:42:44if anything at all i i'm not a good guy
  5071. 2:42:47with sports analogies
  5072. 2:42:48because i don't know anything about
  5073. 2:42:49sports but as i understand it
  5074. 2:42:51there's this thing with the small white
  5075. 2:42:53balls where they have catcher's mitts
  5076. 2:42:55so you know the sending command that's
  5077. 2:42:58going to send some baseballs and we have
  5078. 2:42:59to see what catcher's mitts they get
  5079. 2:43:01caught on the receiving commandment
  5080. 2:43:03you'll see what i mean we have a process
  5081. 2:43:05of by value and by property name and
  5082. 2:43:08if those don't work we have a last line
  5083. 2:43:11of resorts so
  5084. 2:43:12i'm just going to first of all point out
  5085. 2:43:14that all of this is in the slides but
  5086. 2:43:15i'm not going to use the slides
  5087. 2:43:17so here we go let's get rid of the
  5088. 2:43:19slides
  5089. 2:43:21let's start with an idea get service if
  5090. 2:43:24i can spell it
  5091. 2:43:26stop service guys we showed you this
  5092. 2:43:28earlier and you
  5093. 2:43:29we did dash what if you know that it's
  5094. 2:43:31going to work
  5095. 2:43:33but the question that i have in my head
  5096. 2:43:35is why well here's what's happening
  5097. 2:43:38getservice has is getting a bunch of
  5098. 2:43:41services a bunch of objects and we're
  5099. 2:43:42going to send one object at a time
  5100. 2:43:43across the pipeline
  5101. 2:43:45my question is is the receiving command
  5102. 2:43:47which in this case is stop service
  5103. 2:43:51how is it grabbing hold of this object
  5104. 2:43:52and how does it know what to do with it
  5105. 2:43:54and
  5106. 2:43:54as it turns out it has a lot to do with
  5107. 2:43:57the parameters on the receiving
  5108. 2:43:59commandlet and that's what i want to
  5109. 2:44:01show you first of all one of the first
  5110. 2:44:04things we need to know
  5111. 2:44:05when we're looking at this is when we
  5112. 2:44:08send
  5113. 2:44:09we're sending objects we need to know
  5114. 2:44:11what kind of objects
  5115. 2:44:12they are so i piped it to get member
  5116. 2:44:15because get member shows me what type of
  5117. 2:44:18object
  5118. 2:44:19is being sent across the pipeline this
  5119. 2:44:21is a service controller object
  5120. 2:44:23i need to know that right now now what i
  5121. 2:44:26want to do is
  5122. 2:44:26i want to see what the receiving
  5123. 2:44:29commandlet is capable of receiving
  5124. 2:44:32to do that we look at the help file for
  5125. 2:44:34it the receiving command
  5126. 2:44:36in this process you have a tendency to
  5127. 2:44:38get confused between
  5128. 2:44:39piping to get member and get help but
  5129. 2:44:41it's pipe to get member to see
  5130. 2:44:43the object what kind it is and then we
  5131. 2:44:45look at the help file on the receiving
  5132. 2:44:47commandlet so
  5133. 2:44:48let me show you get help on stop service
  5134. 2:44:51now
  5135. 2:44:51i'm going to use dash full because i
  5136. 2:44:53want you to see everything but jeffrey
  5137. 2:44:54will show you a trick here in a second
  5138. 2:44:57let me go in here and show you inside we
  5139. 2:44:59now
  5140. 2:45:00are very concerned with this information
  5141. 2:45:02we already know how to look at the
  5142. 2:45:04syntax i want to go down here and look
  5143. 2:45:05at the parameters
  5144. 2:45:06the parameters have a capability
  5145. 2:45:09sometimes and that capability is
  5146. 2:45:12do they accept pipeline input now think
  5147. 2:45:15of these guys
  5148. 2:45:16as the parameters are the things with or
  5149. 2:45:18without the catchers met so
  5150. 2:45:20what we're asking is is do you have a
  5151. 2:45:21catcher's mitt or not where you could
  5152. 2:45:23catch this object and do something with
  5153. 2:45:25it
  5154. 2:45:25well a lot of times you'll see like
  5155. 2:45:27display name it it doesn't
  5156. 2:45:29accept pipeline input so there's nothing
  5157. 2:45:31going to cross
  5158. 2:45:32but let's go down this list i often
  5159. 2:45:34start at the bottom but let's go down
  5160. 2:45:35this list
  5161. 2:45:37and this is um stop service so let's see
  5162. 2:45:39here dash what if well dash what if it
  5163. 2:45:41doesn't even make sense to accept
  5164. 2:45:43pipeline input dash confirm
  5165. 2:45:45no that doesn't accept it pass through
  5166. 2:45:48that doesn't accept it
  5167. 2:45:49dash name that does accept it now here's
  5168. 2:45:53what we're concerned about
  5169. 2:45:54we have two ways of accepting pipeline
  5170. 2:45:56input by value
  5171. 2:45:58and by property name and if you're a dev
  5172. 2:46:00out there we're not talking about by
  5173. 2:46:01vowel by ref this is different
  5174. 2:46:03but by value and by property name
  5175. 2:46:06the first way we're going to try it is
  5176. 2:46:08by value and what you're going to notice
  5177. 2:46:10here is
  5178. 2:46:10dash name it supports accepting pipeline
  5179. 2:46:13input by value
  5180. 2:46:14and it would like some kind of string
  5181. 2:46:17well
  5182. 2:46:17wait a second let me show this to you
  5183. 2:46:19let me go up a little bit further
  5184. 2:46:21see this parameter called input object
  5185. 2:46:22i'm not exactly sure what it does but it
  5186. 2:46:24accepts
  5187. 2:46:26true by value look at the kind of
  5188. 2:46:29object it would like a service
  5189. 2:46:31controller wait a minute wait a minute
  5190. 2:46:32wait a minute
  5191. 2:46:33when i did get service what kind of
  5192. 2:46:35object was i sending it
  5193. 2:46:37i was sending a service controller so
  5194. 2:46:39when a service controller comes
  5195. 2:46:41cruising across that pipeline to stop
  5196. 2:46:43service
  5197. 2:46:45the catcher's mitt that's going to grab
  5198. 2:46:46it is the
  5199. 2:46:48input parameter catcher's mitt because
  5200. 2:46:51this name
  5201. 2:46:52is spelled exactly like service
  5202. 2:46:55controller
  5203. 2:46:55of the object type that i sent i know
  5204. 2:46:58this is weird but
  5205. 2:47:00they're spelled the same so since
  5206. 2:47:02they're spelled the same
  5207. 2:47:03this means we're actually passing it by
  5208. 2:47:05value and this is the one of the most
  5209. 2:47:06efficient ways
  5210. 2:47:08to pass so that's how get service
  5211. 2:47:11and stop service actually work we're
  5212. 2:47:13passing by value
  5213. 2:47:15into the parameter input object
  5214. 2:47:18because the names match the type of
  5215. 2:47:21object along with
  5216. 2:47:22what the parameter expects
  5217. 2:47:26here's where it gets a little tricky and
  5218. 2:47:29please jump in
  5219. 2:47:30as soon as you want to yell at me about
  5220. 2:47:31something because you're doing great you
  5221. 2:47:32think so because man this was this was
  5222. 2:47:34hard on me at first but as soon as i got
  5223. 2:47:36this this is
  5224. 2:47:37you got it what made made the world rock
  5225. 2:47:40let's try this notice that i did get
  5226. 2:47:42service stop service and i want to point
  5227. 2:47:44something out to you notice how the
  5228. 2:47:45nouns match
  5229. 2:47:46well if the nouns match it's likely
  5230. 2:47:49that they're going to work together on a
  5231. 2:47:50pipeline it's also
  5232. 2:47:52likely that they'll probably pass by
  5233. 2:47:54value but
  5234. 2:47:56that's not always the case so you always
  5235. 2:47:57want to check to make sure
  5236. 2:47:59let me show you something where the
  5237. 2:48:00nouns don't match
  5238. 2:48:03get service stop process well these are
  5239. 2:48:06two totally different things
  5240. 2:48:07services processes they're not the same
  5241. 2:48:10thing
  5242. 2:48:11so i'll bet most of you are thinking the
  5243. 2:48:13same thing that i am this
  5244. 2:48:14isn't going to work it can't possibly
  5245. 2:48:17work
  5246. 2:48:18services processes let's go through this
  5247. 2:48:21process and take a look
  5248. 2:48:24i'm going to do get service and i'm
  5249. 2:48:25going to pipe it to get member i know we
  5250. 2:48:27know the answer to this but i just want
  5251. 2:48:28to go through the process again
  5252. 2:48:30what kind of object are we sending we're
  5253. 2:48:32sending a service controller object
  5254. 2:48:33across now the first thing i want to
  5255. 2:48:35check
  5256. 2:48:35is to see if there's something in stop
  5257. 2:48:38process
  5258. 2:48:38that supports pipeline input by value
  5259. 2:48:42for this object that would be the first
  5260. 2:48:44way we would hook up
  5261. 2:48:45so i'm going to do get help on the
  5262. 2:48:46receiving commandlet which in this case
  5263. 2:48:48is stop process
  5264. 2:48:53and let's take a quick look let me get
  5265. 2:48:56up to the parameters
  5266. 2:48:58now guys i'm going to shorten this down
  5267. 2:48:59a little bit because i know some of
  5268. 2:49:00these parameters just don't accept
  5269. 2:49:02pipeline input like what if
  5270. 2:49:03it doesn't accept pipeline input so i
  5271. 2:49:05don't even need to look at it so every
  5272. 2:49:06time it says false
  5273. 2:49:07i'm not really that interested in it
  5274. 2:49:09passthrough doesn't support it
  5275. 2:49:11dash name it does support it but right
  5276. 2:49:13now i'm checking for by value this is my
  5277. 2:49:15property name so i'm looking for things
  5278. 2:49:16by value
  5279. 2:49:18up there we go input object it supports
  5280. 2:49:20pipeline input it'll catch it
  5281. 2:49:22and it's doing it by value the first way
  5282. 2:49:24we're going to do it but look at what it
  5283. 2:49:26wants
  5284. 2:49:26a process object well i'm not sending it
  5285. 2:49:30process isn't spelled the same way as
  5286. 2:49:33service controller
  5287. 2:49:36not even close so there's not going to
  5288. 2:49:39be
  5289. 2:49:39a hookup here so by value
  5290. 2:49:43fails well now at this point you kind of
  5291. 2:49:46go well if it fails it's just not going
  5292. 2:49:47to work
  5293. 2:49:48no now we move on to the next process
  5294. 2:49:51which is by
  5295. 2:49:51property name and this gets a little bit
  5296. 2:49:54confusing i want you to notice while i'm
  5297. 2:49:56in this help file
  5298. 2:49:57see how the parameter dash name
  5299. 2:50:01takes pipeline input by property name
  5300. 2:50:05here's what that's saying the object
  5301. 2:50:08that you're sending to me
  5302. 2:50:10does it have a property that is spelled
  5303. 2:50:14exactly like the parameter name that's
  5304. 2:50:17what we mean by property name
  5305. 2:50:18is it spelled the same and if so i might
  5306. 2:50:21be able to hook up that way
  5307. 2:50:22if by vowel fails i'll try this so
  5308. 2:50:26here's what i'm going to do here's the
  5309. 2:50:28catch phrase whenever you want to know
  5310. 2:50:30everything there is to know about an
  5311. 2:50:32object you pipe it to get members so
  5312. 2:50:34get service and i'm going to pipe it to
  5313. 2:50:39get member take a look at this list
  5314. 2:50:43is there a property and remember we only
  5315. 2:50:46all we need is the word property in it
  5316. 2:50:48is there a property
  5317. 2:50:49that is spelled the same way as the
  5318. 2:50:51parameter name and if you look at the
  5319. 2:50:53list
  5320. 2:50:56there is if they're spelled the same
  5321. 2:50:58we're going to have a hookup by property
  5322. 2:51:00name
  5323. 2:51:01but watch what's going to happen here
  5324. 2:51:04so let's look i'm only going to take one
  5325. 2:51:06service here
  5326. 2:51:08service look at what its name is it's
  5327. 2:51:10the name of the service
  5328. 2:51:12okay wait a second when you look at
  5329. 2:51:15processes let's look at processes
  5330. 2:51:21uh process name is also name
  5331. 2:51:25these are process names so when you
  5332. 2:51:28use the commandlet oops clear the screen
  5333. 2:51:31when you use the command
  5334. 2:51:32hello clear the screen there we go when
  5335. 2:51:34you use the commandlet stop
  5336. 2:51:36process what it wants for its dash name
  5337. 2:51:39is the name of a process what i'm
  5338. 2:51:42sending it
  5339. 2:51:44is the name of a service but here's the
  5340. 2:51:48thing
  5341. 2:51:48we do have a hookup this is going to
  5342. 2:51:51work
  5343. 2:51:52it's just your results may be a little
  5344. 2:51:54unusual so let's try it get service
  5345. 2:51:57pipe to stop process this should work
  5346. 2:52:00and
  5347. 2:52:00yeah i'm going to do a dash what if
  5348. 2:52:02because you know why i'm doing a dash
  5349. 2:52:04what if because it does
  5350. 2:52:05actually work notice there's a lot of
  5351. 2:52:07blood on my screen
  5352. 2:52:09now what this means is is that yeah look
  5353. 2:52:11cannot find the process with the name
  5354. 2:52:14well yeah because that's a service name
  5355. 2:52:15of course you can't find that but if you
  5356. 2:52:17look here did you see anything
  5357. 2:52:19white flyby cause that means
  5358. 2:52:22it worked let me see if i can find
  5359. 2:52:24something oh there's always something
  5360. 2:52:27i didn't see anything really don't
  5361. 2:52:28embarrass me in front of my friends
  5362. 2:52:30it's only five thousand or two i know
  5363. 2:52:32there's there's almost always something
  5364. 2:52:34in here that's in white
  5365. 2:52:36go to mine so let me show you guys
  5366. 2:52:40okay so here's here's i'll do a
  5367. 2:52:42different set
  5368. 2:52:43okay cool so notice i started up
  5369. 2:52:46calculator here
  5370. 2:52:47right and so i can do get process
  5371. 2:52:51calc and get calculator and i can pipe
  5372. 2:52:55that
  5373. 2:52:56to der and we see that calc
  5374. 2:53:00is in this and why is that
  5375. 2:53:03because der takes binds by name
  5376. 2:53:07and so you take a look and we'll does
  5377. 2:53:09dur take a process
  5378. 2:53:10do it you know
  5379. 2:53:12system.diagnostics.process
  5380. 2:53:14no and it says oh well i bind anything
  5381. 2:53:16by name
  5382. 2:53:17do you have a name and get process does
  5383. 2:53:20have a name
  5384. 2:53:21and therefore it works that's an
  5385. 2:53:24excellent example and so
  5386. 2:53:25between his example in mind you get
  5387. 2:53:27what's happening here is that
  5388. 2:53:29the commandlets are working together but
  5389. 2:53:31you have to look at what you're
  5390. 2:53:33giving it the information that you're
  5391. 2:53:35giving and what it's expecting in the
  5392. 2:53:36case of my get service stop
  5393. 2:53:38process if you have a process running
  5394. 2:53:41that happens to have the same name as a
  5395. 2:53:43service
  5396. 2:53:44it's going to get killed off most of the
  5397. 2:53:47time that's not the case
  5398. 2:53:48in jeffrey's example i've got a process
  5399. 2:53:50name that happens to be
  5400. 2:53:52actually a file i could go looking for
  5401. 2:53:54so that is a good result
  5402. 2:53:55that works out can i show them uh
  5403. 2:53:57actually you know i said that wrong
  5404. 2:53:59it was actually the path the path that
  5405. 2:54:01it was the dir yeah
  5406. 2:54:02so dur takes a path and process uh
  5407. 2:54:05object
  5408. 2:54:06has a path now here notice in my screen
  5409. 2:54:09uh we said oh you know by name well you
  5410. 2:54:12were doing it by name
  5411. 2:54:13right gsv b and and
  5412. 2:54:16notice his name um what is it i want to
  5413. 2:54:19show you
  5414. 2:54:20um through
  5415. 2:54:21[Music]
  5416. 2:54:23do gm okay
  5417. 2:54:26so notice this thing here yeah okay
  5418. 2:54:30name alias property service name so
  5419. 2:54:33unlike i remember i said that powershell
  5420. 2:54:37we're focused in on making your life
  5421. 2:54:39good because
  5422. 2:54:40those people aren't focused in on that
  5423. 2:54:42right they're focused in on
  5424. 2:54:43i'm writing this for myself it's going
  5425. 2:54:45to be cool or hey you're my developer
  5426. 2:54:47buddy and we're going to talk developer
  5427. 2:54:48talk to each other blah blah blah
  5428. 2:54:50and and so it's pretty inconsistent
  5429. 2:54:52world we're responsible for trying to
  5430. 2:54:54make it a consistent world for you
  5431. 2:54:56so whereas you know um you say
  5432. 2:54:59server service name and process was
  5433. 2:55:02process name
  5434. 2:55:03we want to say no you don't care about
  5435. 2:55:05all that crap you just want the name
  5436. 2:55:07name okay and so what we do is we take
  5437. 2:55:09the type system
  5438. 2:55:10and remember how i showed you xml we
  5439. 2:55:12tweaked the xml
  5440. 2:55:13and we presented to you simpler one of
  5441. 2:55:15the techniques we do for that is
  5442. 2:55:17something called an
  5443. 2:55:18alias property an alias property is with
  5444. 2:55:20something here we say hey
  5445. 2:55:22that we have this property name which is
  5446. 2:55:25aliased
  5447. 2:55:26to service name so the proper the object
  5448. 2:55:29itself really only has this thing called
  5449. 2:55:31service name but we say
  5450. 2:55:33hey treat it as though it has a name um
  5451. 2:55:36which and then when you ask for it given
  5452. 2:55:38the service name and that makes
  5453. 2:55:39that gives you a simplified uh
  5454. 2:55:42consistent view of the world
  5455. 2:55:44and it makes this interoperability stuff
  5456. 2:55:46work because if it turns out that hey
  5457. 2:55:48i want to send something to some command
  5458. 2:55:51and uh it's accepting things by
  5459. 2:55:53by gojar and i have one of those but i
  5460. 2:55:56call it a
  5461. 2:55:57foe right i just go and i say okay well
  5462. 2:55:59on my foo
  5463. 2:56:00you know i'm going to map its name to
  5464. 2:56:02goojar
  5465. 2:56:04i do that once and then i can send it to
  5466. 2:56:06you as a matter of fact this is a
  5467. 2:56:08perfect
  5468. 2:56:08setup for the next stage in this and so
  5469. 2:56:12understand what he's he's showing you is
  5470. 2:56:13that they've done a lot of work to make
  5471. 2:56:16powershell commands consistent in other
  5472. 2:56:19words we had a service name on the
  5473. 2:56:21object
  5474. 2:56:21but they created an alias property
  5475. 2:56:24called name
  5476. 2:56:24so it could work with other commandlets
  5477. 2:56:26that accept
  5478. 2:56:28by property name so they they're making
  5479. 2:56:31it consistent for us
  5480. 2:56:33but there are times when the greatest
  5481. 2:56:36minds all think alike but
  5482. 2:56:38just haven't had a chance to get
  5483. 2:56:39everything consistent yet
  5484. 2:56:41let me give you an example where this is
  5485. 2:56:42going to break down there's
  5486. 2:56:44one of my favorite commandments is get
  5487. 2:56:46ad computer and i need to tell you that
  5488. 2:56:48one of the things you have to be kind of
  5489. 2:56:49careful with is microsoft
  5490. 2:56:51especially the product teams when they
  5491. 2:56:52work with this they they try to help you
  5492. 2:56:55by not
  5493. 2:56:55doing dangerous things to yourself i
  5494. 2:56:57think about the technology underneath
  5495. 2:56:59what this commandlet's going to do
  5496. 2:57:00if i run this who has this information a
  5497. 2:57:03domain controller does so this command
  5498. 2:57:05has to go out to a domain controller ask
  5499. 2:57:08the domain controller for this
  5500. 2:57:09information and then spit this
  5501. 2:57:10information back
  5502. 2:57:12look quite honestly that if you only
  5503. 2:57:14have a couple dozen computers that's not
  5504. 2:57:16a big deal
  5505. 2:57:17but if you have 30 000 computers this
  5506. 2:57:20could be a big deal this could
  5507. 2:57:22make your domain controller not a domain
  5508. 2:57:24controller for a while and then when it
  5509. 2:57:25spits the data back
  5510. 2:57:27you could have some performance issues
  5511. 2:57:28for a while so when
  5512. 2:57:30you're running commands you will notice
  5513. 2:57:32you know a lot of times you'll do a get
  5514. 2:57:33command and it'll
  5515. 2:57:34just run commandlets that might be a
  5516. 2:57:37little bit more dangerous that's not the
  5517. 2:57:39case what they do
  5518. 2:57:40is they put things in them that are
  5519. 2:57:41mandatory we mentioned this with git
  5520. 2:57:43event log earlier
  5521. 2:57:44this is another great command that has
  5522. 2:57:46an example so let me show you if i just
  5523. 2:57:47strike enter on get ad computer
  5524. 2:57:50uh-uh bro you got to give me a little
  5525. 2:57:52bit more information about this
  5526. 2:57:54you've got to be you i don't want to get
  5527. 2:57:56you everything
  5528. 2:57:58really so i'm just going to put in a
  5529. 2:57:59star this will work
  5530. 2:58:01it'll get me everything but notice what
  5531. 2:58:03i've done i'm the one now that's made
  5532. 2:58:05the decision
  5533. 2:58:06to actually get everything so this is
  5534. 2:58:08the commandment that i'm going to use
  5535. 2:58:09for a second so let me do this get ad
  5536. 2:58:11computer
  5537. 2:58:13and i'm just going to put in the filter
  5538. 2:58:15star which means i'm going to grab
  5539. 2:58:17everything
  5540. 2:58:18and i want to here's my business problem
  5541. 2:58:20what i would like to do is get the
  5542. 2:58:21status of the bit service on
  5543. 2:58:23every computer in the network i know it
  5544. 2:58:25doesn't sound that creative but it gets
  5545. 2:58:27better later
  5546. 2:58:28so get service name bits understand what
  5547. 2:58:32i'm trying to do
  5548. 2:58:33i'm trying to get a list of all the
  5549. 2:58:34computers from active directory
  5550. 2:58:37and i want them piped to get service
  5551. 2:58:40and so that git service will then grab
  5552. 2:58:42the bit service from all of them
  5553. 2:58:43well here's the thing let's see if we
  5554. 2:58:46can figure out how this is going to work
  5555. 2:58:48or not work so first thing is that we do
  5556. 2:58:52is i go through the whole process first
  5557. 2:58:53of all pipe to gms to find out what kind
  5558. 2:58:55of object am i working with
  5559. 2:58:56i need to know this for by value in case
  5560. 2:58:58it works for by value so
  5561. 2:59:00ad computer object sounds great probably
  5562. 2:59:03ain't going to happen because the nouns
  5563. 2:59:04don't match but
  5564. 2:59:0580 computer object great next thing i'm
  5565. 2:59:08going to do is get help
  5566. 2:59:10on git service and see if it did
  5567. 2:59:14see if it supports um uh
  5568. 2:59:1880 computer object by value
  5569. 2:59:21and guys i'm going to make this a little
  5570. 2:59:23bit briefer so rather than scrolling
  5571. 2:59:24through
  5572. 2:59:25every and stopping at every single one
  5573. 2:59:27of them let me just scroll up
  5574. 2:59:28to the things that say by value can i
  5575. 2:59:30show them a trick yeah sure so
  5576. 2:59:32do that again and do minus show window
  5577. 2:59:35so do show window open window
  5578. 2:59:39okay and so if you have full now now
  5579. 2:59:41search by by value
  5580. 2:59:42oh man see this whole this whole show
  5581. 2:59:46this whole show window thing is just
  5582. 2:59:48awesome yeah and then hit next oh wait a
  5583. 2:59:49minute i have to hit next there we go oh
  5584. 2:59:52boy there we go what objects see so now
  5585. 2:59:55look look look we got it except pipeline
  5586. 2:59:58input
  5587. 2:59:58you have to watch me scroll true by
  5588. 3:00:01value we're looking good
  5589. 3:00:03what kind of object does input object
  5590. 3:00:04want it wants a
  5591. 3:00:06sir is that spelled exactly the same way
  5592. 3:00:08as a d
  5593. 3:00:09computer no so no hook
  5594. 3:00:13up by value so close so yeah we're so
  5595. 3:00:15close
  5596. 3:00:17so what we're going to do then is check
  5597. 3:00:19for by property name
  5598. 3:00:21well i have to take a look at what the
  5599. 3:00:23properties are and really the only
  5600. 3:00:25property
  5601. 3:00:25i care about that i'm trying to send
  5602. 3:00:27across is whatever holds
  5603. 3:00:29the computer name so let's take a look
  5604. 3:00:31at that real quick
  5605. 3:00:33um get ad computer
  5606. 3:00:36filter star well gee whiz just take one
  5607. 3:00:40of them there's a whole bunch of stuff
  5608. 3:00:42that's
  5609. 3:00:43being sent across the pipe the only
  5610. 3:00:44thing i care about though is where the
  5611. 3:00:46computer name is and that property is
  5612. 3:00:48called
  5613. 3:00:49name so let's go back to the show window
  5614. 3:00:53and see if we have something that
  5615. 3:00:54supports
  5616. 3:00:56name so pipeline by property name
  5617. 3:00:59and so let's do this trick by
  5618. 3:01:03property name and watch what happens so
  5619. 3:01:05we'll find him
  5620. 3:01:07dash computer name hey that supports by
  5621. 3:01:09prop by property name
  5622. 3:01:11but but remember what the rule is this
  5623. 3:01:15has to be spelled exactly like this for
  5624. 3:01:18by property to hook up
  5625. 3:01:20and it's not in fact it's not spelled
  5626. 3:01:23the same
  5627. 3:01:24but you know what is spelled the same if
  5628. 3:01:26i go down here oops wait
  5629. 3:01:27which way down in it lucky
  5630. 3:01:30aim we do support by property name on
  5631. 3:01:33something spelled exactly the same but
  5632. 3:01:36look at what it says
  5633. 3:01:37it wants a service name so here's what's
  5634. 3:01:40going to happen if i try to run this
  5635. 3:01:42i'm going to take a bunch of computer
  5636. 3:01:43names and it's going to
  5637. 3:01:45think that i'm giving it service names
  5638. 3:01:47and unless you named your computers
  5639. 3:01:49after services which would never be a
  5640. 3:01:51good idea
  5641. 3:01:52this is not going to work you know the
  5642. 3:01:54thing is that
  5643. 3:01:55it really gets me is god if there was
  5644. 3:01:58only a way
  5645. 3:01:59if there only was a way where i don't
  5646. 3:02:02want
  5647. 3:02:02this to be called name i want it to be
  5648. 3:02:04called
  5649. 3:02:05computer names because it was called
  5650. 3:02:07computer name then it would
  5651. 3:02:08it would match and everything would work
  5652. 3:02:10if there was only a way i could change
  5653. 3:02:13this property to say computer name
  5654. 3:02:16and yet there is
  5655. 3:02:20you are shown you want to show them
  5656. 3:02:22you've got your computer
  5657. 3:02:24oh that's you have a computer well let
  5658. 3:02:25me show them that so
  5659. 3:02:28let's do the concept so watch guys take
  5660. 3:02:31a look
  5661. 3:02:32get service and i'm just going to show
  5662. 3:02:34you a quick concept
  5663. 3:02:35i want you to see i'm just going to work
  5664. 3:02:36with one service to keep it simple
  5665. 3:02:38you guys have seen us select properties
  5666. 3:02:41before by the way i don't think you've
  5667. 3:02:42shown them computer name have you shown
  5668. 3:02:44a computer name
  5669. 3:02:45so you know get service works against
  5670. 3:02:47computers
  5671. 3:02:48yes oh yeah yeah i should have shown you
  5672. 3:02:50in the help file you'll see
  5673. 3:02:51it has dash computer name so i could use
  5674. 3:02:53this against remote computers
  5675. 3:02:55which is what i'm trying to get the
  5676. 3:02:56active directory commandlet to do
  5677. 3:02:58i'm going to grab name and status and i
  5678. 3:03:00want you guys to see something yeah it's
  5679. 3:03:01going to give me the name and the status
  5680. 3:03:03that's what you would expect but how
  5681. 3:03:05many of you would expect to get an error
  5682. 3:03:07if this occurred and usually when i'm at
  5683. 3:03:08a conference this is exactly what i type
  5684. 3:03:10because i can't type very well so it
  5685. 3:03:12usually comes out name
  5686. 3:03:14status status
  5687. 3:03:18watch what happens see that
  5688. 3:03:22do you get what's going on here wait a
  5689. 3:03:24minute a lot of people think that that
  5690. 3:03:25should generate an error that shouldn't
  5691. 3:03:26generate an error that's a feature
  5692. 3:03:29let me show you i'm going to pipe that
  5693. 3:03:30to get member
  5694. 3:03:34look it just created
  5695. 3:03:38new properties called nam and students
  5696. 3:03:43so here's the idea i want you to think
  5697. 3:03:45about this
  5698. 3:03:46i wonder if i could take the existing
  5699. 3:03:49property for ad computer called name
  5700. 3:03:53and change it to computer name and the
  5701. 3:03:55answer is yes
  5702. 3:03:56however the answer is yes
  5703. 3:04:01but let me show you how this is going to
  5704. 3:04:02work
  5705. 3:04:04first of all i'm going to select the
  5706. 3:04:07property
  5707. 3:04:08name just so you can see i'm not
  5708. 3:04:11cheating
  5709. 3:04:12and then i'm going to show you some
  5710. 3:04:14special syntax and
  5711. 3:04:15this syntax at first is a little chewy
  5712. 3:04:18but it's in the help file for the select
  5713. 3:04:20dash object and it's in the example so
  5714. 3:04:22it's
  5715. 3:04:23going to be one of the things you want
  5716. 3:04:24to learn it's a hash table syntax and we
  5717. 3:04:26use hash tables everywhere
  5718. 3:04:28so you're going to spend the time you're
  5719. 3:04:29going to learn the syntax this syntax
  5720. 3:04:31you must
  5721. 3:04:32you must you're just going to keep
  5722. 3:04:34typing it till you learn it this is
  5723. 3:04:35something you're going to have to
  5724. 3:04:36keep in so it's an at sign with an open
  5725. 3:04:38squiggly and what we have is the word
  5726. 3:04:40called
  5727. 3:04:40name equals and now you get to create
  5728. 3:04:43your own
  5729. 3:04:44property name what would i what would i
  5730. 3:04:46like this to be called i want it to be
  5731. 3:04:48called
  5732. 3:04:48computer name so i'm going to put in
  5733. 3:04:50computer name
  5734. 3:04:53and at this point semicolon and then you
  5735. 3:04:56specify
  5736. 3:04:57the expression that will fill that
  5737. 3:04:59column with data
  5738. 3:05:01well let's do this expression equals
  5739. 3:05:05and you're going to put that inside of
  5740. 3:05:06squigglies and there's one squiggly left
  5741. 3:05:09over
  5742. 3:05:10so inside here we want the current
  5743. 3:05:12object on the pipeline dollar sign
  5744. 3:05:13underscore or you can use dollar sign ps
  5745. 3:05:16item for with version three
  5746. 3:05:18and what do i want from the object
  5747. 3:05:20that's coming from get a d
  5748. 3:05:22computer i want the original name
  5749. 3:05:25property so watch
  5750. 3:05:27name i'm gonna strike enter and watch
  5751. 3:05:29what happens
  5752. 3:05:32dudettes deuces oh
  5753. 3:05:35i've got myself a computer name now
  5754. 3:05:38property now let me just show you how
  5755. 3:05:41you're going to see this on the internet
  5756. 3:05:42a couple of
  5757. 3:05:43just quickie things this is a you know
  5758. 3:05:45here is custom columns
  5759. 3:05:46calculated properties people use all
  5760. 3:05:48these terms for
  5761. 3:05:49for for this but you almost never see
  5762. 3:05:52everybody type in
  5763. 3:05:53this full syntax this way they're going
  5764. 3:05:54to shorten this up to just an
  5765. 3:05:56e and they're going to shorten this up
  5766. 3:05:58to just an n
  5767. 3:06:00and why because because i'm a flawed
  5768. 3:06:03person
  5769. 3:06:04i can't talk first and i can't type at
  5770. 3:06:06all i'm going to figure out how to spell
  5771. 3:06:08expressions expression i know i know
  5772. 3:06:10but watch guys i want to i want you to
  5773. 3:06:11see that this still works so
  5774. 3:06:13you know i've changed it one other thing
  5775. 3:06:15i want to show you you're going to see
  5776. 3:06:16this a lot on the internet and you need
  5777. 3:06:17to watch out for it
  5778. 3:06:19used to be that instead of name this was
  5779. 3:06:22called
  5780. 3:06:23label and everybody would abbreviate
  5781. 3:06:25this as
  5782. 3:06:26an l well i don't know about you but
  5783. 3:06:28when you see this on a blog post or in a
  5784. 3:06:31book
  5785. 3:06:31you can't tell the difference between an
  5786. 3:06:34l and the number one
  5787. 3:06:36so a lot of times you'll type it in
  5788. 3:06:37wrong and you'll go it just doesn't work
  5789. 3:06:39no if you ever see an l or what looks
  5790. 3:06:42like to be a one
  5791. 3:06:43always replace it with an n that way you
  5792. 3:06:45get rid of
  5793. 3:06:46all of those little ambiguity i can't
  5794. 3:06:48say that word but all those little
  5795. 3:06:50problems
  5796. 3:06:50and big yeah all these wild cards for
  5797. 3:06:54speech so
  5798. 3:06:56let's do this i don't really need this
  5799. 3:06:59name in here anymore because
  5800. 3:07:01i've managed to create my own version
  5801. 3:07:04and i want to show you if you pipe it to
  5802. 3:07:05get member
  5803. 3:07:08see it says computer name so lookie
  5804. 3:07:11when we pass it to the the receiving
  5805. 3:07:13commandlet
  5806. 3:07:14computer name is going to match with
  5807. 3:07:16computer name by property name
  5808. 3:07:20and lo and behold donald trump
  5809. 3:07:23drum roll drum roll drum roll and the
  5810. 3:07:25command was get
  5811. 3:07:26service name bits
  5812. 3:07:34oh come on that is so wickedly cool so
  5813. 3:07:39the guys in the back are going i don't
  5814. 3:07:40know what the hell he just did but okay
  5815. 3:07:42we'll go with it
  5816. 3:07:43but here's the begging for the applause
  5817. 3:07:45yeah pity applause golf clap
  5818. 3:07:47um here's the thing is that
  5819. 3:07:50you know they're working to try to you
  5820. 3:07:52know give you alias properties to
  5821. 3:07:54make some consistencies but that's not
  5822. 3:07:56always going to be the case sometimes
  5823. 3:07:58you're the one that has to do it in
  5824. 3:07:59flight to make the consistency
  5825. 3:08:02using a custom column or calculated
  5826. 3:08:04property
  5827. 3:08:05we use these a ton because there's so
  5828. 3:08:08much we can do with this
  5829. 3:08:10so much we can do with this and you'll
  5830. 3:08:12see some more examples of us of us using
  5831. 3:08:14it in here
  5832. 3:08:15but we do have the last
  5833. 3:08:19the last possibility
  5834. 3:08:22it's my favorite one because everybody
  5835. 3:08:26yells at me when i do this
  5836. 3:08:27by the way it's really worth spending
  5837. 3:08:29time on this stuff this
  5838. 3:08:30is the heart of powershell this is the
  5839. 3:08:33core
  5840. 3:08:34concept it's the core power that's where
  5841. 3:08:37you get all your magic
  5842. 3:08:39so learning the stuff like spending some
  5843. 3:08:41time understanding how it really works
  5844. 3:08:43uh getting familiar with the wear the
  5845. 3:08:45pipelining is
  5846. 3:08:46is the heart of it it's worth an
  5847. 3:08:47investment well and i just i just have
  5848. 3:08:49to say
  5849. 3:08:50and and and this is definitely um
  5850. 3:08:53for me guys this is what changed my
  5851. 3:08:55ability to
  5852. 3:08:57be productive with powershell when i
  5853. 3:08:59learned
  5854. 3:09:00this this is what suddenly made
  5855. 3:09:02powershell
  5856. 3:09:03oh i got this because i could discover
  5857. 3:09:05whatever it is i was looking for
  5858. 3:09:07and now i knew how to put it together
  5859. 3:09:09and if it didn't work i knew how to
  5860. 3:09:10troubleshoot it that's the important
  5861. 3:09:12thing
  5862. 3:09:12i know we're going through it quickly
  5863. 3:09:14here but again
  5864. 3:09:16this is the most important thing and it
  5865. 3:09:18does it changes it makes you totally
  5866. 3:09:20productive now i've shown you three ways
  5867. 3:09:22so far
  5868. 3:09:23in this it's getting the stuff to work
  5869. 3:09:25on multiple machines we're going to talk
  5870. 3:09:26more about remoting
  5871. 3:09:27but that's where you just become so
  5872. 3:09:29productive the number of people who've
  5873. 3:09:31come up to me at tech ad
  5874. 3:09:32and had stories like there's remember
  5875. 3:09:35this one guy who said oh well you know
  5876. 3:09:36his boss brings everybody in on like a
  5877. 3:09:38tuesday it's like oh we got to get this
  5878. 3:09:40information from
  5879. 3:09:41every single one of our servers it's top
  5880. 3:09:43priority gotta have it by the end of the
  5881. 3:09:45week
  5882. 3:09:45call home tell folks you're gonna be
  5883. 3:09:47working late doesn't matter
  5884. 3:09:49we gotta get this done he's like uh
  5885. 3:09:50everybody's like uh
  5886. 3:09:52and so he goes back to his office he's
  5887. 3:09:53like wait a minute wait
  5888. 3:09:55i can do that with powershell he says
  5889. 3:09:57ten minutes later i had all the
  5890. 3:09:59information
  5891. 3:10:00he said it took a couple more minutes to
  5892. 3:10:01put in an excel spreadsheet
  5893. 3:10:03yeah so in like 15 minutes i was done i
  5894. 3:10:06said that's awesome
  5895. 3:10:06what did you do he says well i went home
  5896. 3:10:08i took the rest of the
  5897. 3:10:11and then he year back in the morning and
  5898. 3:10:12showed his boss this awesome report he's
  5899. 3:10:14like oh you're a god
  5900. 3:10:16and that's kind of the point is i want
  5901. 3:10:18to go home so i want to get this stuff
  5902. 3:10:20done right
  5903. 3:10:21and this is a primary way for you to
  5904. 3:10:23figure out how things work so
  5905. 3:10:25three ways we've done it so far get
  5906. 3:10:27service to stop service we matched by
  5907. 3:10:30value and that's how we're going to try
  5908. 3:10:31at the very beginning
  5909. 3:10:33when the nouns don't match by value
  5910. 3:10:35probably isn't going to happen not
  5911. 3:10:37always but probably is not going to
  5912. 3:10:38happen and we did get service
  5913. 3:10:40stop process where we had to start to
  5914. 3:10:42match by property name which means
  5915. 3:10:44the name of the the the the the property
  5916. 3:10:48coming across
  5917. 3:10:49has to match the name of the parameter
  5918. 3:10:51of the receiving commandlet
  5919. 3:10:53but whenever you do that that's where
  5920. 3:10:55what if is your friend
  5921. 3:10:56oh yeah that is where what f is
  5922. 3:10:58definitely your friend
  5923. 3:11:00the third way is well
  5924. 3:11:03there's a parameter that supports
  5925. 3:11:05pipeline input and you want to use that
  5926. 3:11:07parameter but what
  5927. 3:11:08the property you're sending it doesn't
  5928. 3:11:09have the right name so you can change it
  5929. 3:11:12in flight using this syntax
  5930. 3:11:15here's the fourth and final and believe
  5931. 3:11:18me then we're ready for a break here in
  5932. 3:11:20just a second so
  5933. 3:11:22so get 80 computer i want you to
  5934. 3:11:26understand my business problem
  5935. 3:11:27first of all to show you there's a
  5936. 3:11:29commitment we're not going to get a lot
  5937. 3:11:30of time today to spend with this
  5938. 3:11:32with the concept of wmi but wmi is one
  5939. 3:11:35of the greatest things wmi and similar
  5940. 3:11:36one of the greatest things in the world
  5941. 3:11:37i'm hoping that a little bit later on
  5942. 3:11:38jeffrey will be able to have a chance to
  5943. 3:11:40talk about it
  5944. 3:11:42but i just want to show you wmi is great
  5945. 3:11:44for grabbing all kinds of wonderful
  5946. 3:11:45information
  5947. 3:11:47here's an example of wmi grabbing just
  5948. 3:11:49some bios information
  5949. 3:11:50i also want to point out that this
  5950. 3:11:52commandlet supports
  5951. 3:11:53computer name which means i could get it
  5952. 3:11:55from multiple computers
  5953. 3:11:57now if i could spell them correctly
  5954. 3:12:00so understand that this could be really
  5955. 3:12:02useful to me i might want to do a whole
  5956. 3:12:04hardware inventory
  5957. 3:12:05but i'm not going to want to sit here
  5958. 3:12:07and hand type in a bunch of computer
  5959. 3:12:09names instead i'm going to want to
  5960. 3:12:11pipe a bunch of computer names from
  5961. 3:12:12active directory so what i'm doing is
  5962. 3:12:14i'm going to say get ad computer
  5963. 3:12:17filter star
  5964. 3:12:19[Music]
  5965. 3:12:21pipe to get wmi object
  5966. 3:12:24and i want the class for bios
  5967. 3:12:28well here's the thing you can spend the
  5968. 3:12:31next
  5969. 3:12:32two days trying to get this to work
  5970. 3:12:38ain't gonna happen if you know how to
  5971. 3:12:39work this process that we're showing you
  5972. 3:12:41right here
  5973. 3:12:42here's what you would do and you're
  5974. 3:12:44gonna solve this problem in seconds
  5975. 3:12:46rather than days first of all you're
  5976. 3:12:48going to pipe to gm to see what the
  5977. 3:12:49object type is because we want to check
  5978. 3:12:51for by value and i'm just going to tell
  5979. 3:12:52you right now my value is not going to
  5980. 3:12:54work
  5981. 3:12:54i got ad computer but by value is not
  5982. 3:12:57going to work you know how i know that
  5983. 3:12:58because the next thing we do is we go
  5984. 3:13:00look at parameters that support
  5985. 3:13:02pipeline input well let's do that get
  5986. 3:13:05help
  5987. 3:13:06uh get wmi object
  5988. 3:13:10dash full
  5989. 3:13:13and guys i i know we could do this uh
  5990. 3:13:15with the uh the show window but i just
  5991. 3:13:17want you to see the beauty of this
  5992. 3:13:19watch as it scrolls by when i get to the
  5993. 3:13:21parameters
  5994. 3:13:24throttle limit no recurse
  5995. 3:13:28no query no property no
  5996. 3:13:32name space no locale yeah denied
  5997. 3:13:36um list no uh impersonation fun on a
  5998. 3:13:40friday night but no
  5999. 3:13:41it's um filter no every computer says
  6000. 3:13:45no every parameter says
  6001. 3:13:49no no pipeline input
  6002. 3:13:52it will not take any pipeline input stop
  6003. 3:13:55trying
  6004. 3:13:56it won't take any pipeline input so i
  6005. 3:13:57see guys all the time that go
  6006. 3:14:00okay well then you can't do it it's
  6007. 3:14:02broke they need to fix that with
  6008. 3:14:03powershell
  6009. 3:14:04well no you can do it you just have to
  6010. 3:14:07know how
  6011. 3:14:08let me show you you know i was showing
  6012. 3:14:10you that
  6013. 3:14:11how this commandlet get help and i'm
  6014. 3:14:14going to do the short help for it
  6015. 3:14:16this guy supports dash computer name
  6016. 3:14:19well here i want you to take notice here
  6017. 3:14:20let's look at dash computer name see
  6018. 3:14:22dash computer name
  6019. 3:14:23and what he wants is a bunch of strings
  6020. 3:14:26that's what he wants
  6021. 3:14:27as an object strings he'll take dash
  6022. 3:14:30computer name i just have to figure out
  6023. 3:14:31how to get it
  6024. 3:14:32in there get those computer names in
  6025. 3:14:34there so
  6026. 3:14:35here's what i'd like to do get wmi
  6027. 3:14:39object whatever class i want
  6028. 3:14:44and i would like to do dash computer
  6029. 3:14:47name and
  6030. 3:14:48get the computer names in there i'd like
  6031. 3:14:49to do like get ad computer
  6032. 3:14:52filter star well you can't do that
  6033. 3:14:55because it
  6034. 3:14:55screws up the argument so you have to
  6035. 3:14:57put them in parentheses because remember
  6036. 3:14:59what parentheses means i wasn't a big
  6037. 3:15:01math fan
  6038. 3:15:02but they those things are like order of
  6039. 3:15:04operands or
  6040. 3:15:06you're a smart guy you know all that
  6041. 3:15:07stuff it's it's it means
  6042. 3:15:09do this first before we do anything else
  6043. 3:15:12so what's going to happen is
  6044. 3:15:13what's ever in those parens is
  6045. 3:15:15parenthetical it's going to do that
  6046. 3:15:17first
  6047. 3:15:18and that becomes the argument on this
  6048. 3:15:20dash computer name
  6049. 3:15:21but there's a small problem remember
  6050. 3:15:23dash computer name wants
  6051. 3:15:25a bunch of string objects i wonder what
  6052. 3:15:28this is providing me as a matter of fact
  6053. 3:15:30let me show you get
  6054. 3:15:32ad computer and you know how to do this
  6055. 3:15:33now filter star
  6056. 3:15:35what kind of object is this producing
  6057. 3:15:37pipe it to gm
  6058. 3:15:39it's giving me ad computer
  6059. 3:15:42that doesn't say string watch
  6060. 3:15:45also it's giving me way too much
  6061. 3:15:48information
  6062. 3:15:50this is giving me all kinds of stuff i
  6063. 3:15:52don't want i just want name i just want
  6064. 3:15:54to select
  6065. 3:15:55i just want to select name so get ad
  6066. 3:16:00computer
  6067. 3:16:03filter star select the property
  6068. 3:16:07name awesome i've got the names this is
  6069. 3:16:10what i want to throw into dash computer
  6070. 3:16:12but
  6071. 3:16:13before we try this check it with get
  6072. 3:16:16member
  6073. 3:16:17look at what the object type is 80
  6074. 3:16:20computer
  6075. 3:16:20it doesn't say string here
  6076. 3:16:24so it's going to break well they thought
  6077. 3:16:26of this they solved this what i really
  6078. 3:16:28want
  6079. 3:16:29is i want to
  6080. 3:16:32extract those names and put them in that
  6081. 3:16:35dash computer name argument in between
  6082. 3:16:37the two of
  6083. 3:16:38us i want to extract or extract
  6084. 3:16:41extract isn't the right word i want to
  6085. 3:16:45expand this property now we can only
  6086. 3:16:48expand one
  6087. 3:16:49but look at the difference on my screen
  6088. 3:16:51how this looks
  6089. 3:16:53see how you don't have this anymore
  6090. 3:16:56it's just the names of the computers
  6091. 3:17:00let's pipe it to get member
  6092. 3:17:05lookie string
  6093. 3:17:08string happy happy happy happy so
  6094. 3:17:12what we do is we and i'm going to try to
  6095. 3:17:14do this i'm going to try to right click
  6096. 3:17:16on this
  6097. 3:17:18and here's what we're going to do right
  6098. 3:17:21yeah right click i i think i did that
  6099. 3:17:22right so
  6100. 3:17:24get wmi object whatever class i wanted
  6101. 3:17:28win32 underscore bios
  6102. 3:17:30dash computer name and here's what i
  6103. 3:17:32want to put inside of the parentheses
  6104. 3:17:34that whole thing now you might be saying
  6105. 3:17:38gee whiz
  6106. 3:17:38that's an awful lot of work but as soon
  6107. 3:17:40as you do this like two or three times
  6108. 3:17:42it's not a lot of work because now what
  6109. 3:17:45you couldn't solve
  6110. 3:17:46before or you were spending days banging
  6111. 3:17:48your head on
  6112. 3:17:50now just works and it just works because
  6113. 3:17:53we couldn't pipeline to this commandlet
  6114. 3:17:55darn okay forget about it that's fine
  6115. 3:17:58what do you want to use i want to use
  6116. 3:18:00dash computer name what does it want it
  6117. 3:18:01wants a string so i want to grab all the
  6118. 3:18:03aed computers i just want the property
  6119. 3:18:05name
  6120. 3:18:06i don't want all the other properties i
  6121. 3:18:07just want name send it to get
  6122. 3:18:09member it's not a string oh i need to
  6123. 3:18:11expand that
  6124. 3:18:13think extract that those values out
  6125. 3:18:17and i get the string now it's going to
  6126. 3:18:19work
  6127. 3:18:20this is your last line of resort now
  6128. 3:18:23don't use this as your first line of
  6129. 3:18:24resort
  6130. 3:18:25that's not the point because you want
  6131. 3:18:26the power of the pipeline
  6132. 3:18:28so don't do this first do this last and
  6133. 3:18:32let me show you and we're going to let
  6134. 3:18:33jeffrey talk about this for a second is
  6135. 3:18:34that
  6136. 3:18:35before we take a break let me show you
  6137. 3:18:37what i found out microsoft's kind of
  6138. 3:18:39doing to help us out
  6139. 3:18:41you know how the the get wmi thing
  6140. 3:18:45it doesn't take any pipeline input well
  6141. 3:18:48i happen to know that there's wait
  6142. 3:18:50before you go there okay
  6143. 3:18:52up arrow up arrow because this works
  6144. 3:18:55perfectly this works perfectly
  6145. 3:18:57but this works in powershell version two
  6146. 3:19:00powershell version three we made it
  6147. 3:19:02simpler
  6148. 3:19:04oh let's make it simpler hit delete
  6149. 3:19:07uh delete the select
  6150. 3:19:11oh no no all the way from the end of the
  6151. 3:19:13line to the slide away from the other
  6152. 3:19:15one
  6153. 3:19:16get rid of that get rid of all that yeah
  6154. 3:19:19more
  6155. 3:19:19more line okay now in paren
  6156. 3:19:22and parentheses that's again prin
  6157. 3:19:27oh end parent yeah okay space oh i see
  6158. 3:19:30what you're doing oh
  6159. 3:19:33[Music]
  6160. 3:19:36basically is shorthand uh
  6161. 3:19:40syntax to do that selects which is what
  6162. 3:19:42you were showing earlier with
  6163. 3:19:44casting to xml and guys one of the
  6164. 3:19:46things is we're going to start showing
  6165. 3:19:48you as we get close to scripting
  6166. 3:19:49we're going to be showing you working
  6167. 3:19:50with variables and using this dot syntax
  6168. 3:19:53this dot
  6169. 3:19:54syntax so you get more and more
  6170. 3:19:56comfortable with it because now
  6171. 3:19:58that was a lot easier to type as soon as
  6172. 3:20:00you know more about that dot syntax so
  6173. 3:20:02this is
  6174. 3:20:03awesome see it still worked and as
  6175. 3:20:06i just showed oh let me show you again
  6176. 3:20:08because i don't think the thing was on
  6177. 3:20:10there let me show you
  6178. 3:20:11that oh what's going on is this hard for
  6179. 3:20:13you
  6180. 3:20:17i could go over there well no it's it's
  6181. 3:20:20it's it's
  6182. 3:20:21something has gone awry and i think my
  6183. 3:20:24ah there we go something computer we
  6184. 3:20:26were waiting on so
  6185. 3:20:28this syntax if you can see it is it
  6186. 3:20:29works the exact same way um so i can
  6187. 3:20:32execute it but i don't want to do it
  6188. 3:20:33again because
  6189. 3:20:34it was holding up on one of the machines
  6190. 3:20:35oh was it one last thing to show you and
  6191. 3:20:37then we'll take a break
  6192. 3:20:39is get wmi object doesn't support any
  6193. 3:20:42input but
  6194. 3:20:43there's an if you're working with wmi
  6195. 3:20:45there's a whole new way of doing this
  6196. 3:20:48and if you were to do get help on
  6197. 3:20:50something called
  6198. 3:20:51get sem instance and you were to take a
  6199. 3:20:55look at the parameters and what they
  6200. 3:20:57what parameters accepted pipeline input
  6201. 3:20:59you would see that
  6202. 3:21:00this is now the replacement for
  6203. 3:21:04this because the new one
  6204. 3:21:07now supports pipeline input in the
  6205. 3:21:09places where you want it to support
  6206. 3:21:10pipeline input so
  6207. 3:21:13the idea is that going forward some of
  6208. 3:21:15the commands that you may run across
  6209. 3:21:16especially if they're four or five years
  6210. 3:21:18old that didn't support pipeline input
  6211. 3:21:20may start to support it but if it
  6212. 3:21:22doesn't you do have this last
  6213. 3:21:24line of resort now as a final note
  6214. 3:21:27make sure this is so very important well
  6215. 3:21:29you got
  6216. 3:21:30i was going to show them one more thing
  6217. 3:21:31oh go ahead show them one more thing i'm
  6218. 3:21:33going to take over your machine
  6219. 3:21:34okay it's all yours man okay just did
  6220. 3:21:36that work yeah right of course
  6221. 3:21:38okay here we go where are you
  6222. 3:21:41okay i'm taking over his machine he's
  6223. 3:21:42gonna take over my machine while he's
  6224. 3:21:44taking it over
  6225. 3:21:45get don jones's book uh learn windows
  6226. 3:21:49powershell in a month of lunches
  6227. 3:21:51chapter nine you've got to know that
  6228. 3:21:53that's the most important thing that's
  6229. 3:21:54what we just did in here
  6230. 3:21:57okay so now i'm gonna show you something
  6231. 3:22:00crazy freaky
  6232. 3:22:01freaky freaky freaky powerful oh let's
  6233. 3:22:03get freaky yeah we're gonna get freaky
  6234. 3:22:05freaking
  6235. 3:22:06okay sorry
  6236. 3:22:10okay so so now this is this is pretty
  6237. 3:22:12advanced stuff
  6238. 3:22:13um but why not end
  6239. 3:22:16on something really powerful okay and
  6240. 3:22:19this is something
  6241. 3:22:20called um what do we call these we call
  6242. 3:22:22these script parameters
  6243. 3:22:24i think it's the term form so now what
  6244. 3:22:26we're going to do is remember the
  6245. 3:22:28original problem was
  6246. 3:22:29get ad computer must filter
  6247. 3:22:34star pipe to get wmi object
  6248. 3:22:39win32 bios and it was this computer name
  6249. 3:22:43that we couldn't get a value for right
  6250. 3:22:45darn
  6251. 3:22:46okay so here's the deal
  6252. 3:22:49script block whenever you see the what
  6253. 3:22:51do you call them the the squigglies
  6254. 3:22:53squigglies
  6255. 3:22:54i like to see my hips myself but for
  6256. 3:22:56those who see the squigglies
  6257. 3:22:57that's called a script block that
  6258. 3:22:59represents code
  6259. 3:23:01if you give a script block
  6260. 3:23:04to a property to a parameter which
  6261. 3:23:07doesn't take a script block
  6262. 3:23:09then what it is is oh that you must be
  6263. 3:23:12asking for a
  6264. 3:23:13script parameter and what it does
  6265. 3:23:16is it takes the value of the current
  6266. 3:23:19object
  6267. 3:23:20assigns it to dollar sign under bar and
  6268. 3:23:23runs the script
  6269. 3:23:24and takes the value and puts it in there
  6270. 3:23:27oh this could be totally awesome and so
  6271. 3:23:29what you do is you say
  6272. 3:23:30dollar sign under bar dot was it was it
  6273. 3:23:32name it was name
  6274. 3:23:33name okay by the way you can do anything
  6275. 3:23:35you want here you could say two upper
  6276. 3:23:37or you know anything but here we just do
  6277. 3:23:40this
  6278. 3:23:40so again what's gonna happen is you're
  6279. 3:23:42going to run this
  6280. 3:23:44you're going to take the current object
  6281. 3:23:46you're going to assign it to
  6282. 3:23:47this and then you're going to run this
  6283. 3:23:50code
  6284. 3:23:50and so each object you're going to get
  6285. 3:23:52the value of the name
  6286. 3:23:54and then you're going to run this with
  6287. 3:23:57the value
  6288. 3:23:58was that crazy powerful you know you
  6289. 3:24:00realize that you've made that so much
  6290. 3:24:02easier that
  6291. 3:24:03there everybody's going to like you
  6292. 3:24:04better than they like me now because i
  6293. 3:24:06i drug them through this plan okay well
  6294. 3:24:09it worked because i took them through
  6295. 3:24:10that long thing
  6296. 3:24:11and then you just made it really short
  6297. 3:24:13and sweet so congratulations very nice
  6298. 3:24:15there you go so have fun with that so
  6299. 3:24:19folks
  6300. 3:24:19we're going to go ahead and take a 10
  6301. 3:24:20minute break when we come back we can
  6302. 3:24:22get some coffee
  6303. 3:24:23yeah oh yeah yeah give me some coffee
  6304. 3:24:24because i need more and um
  6305. 3:24:26we're going to go into something that is
  6306. 3:24:28going to change the way you manage
  6307. 3:24:30now you're going to take the tools that
  6308. 3:24:31you started to learn today and we're
  6309. 3:24:33going to get into
  6310. 3:24:34one of the most powerful things in the
  6311. 3:24:35world remoting and we want to talk to
  6312. 3:24:38jeffrey about remoting before we get
  6313. 3:24:39into it this is
  6314. 3:24:40totally awesome stuff so see you guys in
  6315. 3:24:4210 minutes
  6316. 3:25:00[Music]
  6317. 3:25:09we're back and i have to tell you we're
  6318. 3:25:11here to talk and this
  6319. 3:25:12now we're going to talk about one of my
  6320. 3:25:13most favorite things and you get to talk
  6321. 3:25:16about it
  6322. 3:25:17and we're going to do this twice guys
  6323. 3:25:18we're going to do kind of a short
  6324. 3:25:20section of this to get you started then
  6325. 3:25:21we're going to get into scripting
  6326. 3:25:23teach you about variables and stuff and
  6327. 3:25:24then hit remoting this topic
  6328. 3:25:27again with something called sessions
  6329. 3:25:29that'll be outstanding but
  6330. 3:25:31remoting this changed how i manage
  6331. 3:25:35in scale when it comes to the entire
  6332. 3:25:37windows uh
  6333. 3:25:38all the products the platform everything
  6334. 3:25:41this when it released with version two
  6335. 3:25:43literally made me a hero overnight so
  6336. 3:25:45you have to tell us about
  6337. 3:25:47what were you trying to solve with this
  6338. 3:25:49what does this thing do this is
  6339. 3:25:51unbelievable stuff yeah so in in
  6340. 3:25:53powershell we have this idea we called
  6341. 3:25:55it
  6342. 3:25:55we talked a lot about in the past we
  6343. 3:25:56don't talk so much about it now because
  6344. 3:25:58because we already delivered it
  6345. 3:26:00this notion of universal code execution
  6346. 3:26:02right which is to say that you have
  6347. 3:26:04code and sometimes you want to run the
  6348. 3:26:06code here
  6349. 3:26:07yeah that's what we do everything we've
  6350. 3:26:09been showing you today
  6351. 3:26:10we bring up a console window and we type
  6352. 3:26:13the code
  6353. 3:26:14and the code runs here but actually it's
  6354. 3:26:17a generalization
  6355. 3:26:18like here is a generalization or a
  6356. 3:26:20specialization of
  6357. 3:26:22anywhere like sometimes i want to run
  6358. 3:26:23the code there and sometimes i want to
  6359. 3:26:25run the code
  6360. 3:26:26there and sometimes i want to run the
  6361. 3:26:28code on those machines
  6362. 3:26:31and sometimes i want to run the code on
  6363. 3:26:32those machines as
  6364. 3:26:34myself and sometimes i want to give a
  6365. 3:26:36different set of credentials
  6366. 3:26:38and sometimes i want to run it and get
  6367. 3:26:40the results back immediately
  6368. 3:26:41and sometimes i want to run it and i'll
  6369. 3:26:43get the results back later
  6370. 3:26:45and sometimes i want to run it in a way
  6371. 3:26:46that uh um
  6372. 3:26:48i can do anything and sometimes i want
  6373. 3:26:50to run in an environment where
  6374. 3:26:52no no no these are and only these
  6375. 3:26:54commands you can run
  6376. 3:26:55secure environments and so there's this
  6377. 3:26:57notion of this
  6378. 3:26:58universal code execution model oh by the
  6379. 3:27:01way sorry the last one was
  6380. 3:27:02sometimes i want to run it i'm going to
  6381. 3:27:04run it for such a long time
  6382. 3:27:06that i might want to like shut down the
  6383. 3:27:07machine and bring it back up and have it
  6384. 3:27:10continue to run
  6385. 3:27:11right go somewhere else and maybe check
  6386. 3:27:13on it or something exactly
  6387. 3:27:14so this is the notion of the universal
  6388. 3:27:17uh
  6389. 3:27:18code execution model and remoting of
  6390. 3:27:20course is intrinsic to that
  6391. 3:27:22coupled with that are notions like jobs
  6392. 3:27:25jobs are things that run in the
  6393. 3:27:27background and then workflow which we
  6394. 3:27:29added in powershell version three which
  6395. 3:27:30is the idea that says hey i'm going to
  6396. 3:27:32run this
  6397. 3:27:33and at any stage after any command i can
  6398. 3:27:35suspend things
  6399. 3:27:37shut down the machine bring it back up
  6400. 3:27:40and continue
  6401. 3:27:41from where i started now see this sounds
  6402. 3:27:43awesome now what we had before is like
  6403. 3:27:45um
  6404. 3:27:45with like the remote server
  6405. 3:27:47administration tools i have a graphical
  6406. 3:27:48like active directory users and
  6407. 3:27:50computers
  6408. 3:27:50it will connect to a domain controller
  6409. 3:27:52over dcom using rpc
  6410. 3:27:54right and there's there's a lot of
  6411. 3:27:56challenges and problems with that
  6412. 3:27:57firewall challenges right
  6413. 3:27:59and all kinds of a mess but what you may
  6414. 3:28:02which
  6415. 3:28:02what you guys created though solves all
  6416. 3:28:05those
  6417. 3:28:06all those problems exactly so here's
  6418. 3:28:07what we did was first was we wanted to
  6419. 3:28:09solve all those problems so http
  6420. 3:28:11super important next was we already had
  6421. 3:28:14a pro protocol that went over http
  6422. 3:28:16our standards-based management so you
  6423. 3:28:18probably heard we talk a lot these days
  6424. 3:28:20about standards-based management
  6425. 3:28:22in fact you know what at tech heads and
  6426. 3:28:24such i'll show up i'll i'll bring up a
  6427. 3:28:26linux box
  6428. 3:28:27and i'll show how on a linux box i can
  6429. 3:28:29enumerate all the roles on a remote
  6430. 3:28:31windows server
  6431. 3:28:32and then install roles on a remote
  6432. 3:28:35windows server from a linux box i mean
  6433. 3:28:37just
  6434. 3:28:38crazy stuff right yeah i saw you do that
  6435. 3:28:41demonstration for the first time i think
  6436. 3:28:42it was like a year and a half ago and i
  6437. 3:28:43just went
  6438. 3:28:45just explode so this is because of this
  6439. 3:28:48standards and uh and when rm
  6440. 3:28:50the winram or ws management protocol
  6441. 3:28:52winner is our implementation of that
  6442. 3:28:54and so for powershell remote we leverage
  6443. 3:28:56winram
  6444. 3:28:58and we added streaming extensions to it
  6445. 3:29:01so that's how it works and when rm is
  6446. 3:29:03the service that you're going to see
  6447. 3:29:04that's that's running underneath all
  6448. 3:29:05that as a matter of fact i got a a
  6449. 3:29:07couple of slides
  6450. 3:29:08uh here and then we'll talk some more
  6451. 3:29:10about this if you take a look at the
  6452. 3:29:12slide here as an overview of remoting
  6453. 3:29:13basically what this comes down to
  6454. 3:29:15is you can go and touch
  6455. 3:29:18just as jeffrey went through the
  6456. 3:29:20scenarios using what you've already been
  6457. 3:29:22typing in at the console
  6458. 3:29:24locally you can pick that up and now
  6459. 3:29:26fire that
  6460. 3:29:27at whatever it is you want to fire it at
  6461. 3:29:29and it's over remoting which is going to
  6462. 3:29:31give us a lot of cool characteristics
  6463. 3:29:33it's going to be fast it's going to be
  6464. 3:29:35easy to cross
  6465. 3:29:36firewalls because we only have one port
  6466. 3:29:37to deal with and we're dealing with a
  6467. 3:29:39secured port so here's the idea if your
  6468. 3:29:41machines are in a domain
  6469. 3:29:43this isn't going over just http plain
  6470. 3:29:45text it's getting all encrypted
  6471. 3:29:47all encrypted with kerberos and then of
  6472. 3:29:49course if you're going across
  6473. 3:29:51the internet or across firewalls and you
  6474. 3:29:53want to put on ssl or if
  6475. 3:29:54you even want to do ssl internally you
  6476. 3:29:57can put on ssl you want that full
  6477. 3:30:00encrypted tunnel so well just be clear
  6478. 3:30:01we'll encrypt it twice we'll encrypt it
  6479. 3:30:03twice at that point yeah
  6480. 3:30:05if you really need it twice the
  6481. 3:30:06encrypted we'll do it twice um
  6482. 3:30:08but here's the idea is that you're
  6483. 3:30:10hitting whatever machines you want
  6484. 3:30:13securely and with what credentials you
  6485. 3:30:15want
  6486. 3:30:16and nobody can tell i mean nobody can
  6487. 3:30:18read it nobody can use a protocol
  6488. 3:30:20sniffer and sniff out what's going on so
  6489. 3:30:22this is actually
  6490. 3:30:23really cool stuff so you know there's
  6491. 3:30:25there's
  6492. 3:30:26enabling remoting is definitely
  6493. 3:30:30one of these things that that comes up
  6494. 3:30:31first of all we we just you know we just
  6495. 3:30:33need to tell everybody that
  6496. 3:30:35that you have to turn remoting on kind
  6497. 3:30:37of sort of maybe
  6498. 3:30:39kind of sort of maybe because um in
  6499. 3:30:42prior versions
  6500. 3:30:43not server 2012 but in prior versions
  6501. 3:30:45remoting had to be turned on and this
  6502. 3:30:46can actually be
  6503. 3:30:48kind of a hard conversation for some
  6504. 3:30:49security people to have or
  6505. 3:30:51some admins to have with their security
  6506. 3:30:52people in
  6507. 3:30:54in that i'm going to turn on this really
  6508. 3:30:55cool thing that lets me do whatever i
  6509. 3:30:57want to whatever i want the security guy
  6510. 3:30:59goes
  6511. 3:30:59no which is exactly what they should say
  6512. 3:31:02but as soon as they understand remoting
  6513. 3:31:05and how it works
  6514. 3:31:06all of a sudden it's like oh well this
  6515. 3:31:07is yeah this is perfectly fine yes
  6516. 3:31:09so there's this conversation that has to
  6517. 3:31:11have to get it turned on
  6518. 3:31:13if you guys take a look at the the slide
  6519. 3:31:15here
  6520. 3:31:16what i've done is i've shown you a basic
  6521. 3:31:18way to turn it on i'm actually going to
  6522. 3:31:20demonstrate this on one of my machines
  6523. 3:31:22here
  6524. 3:31:22but there's a commandlet that you can
  6525. 3:31:24you can turn that you can use called
  6526. 3:31:25enable dash ps remoting
  6527. 3:31:28and now you can you want to walk around
  6528. 3:31:30to all of your servers and type enable
  6529. 3:31:32ps remoting
  6530. 3:31:33knock yourself out but there's a group
  6531. 3:31:36policy and i have it written down here
  6532. 3:31:37for you
  6533. 3:31:38it's much easier if you use the group
  6534. 3:31:40policy to enable remoting
  6535. 3:31:42but here's the deal you have to turn
  6536. 3:31:45this on let me say it again
  6537. 3:31:49you have to turn this on
  6538. 3:31:53i'm we're going to show you all these
  6539. 3:31:54great features but none of it's going to
  6540. 3:31:56work until you turn on remoting
  6541. 3:31:58it's not necessarily an easy
  6542. 3:31:59conversation there's a free ebook
  6543. 3:32:01on powershell.org secrets about remoting
  6544. 3:32:04yeah great book which will take give you
  6545. 3:32:07not only take you through every possible
  6546. 3:32:08scenario
  6547. 3:32:09but will is the information that your
  6548. 3:32:11security guys need to know
  6549. 3:32:13so that they understand that it's
  6550. 3:32:14secured and what ports it uses
  6551. 3:32:18this has to be turned on it's not
  6552. 3:32:20because i'm just saying it it's because
  6553. 3:32:21you're running out of options now
  6554. 3:32:23a lot of the new administrative
  6555. 3:32:25graphical tools are made
  6556. 3:32:27to use powershell and powershell
  6557. 3:32:29remoting server 2012 is a great example
  6558. 3:32:32of the new server manager right it's
  6559. 3:32:33using
  6560. 3:32:34all of these capabilities that are built
  6561. 3:32:36in and if you don't have it turned on
  6562. 3:32:38you can't manage anything with anything
  6563. 3:32:41so you've got to get it turned on and as
  6564. 3:32:43a side note
  6565. 3:32:44server 2012 it's turned on by default
  6566. 3:32:48oh yeah so it's gonna get turned on just
  6567. 3:32:51to be clear on that one
  6568. 3:32:52so as you know uh uh we are secure by
  6569. 3:32:55default and released by release
  6570. 3:32:57we continue to shut things off by
  6571. 3:32:59default and
  6572. 3:33:00you have to turn them on uh in the
  6573. 3:33:02course this has been going on for quite
  6574. 3:33:04a number of years
  6575. 3:33:05been exactly to my knowledge one time
  6576. 3:33:08where we went the other direction
  6577. 3:33:09where we turned something on by default
  6578. 3:33:11instead of off by default
  6579. 3:33:13and that was uh power it's got to be
  6580. 3:33:15powershell remote
  6581. 3:33:16shell remoting that's right so for
  6582. 3:33:17windows server 2012 we turned on
  6583. 3:33:20powershell remoting
  6584. 3:33:21it was a big issue the security security
  6585. 3:33:23guys are like
  6586. 3:33:24what are you talking about maybe you
  6587. 3:33:26didn't get the memo we're going the
  6588. 3:33:27other direction
  6589. 3:33:28it's like okay well let's talk about
  6590. 3:33:30that why is that and the answer is of
  6591. 3:33:32course windows server 2012
  6592. 3:33:34right it is a cloud operating system a
  6593. 3:33:36cloud operating system says hey it's not
  6594. 3:33:38about this server it's about
  6595. 3:33:40these servers i need to be able to
  6596. 3:33:42manage things and therefore remoting of
  6597. 3:33:44large numbers of systems is critical
  6598. 3:33:46function it is the core
  6599. 3:33:47of a cloud os and so they said okay well
  6600. 3:33:50i'm willing to entertain that i mean
  6601. 3:33:52that makes sense
  6602. 3:33:53but we got to be sure and say okay well
  6603. 3:33:54let's walk through it and we showed them
  6604. 3:33:56all the things that we had done
  6605. 3:33:57actually they've been involved all along
  6606. 3:33:59uh and step by step by step we went and
  6607. 3:34:01did the threat analysis and they were
  6608. 3:34:02convinced yeah
  6609. 3:34:03this is safe to do and so when you have
  6610. 3:34:06that conversation with your security
  6611. 3:34:07guys
  6612. 3:34:08you just point to that and the history
  6613. 3:34:10of this environment this
  6614. 3:34:12server one time we switch and turn
  6615. 3:34:14things on by default it is
  6616. 3:34:16powershell remoting so go for it yeah
  6617. 3:34:19and i think that's a really great
  6618. 3:34:20concept because microsoft's not going to
  6619. 3:34:21turn on something
  6620. 3:34:22that is a an easy to use attack surface
  6621. 3:34:25it's just not going to happen so we put
  6622. 3:34:27an extraordinary amount into the
  6623. 3:34:29security of making sure that this is
  6624. 3:34:31going to be secure environment
  6625. 3:34:32we've got pen testers who've been
  6626. 3:34:34evaluating the design
  6627. 3:34:36the code etc we spent a lot
  6628. 3:34:39look we started powershell after bill
  6629. 3:34:42gates
  6630. 3:34:43his famous um security memo yeah
  6631. 3:34:46right so and and what started that
  6632. 3:34:48security member what started that whole
  6633. 3:34:50bufferama
  6634. 3:34:51i love you i love you man.vbs oh you're
  6635. 3:34:54talking about that i was just saying i
  6636. 3:34:56love you man i'm
  6637. 3:34:57sorry oh that's special okay okay
  6638. 3:35:00there's anything wrong with that no it
  6639. 3:35:03was
  6640. 3:35:03it was scripting scripting had caused
  6641. 3:35:05that big i love you
  6642. 3:35:06mass and so we knew that scripting was
  6643. 3:35:09going to be a key
  6644. 3:35:10vector so we just spent a ton of time
  6645. 3:35:13making sure we were secure secure secure
  6646. 3:35:16so now that we've jumped up and down
  6647. 3:35:18enough that you not only have to turn
  6648. 3:35:20this on but it's secured to have it
  6649. 3:35:21turned on
  6650. 3:35:22get it turned on let's start to show you
  6651. 3:35:24some of the cool things that you can do
  6652. 3:35:25now like i said we're going to hit this
  6653. 3:35:26topic twice
  6654. 3:35:27as we learn more and more about it so we
  6655. 3:35:29this is all in the slides but
  6656. 3:35:31um let me take you through here and as
  6657. 3:35:33soon as i can
  6658. 3:35:35there we go
  6659. 3:35:38well maybe not quite i can do something
  6660. 3:35:42i think you have control of my machine
  6661. 3:35:44no i keep it up
  6662. 3:35:46okay my machine is just moving slow for
  6663. 3:35:48a second i don't oh here we go okay
  6664. 3:35:50so let me do something real quick and
  6665. 3:35:52jeffrey please jump in
  6666. 3:35:53first of all i'm going to do what's
  6667. 3:35:54called a one-to-one connection this is
  6668. 3:35:56in
  6669. 3:35:56you'll see exactly watch i'm going to
  6670. 3:35:58type in enter it's a commandment
  6671. 3:36:00ps session powershell session and i'm
  6672. 3:36:03going to put in a computer name that i
  6673. 3:36:05want to go to
  6674. 3:36:06i'm just going to say dc it's one of the
  6675. 3:36:07vms that i have running
  6676. 3:36:09watch what happens to my prompt here you
  6677. 3:36:12see what happened
  6678. 3:36:14guess guess where i'm sitting right now
  6679. 3:36:17guess
  6680. 3:36:18where i am right now i'm on the dc
  6681. 3:36:22i'm on the dc you don't believe me watch
  6682. 3:36:25i i'm going to clean up this path a
  6683. 3:36:27little bit
  6684. 3:36:28watch host name
  6685. 3:36:32and i'll do ipconfig that information is
  6686. 3:36:35coming from the dc
  6687. 3:36:37so i can actually do a one-to-one
  6688. 3:36:39connection and i can troubleshoot and i
  6689. 3:36:40can manage
  6690. 3:36:42a single system this way as if i was
  6691. 3:36:44sitting on there as a matter of fact
  6692. 3:36:46think of this as a secure telnet a
  6693. 3:36:48secured telnet i love that and
  6694. 3:36:50and here's let me show you why i think
  6695. 3:36:52that this is also so important
  6696. 3:36:54that you just get used to managing
  6697. 3:36:56servers when you just need to do one
  6698. 3:36:57thing to one server this is a great way
  6699. 3:36:59to do it
  6700. 3:37:00get used to this because i have you guys
  6701. 3:37:02seen um server 2012 let me exit out of
  6702. 3:37:05this and let me just show you
  6703. 3:37:06um i'm going to go out to uh
  6704. 3:37:10my domain controller and we're going to
  6705. 3:37:11show you uh server 2012. um
  6706. 3:37:14this is uh to me fascinating um
  6707. 3:37:18welcome aboard there it is by the way
  6708. 3:37:22what you guys did with the color scheme
  6709. 3:37:23on here is awesome
  6710. 3:37:25yeah the background the color scheme
  6711. 3:37:27this is totally
  6712. 3:37:28totally awesome like in its simplicity
  6713. 3:37:30it's very zen like in its simplicity
  6714. 3:37:32yep you guys probably figured out that
  6715. 3:37:34this is definitely this is
  6716. 3:37:36you know we used to call refer to this
  6717. 3:37:38as the core installation and yeah with
  6718. 3:37:40server 2012 this is now the
  6719. 3:37:42default installation so and for a good
  6720. 3:37:45reason
  6721. 3:37:46performance security all that kind of
  6722. 3:37:49stuff so
  6723. 3:37:51let me show you you would be managing
  6724. 3:37:53the server that way
  6725. 3:37:54anyways and i don't want to screw this
  6726. 3:37:56up so let me get rid of him
  6727. 3:37:58there we go so doing that single session
  6728. 3:38:02that enter ps session to a machine that
  6729. 3:38:04you want to do work on it gives you that
  6730. 3:38:06one-to-one connection and you can now do
  6731. 3:38:08whatever you want on that machine
  6732. 3:38:10but here's the big one and so let me
  6733. 3:38:13exit this
  6734. 3:38:15you guys been watching all day long and
  6735. 3:38:16you know you're going to be doing a lot
  6736. 3:38:18of good hard work on stuff like this i
  6737. 3:38:19want to do get event log
  6738. 3:38:21log name system
  6739. 3:38:24and i'm just going to do newest three
  6740. 3:38:27now i could do entry type
  6741. 3:38:28and all this other stuff but i just want
  6742. 3:38:30to keep it short and simple because
  6743. 3:38:32let me just show you i'm going to take
  6744. 3:38:33this and i'm going to copy this what i
  6745. 3:38:35can get to work
  6746. 3:38:36here and what jeffrey was saying is the
  6747. 3:38:39whole point is
  6748. 3:38:40we'll work anywhere so here's what i'm
  6749. 3:38:42going to do
  6750. 3:38:43i'm going to invoke
  6751. 3:38:47command this is a remoting command
  6752. 3:38:50what computers when you use this dash
  6753. 3:38:53computer name
  6754. 3:38:54it's using powershell remoting not the
  6755. 3:38:56old dcom rpc stuff which is what a lot
  6756. 3:38:59of the older commandlets use so this
  6757. 3:39:00one's using the good stuff
  6758. 3:39:02and then whatever you put in the
  6759. 3:39:05squigglies is exactly what we're going
  6760. 3:39:06to do
  6761. 3:39:07oops sorry wait a minute put in some
  6762. 3:39:10computer names and i'm going to be brave
  6763. 3:39:12and risky whatever you put in the
  6764. 3:39:15squigglies
  6765. 3:39:16is exactly what we're going to do and in
  6766. 3:39:18this case
  6767. 3:39:20watch boom
  6768. 3:39:23so over remoting we've was that was that
  6769. 3:39:26was that approval back there that we
  6770. 3:39:27heard a knock or something uh
  6771. 3:39:30that i want you to get that what just
  6772. 3:39:32happened is by using powershell remoting
  6773. 3:39:34i just hit
  6774. 3:39:35three different systems all at the same
  6775. 3:39:37time and said give me this information i
  6776. 3:39:39can now
  6777. 3:39:40convert this i can put it to a file i
  6778. 3:39:42can put it to a web page whatever it is
  6779. 3:39:43i want to do with it
  6780. 3:39:45but i just used powershell remoting and
  6781. 3:39:47i and
  6782. 3:39:48and and jeffrey this is actually so
  6783. 3:39:50powerful that
  6784. 3:39:51admins need to be a little careful right
  6785. 3:39:53because things like
  6786. 3:39:55um uh computer oh yeah that's a good one
  6787. 3:39:58um
  6788. 3:39:59restart computer all of a sudden take on
  6789. 3:40:02a whole new dimension
  6790. 3:40:04because whatever you fill that with
  6791. 3:40:06that's what it's going to do
  6792. 3:40:08dash computer name i can be grabbing the
  6793. 3:40:09computers from active directory a csv
  6794. 3:40:11file a text file making me nervous man i
  6795. 3:40:14know at the moment i'm actually very
  6796. 3:40:15nervous too i need to get rid of that so
  6797. 3:40:17that's
  6798. 3:40:17actually nice and so it's going to
  6799. 3:40:20restart those machines
  6800. 3:40:22so this is a one-to-many connection now
  6801. 3:40:25jeffrey one of the
  6802. 3:40:25things that comes up all the time is if
  6803. 3:40:27i do get service i'll do name bits
  6804. 3:40:30how's this working i mean it's it's
  6805. 3:40:32actually sending the commands to the
  6806. 3:40:34machine
  6807. 3:40:34and then how am i getting this data back
  6808. 3:40:36yeah so literally what happens is we go
  6809. 3:40:38and we create a connection to that
  6810. 3:40:40remote machine
  6811. 3:40:41right so there's a tcp connection we
  6812. 3:40:44then
  6813. 3:40:45fire up a powershell connection we
  6814. 3:40:48load.net we load powershell
  6815. 3:40:50we take that code and we squirt it
  6816. 3:40:53across the wire
  6817. 3:40:54we then execute it you know we logged
  6818. 3:40:56you in
  6819. 3:40:57use your credentials to log you in we
  6820. 3:40:59then execute the code there
  6821. 3:41:01and then we get those objects and we
  6822. 3:41:03serialize those objects
  6823. 3:41:06we move them across the wire and then we
  6824. 3:41:08reconstitute them we deserialize them
  6825. 3:41:11and emit them as though they happen here
  6826. 3:41:13okay okay so let me see if i get this
  6827. 3:41:14straight because you're gonna have to
  6828. 3:41:15explain the serialization
  6829. 3:41:16yes let me see if i can get this
  6830. 3:41:18straight so we're connecting to these
  6831. 3:41:19remote
  6832. 3:41:19machines and we're actually starting a
  6833. 3:41:21power shell session
  6834. 3:41:22on those machines and having the command
  6835. 3:41:25run
  6836. 3:41:26on those machines so it's not my
  6837. 3:41:28computer working harder it's those
  6838. 3:41:29machines that are doing the work
  6839. 3:41:31yep now the serialization you're
  6840. 3:41:33squirting this stuff back
  6841. 3:41:34serializes serialize deserialize
  6842. 3:41:38what does this mean exactly so what we
  6843. 3:41:40do is we we take the object
  6844. 3:41:42and we transform it into something that
  6845. 3:41:45can be moved around
  6846. 3:41:46and reconstructed anywhere okay okay so
  6847. 3:41:49concretely i mean anywhere like i'm over
  6848. 3:41:52here
  6849. 3:41:53i go talk to your machine and it's
  6850. 3:41:55windows talking.net
  6851. 3:41:56and then i could bring it over here and
  6852. 3:41:58it could be linux now there's no
  6853. 3:42:00net on linux so how's that going to work
  6854. 3:42:02right and so i've got to serialize it
  6855. 3:42:04into something that can work
  6856. 3:42:05anywhere now imagine i go and i say well
  6857. 3:42:08hey i
  6858. 3:42:08talk to exchange version whatever
  6859. 3:42:12and i get the objects here but i don't
  6860. 3:42:14have exchange here
  6861. 3:42:16so how do i recreate exchange objects
  6862. 3:42:18again that's the problem so what we do
  6863. 3:42:20is we take these objects
  6864. 3:42:22and we turn them into essentially a
  6865. 3:42:23property bag you know just a bag
  6866. 3:42:26of properties and then we take them and
  6867. 3:42:28you know the properties have names
  6868. 3:42:30and values and the values have types now
  6869. 3:42:32here's the trick
  6870. 3:42:34the types are not the infinite set of
  6871. 3:42:36types
  6872. 3:42:37there right if you tried to do that it
  6873. 3:42:39would never work
  6874. 3:42:40so what we do is we render it down to a
  6875. 3:42:42set of i think 26 or so
  6876. 3:42:44types which you know i put my badge on
  6877. 3:42:46the table and i say if this
  6878. 3:42:48i guarantee that these will always work
  6879. 3:42:50if these don't work
  6880. 3:42:51fire me well there you go forever
  6881. 3:42:54forever because you know what
  6882. 3:42:55um a uh an exchange
  6883. 3:42:59uh mailbox 30 years from now probably
  6884. 3:43:02going to change
  6885. 3:43:03but i'll guarantee you this a 64-bit
  6886. 3:43:05integer isn't going to change
  6887. 3:43:0630 years from now yeah right so it's
  6888. 3:43:08those type of things
  6889. 3:43:10integers strings uh ins guides
  6890. 3:43:13things like that are going to be yeah
  6891. 3:43:16the same
  6892. 3:43:17exactly so then i take that property bag
  6893. 3:43:19and i just uh
  6894. 3:43:20uh turn it into xml i then bring it over
  6895. 3:43:23here and then i reconstruct the property
  6896. 3:43:24back
  6897. 3:43:25and so in fact here do do the by the way
  6898. 3:43:28uh let me correct something
  6899. 3:43:29show your screen okay okay so you said
  6900. 3:43:32that this was
  6901. 3:43:33remoting in fact invoke command is not
  6902. 3:43:35remoting
  6903. 3:43:36well what is it command is the way we do
  6904. 3:43:39everything
  6905. 3:43:40remember we have this kind of underlying
  6906. 3:43:42system and then we've got
  6907. 3:43:43we've got a great syntactic syntax
  6908. 3:43:45syntax
  6909. 3:43:46sugar on top of it so go remove the
  6910. 3:43:48minus computer name
  6911. 3:43:50so let's do this yeah well that whole dc
  6912. 3:43:54one two three
  6913. 3:43:55dc get rid of that
  6914. 3:43:59okay and hit care to turn okay okay
  6915. 3:44:02so that worked locally and that's the
  6916. 3:44:04same as is if you hadn't typed
  6917. 3:44:06invoke command and squiggle brackets or
  6918. 3:44:08rather say when you just type get
  6919. 3:44:10service minus name
  6920. 3:44:11bits we transform it into this and then
  6921. 3:44:14we run it
  6922. 3:44:15and then we run it and that's that
  6923. 3:44:17universe this is the universal code
  6924. 3:44:19execution
  6925. 3:44:20and this is this is what makes it so
  6926. 3:44:22easy for especially if you're an
  6927. 3:44:23administrator
  6928. 3:44:24you work out what you want first
  6929. 3:44:28then you can just put it in the
  6930. 3:44:30squigglies and it's going to work at the
  6931. 3:44:31other side
  6932. 3:44:32exactly so from here pipe that to
  6933. 3:44:34[Music]
  6934. 3:44:36put that to get member okay and scroll
  6935. 3:44:40up
  6936. 3:44:42and what do we have we've got a service
  6937. 3:44:45no look at the beginning
  6938. 3:44:47system system dot service process that's
  6939. 3:44:50service control
  6940. 3:44:52now add a computer name to that line
  6941. 3:44:55oh yeah so let's do this let's have it
  6942. 3:44:58go to
  6943. 3:44:59uh let's do uh dash comp and
  6944. 3:45:02dc one okay this one yeah whatever
  6945. 3:45:05now go on look at the beginning
  6946. 3:45:09it's seriously serialized ding ding ding
  6947. 3:45:11ding ding now
  6948. 3:45:12a de-serialized object is incredibly
  6949. 3:45:15powerful
  6950. 3:45:16but it's different okay so if you scroll
  6951. 3:45:18up a bit
  6952. 3:45:20oh i'm scroll down did you did you just
  6953. 3:45:22clear
  6954. 3:45:23you didn't clear i did a clear okay
  6955. 3:45:26don't do it clear and and do it again do
  6956. 3:45:28the local command
  6957. 3:45:32okay notice see these methods right okay
  6958. 3:45:35see the start and the stop method top
  6959. 3:45:37yeah okay
  6960. 3:45:38that's because it's a live object and
  6961. 3:45:41you can do methods on it
  6962. 3:45:42go up to the deserialized one yeah it's
  6963. 3:45:45it's it's there's there's just one
  6964. 3:45:47method two strength or two strings
  6965. 3:45:49exactly because the object itself is
  6966. 3:45:51gone and what you have is a represent
  6967. 3:45:54representation of the object now it
  6968. 3:45:56turns out that that's
  6969. 3:45:57extraordinarily powerful now some people
  6970. 3:45:59say oh well it should be the same
  6971. 3:46:00everywhere no
  6972. 3:46:01no no my friends it shouldn't be the
  6973. 3:46:03point is that because we have this
  6974. 3:46:05this live deserialized
  6975. 3:46:09concept what it means is that when i'm
  6976. 3:46:11over there i'm able to take advantage of
  6977. 3:46:13the
  6978. 3:46:13remote i'm able to take advantage of the
  6979. 3:46:16full richness of the object system
  6980. 3:46:18be able to do everything in a very
  6981. 3:46:20lightweight way
  6982. 3:46:21very high performance low latency way
  6983. 3:46:24and then
  6984. 3:46:25when i bring it over here i can still do
  6985. 3:46:27a ton of stuff but i can't do that so
  6986. 3:46:28the way we refer to this is
  6987. 3:46:32islands of optimization in a sea
  6988. 3:46:35of interoperability okay let's islands
  6989. 3:46:38of
  6990. 3:46:38optimization in a sea of
  6991. 3:46:41interoperability of interoperability
  6992. 3:46:43which is to say
  6993. 3:46:44it's it's it's poetic
  6994. 3:46:45[Laughter]
  6995. 3:46:47so what that means is i can go to any of
  6996. 3:46:49the machines and i can interoperate i'm
  6997. 3:46:50guaranteed to do that
  6998. 3:46:52and then there are times however when
  6999. 3:46:54i'm doing all the code on one machine
  7000. 3:46:57that i can optimize i have the live
  7001. 3:46:59objects i can do things etc
  7002. 3:47:01and that by the way is what allows us to
  7003. 3:47:02do the gui layering guise on top of
  7004. 3:47:05powershell
  7005. 3:47:06because we can have these nice high
  7006. 3:47:09speed low latency
  7007. 3:47:12activities if you tried to layer
  7008. 3:47:14everything on top of a deserialized
  7009. 3:47:16object
  7010. 3:47:17you got a lot of recreating objects a
  7011. 3:47:20lot of inefficiency
  7012. 3:47:21right right yeah well guys this is our
  7013. 3:47:24first hit into remoting so we did
  7014. 3:47:27one-to-one
  7015. 3:47:28we did one-to-many now we've got more
  7016. 3:47:30remoting to do because
  7017. 3:47:32we're just getting started with the
  7018. 3:47:33remoting but now
  7019. 3:47:35it's getting for that time for us to
  7020. 3:47:38oh you know before we get into scripting
  7021. 3:47:41i just oh no we gotta show more here
  7022. 3:47:43no yeah i know there's a problem i have
  7023. 3:47:46yeah
  7024. 3:47:46this is cool but you know one of the
  7025. 3:47:49problems i have
  7026. 3:47:50i know a few of the problems
  7027. 3:47:54one of the one of the things i run into
  7028. 3:47:56is
  7029. 3:47:58wouldn't it be cool if you know when i
  7030. 3:48:01go on vacation i don't know about you
  7031. 3:48:03but i like to go places with beaches
  7032. 3:48:04oh yeah that have they have the the the
  7033. 3:48:07little drinks with the little umbrellas
  7034. 3:48:09in them
  7035. 3:48:09and when i'm sitting on the beach the
  7036. 3:48:11last thing that i'm gonna have is a
  7037. 3:48:13laptop
  7038. 3:48:14yeah right that's something not not cool
  7039. 3:48:16not cool at all
  7040. 3:48:17but things still do go wrong back at the
  7041. 3:48:20office and so
  7042. 3:48:21i am going to have a phone yep
  7043. 3:48:25ah i see where you're going wouldn't it
  7044. 3:48:29be
  7045. 3:48:29you know it'd be so cool if i could
  7046. 3:48:33maybe have powershell here
  7047. 3:48:37and i could launch a script which we're
  7048. 3:48:40going to be doing this afternoon or i
  7049. 3:48:41could
  7050. 3:48:42type in these commands and i could do
  7051. 3:48:43all of this
  7052. 3:48:45kind of cool stuff it would be so cool
  7053. 3:48:48if i had powershell here or on a tablet
  7054. 3:48:50if if only if only you had powershell
  7055. 3:48:53version 3.
  7056. 3:48:54if only you had powershell version three
  7057. 3:48:56and
  7058. 3:48:57at least one server 2012 box yeah it
  7059. 3:49:00could be a vm
  7060. 3:49:01but i want to show you something kind of
  7061. 3:49:02cool have you picked up on the fact that
  7062. 3:49:04we're big fans of powershell version
  7063. 3:49:05three
  7064. 3:49:06yeah we're huge fans of powershell v3 so
  7065. 3:49:09guys i want you to watch something i'm
  7066. 3:49:10actually going to take you through this
  7067. 3:49:11is kind of a cute review not a cute
  7068. 3:49:13review i can't believe i said the word
  7069. 3:49:14cute this is a review
  7070. 3:49:15over what we started off with today
  7071. 3:49:18discovering
  7072. 3:49:19and utilizing commandlets and in this
  7073. 3:49:21case
  7074. 3:49:22using a feature that i think is just
  7075. 3:49:23wickedly awesome so here's what i'm
  7076. 3:49:25going to do
  7077. 3:49:26i'm going to use powershell remote or
  7078. 3:49:28i'm going to enter a ps session to
  7079. 3:49:30a server i have out there called pwa now
  7080. 3:49:32this server
  7081. 3:49:33doesn't really have anything on it it's
  7082. 3:49:34just a generic server 2012
  7083. 3:49:37box key is 2012. it could be a vm
  7084. 3:49:40somewhere but it's
  7085. 3:49:41got to be 2012. what i'm going to do is
  7086. 3:49:44there's commandlet out there called get
  7087. 3:49:46windows feature
  7088. 3:49:48get windows feature is part of the
  7089. 3:49:49server manager module
  7090. 3:49:51what it does is it lists for you all of
  7091. 3:49:54your roles and features for your server
  7092. 3:49:56and if there are x's in it i know i love
  7093. 3:49:58it when
  7094. 3:49:59if there's an x that means it's
  7095. 3:50:01installed if there's not an x
  7096. 3:50:03it's not installed well i'm going to use
  7097. 3:50:05this commandlet to
  7098. 3:50:06see if there's a feature
  7099. 3:50:10what features are available for
  7100. 3:50:12powershell and in server 2012 we have
  7101. 3:50:15something down here at the bottom called
  7102. 3:50:17powershell web access i'm about to
  7103. 3:50:19change
  7104. 3:50:22the world as well and it's not me who
  7105. 3:50:24i'm
  7106. 3:50:25the only thing that i'm changing is i'm
  7107. 3:50:26showing you how to set it up
  7108. 3:50:28you're the one that changed the world so
  7109. 3:50:30the team the team the team
  7110. 3:50:31so yeah the team the team um so it's
  7111. 3:50:34called windows powershell web access
  7112. 3:50:36and this is pretty cool so i want to
  7113. 3:50:38install this
  7114. 3:50:39so we have this install windows feature
  7115. 3:50:42commandlet that'll let me install
  7116. 3:50:43windows powershell web
  7117. 3:50:47access i've used git help i can
  7118. 3:50:50the install windows feature will let me
  7119. 3:50:52choose whatever thing i want to install
  7120. 3:50:53and away it goes now here's what it's
  7121. 3:50:55going to do
  7122. 3:50:56[Music]
  7123. 3:50:58it's going to install iis because this
  7124. 3:51:02is going to be a web
  7125. 3:51:03thing so it's going to install iis we
  7126. 3:51:05have net 45 on here and its server 2012.
  7127. 3:51:10when it gets this installed we'll also
  7128. 3:51:12get a new module
  7129. 3:51:13with some additional commands six
  7130. 3:51:16additional command lines so what we're
  7131. 3:51:17gonna do is use get help to find them
  7132. 3:51:19and then use them because in like three
  7133. 3:51:22steps i'm gonna have one of these
  7134. 3:51:23coolest features in the world turned on
  7135. 3:51:25so watch i'm gonna clear my screen this
  7136. 3:51:27is just let me know they have my updates
  7137. 3:51:29turned off which
  7138. 3:51:30it's a vm right now it does but it was
  7139. 3:51:31it exited with success
  7140. 3:51:33no restart needed awesome so
  7141. 3:51:36clear my screen and guys notice i'm
  7142. 3:51:38doing this all on a different server
  7143. 3:51:39right so
  7144. 3:51:40how cool is that yeah i know this is
  7145. 3:51:42totally wickedly cool
  7146. 3:51:43so um i'm going to do github it's not
  7147. 3:51:46your dad's server
  7148. 3:51:47this is not your daddy i love that
  7149. 3:51:50so it's it's called powershell web
  7150. 3:51:52access so pswa a lot of us just refer to
  7151. 3:51:55it as pwa powershell web access but
  7152. 3:51:58pswa and you can see there's six
  7153. 3:52:00commandlets by looking at the verbs you
  7154. 3:52:02could probably figure out
  7155. 3:52:03the first place i'm gonna go is to
  7156. 3:52:05install
  7157. 3:52:07a powershell web access application
  7158. 3:52:09technically what's gonna happen is we're
  7159. 3:52:11going to create
  7160. 3:52:12a a a web application by default off of
  7161. 3:52:16the default website
  7162. 3:52:18when we installed iis now we didn't need
  7163. 3:52:20to install it that happened for us
  7164. 3:52:22automatically
  7165. 3:52:23you can alter these defaults but i'm
  7166. 3:52:25just going to take the defaults
  7167. 3:52:26for right now now so install
  7168. 3:52:30pswa and i'm going to
  7169. 3:52:33you've got to use https for this because
  7170. 3:52:36this is going to be something that you
  7171. 3:52:37hit from
  7172. 3:52:38anywhere in the world back to your home
  7173. 3:52:42so we're going to need https you can't
  7174. 3:52:44do this with http
  7175. 3:52:46now if you don't have a good certificate
  7176. 3:52:48to put on
  7177. 3:52:49your web box right now for testing
  7178. 3:52:52purposes
  7179. 3:52:53they have this option of use a test
  7180. 3:52:55certificate now i
  7181. 3:52:56screened my screen freaked out a little
  7182. 3:52:57bit but use a test certificate it's
  7183. 3:52:59going to put on a temporary cert just
  7184. 3:53:01remember this is not the cert that you
  7185. 3:53:04want when you go to production so
  7186. 3:53:07what's going to happen is is that it
  7187. 3:53:08creates in iis terms an application pool
  7188. 3:53:11for the web app creates the web app
  7189. 3:53:13points the web app to where the files
  7190. 3:53:15are and we're almost ready to go
  7191. 3:53:19we just now have to tell it who's
  7192. 3:53:20allowed to use this now
  7193. 3:53:22this is going to be one of those rare do
  7194. 3:53:24as i say not as i do
  7195. 3:53:27and let me tell you why because i'm
  7196. 3:53:29going to do get help again on
  7197. 3:53:30on pswa we need to create
  7198. 3:53:34who's allowed to use this and what
  7199. 3:53:36they're allowed to go to when they use
  7200. 3:53:38this
  7201. 3:53:40so we need to add rules and you're going
  7202. 3:53:41to want to add granular rules that make
  7203. 3:53:43sense in other words
  7204. 3:53:45is there a group of administrators that
  7205. 3:53:46you want to be able to have remoting
  7206. 3:53:48or to have powershell web access and
  7207. 3:53:51what machine
  7208. 3:53:52should they be allowed to get to or
  7209. 3:53:55remote to when they use this
  7210. 3:53:57you're going to want to keep control on
  7211. 3:53:59this you're not going to want to do what
  7212. 3:54:00i'm going to do just for easy sex so let
  7213. 3:54:02me show you how to
  7214. 3:54:04what you're looking for here so add
  7215. 3:54:07a pswa uh authorization rule and let me
  7216. 3:54:11just show you
  7217. 3:54:13uh what computers do you want to be able
  7218. 3:54:16to remote to
  7219. 3:54:17so you can make this list you can create
  7220. 3:54:18it as a computer group you also have
  7221. 3:54:21another parameter you're going to need
  7222. 3:54:22is either by
  7223. 3:54:24user group or user name who's allowed to
  7224. 3:54:27use this so you're going to want to fill
  7225. 3:54:28out the username
  7226. 3:54:29what computer and we're not going to get
  7227. 3:54:31a chance to do
  7228. 3:54:34different kinds of configurations but
  7229. 3:54:36you can control
  7230. 3:54:38through different configurations what
  7231. 3:54:39command lets a person is allowed to use
  7232. 3:54:41when they get there
  7233. 3:54:42which is actually totally cool these
  7234. 3:54:45three things
  7235. 3:54:46you need to specify just be clear that's
  7236. 3:54:48for things like
  7237. 3:54:49hey i'm going to let um these people
  7238. 3:54:51come into these machines
  7239. 3:54:53and all they can do is read only
  7240. 3:54:54operations
  7241. 3:54:56like they can do gets they can't do sets
  7242. 3:54:58and then
  7243. 3:54:59this guy on these machines he can reboot
  7244. 3:55:02the machine
  7245. 3:55:03okay but he can't read data things like
  7246. 3:55:06that and that's a really important point
  7247. 3:55:08is that
  7248. 3:55:08these users i've got administrators that
  7249. 3:55:10have full capabilities but i got a guy
  7250. 3:55:12who's a lot of reset passwords when he
  7251. 3:55:14gets there
  7252. 3:55:15that kind of stuff that you can control
  7253. 3:55:17don't
  7254. 3:55:18do what i'm about to do in real life if
  7255. 3:55:20you're just testing on a vm that's fine
  7256. 3:55:22but what i'm going to do is i'm for
  7257. 3:55:23those three parameters i'm going to do
  7258. 3:55:24star
  7259. 3:55:25star star yeah i know i know that means
  7260. 3:55:29everybody can do anything to everybody
  7261. 3:55:30and it's just
  7262. 3:55:31it's just lullable it's just yeah not
  7263. 3:55:34not cool but
  7264. 3:55:35for demonstration first summer of love
  7265. 3:55:38the summer of
  7266. 3:55:39love at this point
  7267. 3:55:42i installed the feature i ins
  7268. 3:55:45i i i installed the web app and i have
  7269. 3:55:48now created a rule
  7270. 3:55:51anarchy anarchy
  7271. 3:55:55this is so so freaky cool guys this is
  7272. 3:55:57um let me exit out of that machine
  7273. 3:55:59this is so freaky cool that i'm going to
  7274. 3:56:02uh this is start process i'm going to
  7275. 3:56:04use the
  7276. 3:56:04alias start and i'm going to start i
  7277. 3:56:06explore
  7278. 3:56:08with https and i'm going to go to that
  7279. 3:56:11powershell web access box the box i just
  7280. 3:56:13set up
  7281. 3:56:16pwa and it's going to go to the default
  7282. 3:56:19website and there's a web application
  7283. 3:56:22underneath the default called pswa
  7284. 3:56:25you can of course alter all this to make
  7285. 3:56:27it cleaner but watch what happens
  7286. 3:56:30secured site a matter of fact let me
  7287. 3:56:32make this just a little bit
  7288. 3:56:33zoomier sooner zoomier
  7289. 3:56:37so this is the temporary certificate
  7290. 3:56:39remember in real life when you go to
  7291. 3:56:40production you're going to
  7292. 3:56:41replace this continue the website
  7293. 3:56:44it's going to come up it's going to ask
  7294. 3:56:45me oh lookie it's going to ask for some
  7295. 3:56:47credentials so
  7296. 3:56:48doesn't it look like a outlook web
  7297. 3:56:50access yeah we need to talk about that
  7298. 3:56:55so here i'm going to put in my
  7299. 3:56:56credentials watch
  7300. 3:56:58and what computer do i want to remote to
  7301. 3:57:01and work with
  7302. 3:57:02well let's go mess with the domain
  7303. 3:57:03controller i feel kind of froggy today
  7304. 3:57:08get it oh do a hostname hostname show
  7305. 3:57:10them where we are
  7306. 3:57:11oh this is so cool it's powershell
  7307. 3:57:15through a
  7308. 3:57:15browser it's powershell through
  7309. 3:57:19you made power shall work through but
  7310. 3:57:23guys gals on the beach
  7311. 3:57:26on the beach through any browser it's
  7312. 3:57:29anything funny
  7313. 3:57:30that it can be safari it can be
  7314. 3:57:34ie it can be chrome it can be on any
  7315. 3:57:37device a microsoft device a
  7316. 3:57:39non-microsoft device
  7317. 3:57:41your phone your tablet your laptop
  7318. 3:57:44anywhere in the world
  7319. 3:57:45you got powershell and i i want you to
  7320. 3:57:47point out that not all these things have
  7321. 3:57:49tab buttons when you use them
  7322. 3:57:51but look i'll just even type a get
  7323. 3:57:55dash serve lookie graphically they gave
  7324. 3:57:58you a tab completion button
  7325. 3:58:01i mean come on they thought this through
  7326. 3:58:03this is so
  7327. 3:58:04totally awesome now a lot of you right
  7328. 3:58:06now are going wait a minute wait a
  7329. 3:58:08minute wait a minute wait a minute wait
  7330. 3:58:09a minute
  7331. 3:58:10what about security stop it
  7332. 3:58:13it's just like getting your email it's
  7333. 3:58:15the same thing as getting your email if
  7334. 3:58:17you have exchange
  7335. 3:58:18you've got a casual out there probably
  7336. 3:58:21in your middle tier
  7337. 3:58:22protected by threat management gateway
  7338. 3:58:23whatever you have it it's the same thing
  7339. 3:58:26you can put the box right next to it
  7340. 3:58:28it's the same
  7341. 3:58:29thing so everybody says well this is
  7342. 3:58:32going to be dangerous no more dangerous
  7343. 3:58:34than you checking your email it's over
  7344. 3:58:35https
  7345. 3:58:37you control who has access to this you
  7346. 3:58:39can even control what commandlets they
  7347. 3:58:40can run
  7348. 3:58:42this is one of the best tools and here's
  7349. 3:58:44for a guy like me that's
  7350. 3:58:46traveling all over the place i don't
  7351. 3:58:49have a laptop
  7352. 3:58:50necessarily with vpn to my network all
  7353. 3:58:52the time sometimes the only thing i have
  7354. 3:58:54is the tablet in my hand
  7355. 3:58:56and i can run scripts which we need to
  7356. 3:58:58do scripts
  7357. 3:58:59and i can have access to powershell and
  7358. 3:59:01remote to any box that i want to remote
  7359. 3:59:03to dude you've undersold it
  7360. 3:59:06i sold it i undersold it
  7361. 3:59:09the security yeah absolutely no this is
  7362. 3:59:12more secure than that
  7363. 3:59:13okay why so let's see what we're
  7364. 3:59:15comparing ourselves against
  7365. 3:59:17so there you are and you got your laptop
  7366. 3:59:19and you connect to your domain
  7367. 3:59:20controller
  7368. 3:59:21versus you're on your phone or this
  7369. 3:59:24device of that device and you go https
  7370. 3:59:27to a browser there to a to a website
  7371. 3:59:30that then goes talks to the domain
  7372. 3:59:32controller
  7373. 3:59:33okay now on that machine that web server
  7374. 3:59:37you're not setting that up so that
  7375. 3:59:38people are surfing the net
  7376. 3:59:40that web server that you go to on your
  7377. 3:59:42laptop you're off there surfing your net
  7378. 3:59:44you're at this new site that news site
  7379. 3:59:46maybe some dodgy new dodgy sites dodgy
  7380. 3:59:49sites
  7381. 3:59:49yeah somebody's you're reading your
  7382. 3:59:51email and people are saying oh you know
  7383. 3:59:53click here
  7384. 3:59:54for something wonderful and so that the
  7385. 3:59:56risks of you know using that same box
  7386. 3:59:59to manage your domain controller is
  7387. 4:00:01pretty dodgy
  7388. 4:00:02and so that's why the professional sites
  7389. 4:00:05they set these things up called
  7390. 4:00:06jump boxes they says okay look take your
  7391. 4:00:09dodgy device
  7392. 4:00:10whatever and then you go to this machine
  7393. 4:00:13now this environment
  7394. 4:00:14is safe stay safe you get to do one
  7395. 4:00:17thing on this environment that is
  7396. 4:00:18go to these other environments and you
  7397. 4:00:20know i think that that that is such a
  7398. 4:00:22great description because a lot of you
  7399. 4:00:23guys probably have
  7400. 4:00:24uh you might refer to them as bastion
  7401. 4:00:26boxes question servers
  7402. 4:00:28bastion servers where that's the whole
  7403. 4:00:30point is that my laptop
  7404. 4:00:32might be the wrong tool to be managing
  7405. 4:00:34active directory with because
  7406. 4:00:36of all of the weird things on it but
  7407. 4:00:37this is a controlled server a controlled
  7408. 4:00:40point that i'm going to that isn't going
  7409. 4:00:41to have all that garbage and viruses and
  7410. 4:00:44worms
  7411. 4:00:44and crap on it and this becomes your
  7412. 4:00:47bastion point or your bastion server
  7413. 4:00:49this is awesome
  7414. 4:00:50this is a huge time saver anywhere in
  7415. 4:00:53the world and this way
  7416. 4:00:54you know i heard this in in from
  7417. 4:00:55microsoft i think it was in the year
  7418. 4:00:572001
  7419. 4:00:58we want to get to a place to where we
  7420. 4:00:59can do we could be anywhere
  7421. 4:01:02anytime on any device i think was the
  7422. 4:01:04phrase and
  7423. 4:01:05when this uh feature came out it was i
  7424. 4:01:08can do powershell anywhere anytime any
  7425. 4:01:09device
  7426. 4:01:10you win so awesome feature before we
  7427. 4:01:13wrap up promoting
  7428. 4:01:14now we're going to do sessions in a
  7429. 4:01:16little bit so okay but still i think
  7430. 4:01:18there was a key
  7431. 4:01:18point we didn't we didn't well
  7432. 4:01:22you got the remote man what would you
  7433. 4:01:24like to do
  7434. 4:01:25let's leave this page yeah okay so go
  7435. 4:01:27back to where you did the
  7436. 4:01:28the uh and get the event log
  7437. 4:01:32okay so uh you just want to get a value
  7438. 4:01:34involved invoke command okay
  7439. 4:01:36three machines oh you're gonna do it all
  7440. 4:01:37over computer name
  7441. 4:01:39by the way computer name if you want you
  7442. 4:01:40can just type cn but anyway that's fine
  7443. 4:01:42uh get log stop yeah
  7444. 4:01:46get event log log name let's do
  7445. 4:01:50system notice tab completion is working
  7446. 4:01:52in the squigglies guys
  7447. 4:01:54uh let's do newest three yeah yeah good
  7448. 4:01:58character turn okay so here's the
  7449. 4:02:01question
  7450. 4:02:03why did we return objects
  7451. 4:02:06like like that looks like text to me and
  7452. 4:02:08that looks like what i wanted
  7453. 4:02:10why didn't you just do that and the
  7454. 4:02:12answer is
  7455. 4:02:13because it's objects and objects are
  7456. 4:02:15awesome so now what you can do is you
  7457. 4:02:17can take that
  7458. 4:02:18and do oh right go back just fine all
  7459. 4:02:21right
  7460. 4:02:22just run it okay okay so now what you
  7461. 4:02:24can do is you can say
  7462. 4:02:25uh pipe two sort
  7463. 4:02:29time see here these aren't sorted by
  7464. 4:02:32time
  7465. 4:02:32so you get a three from this guy and
  7466. 4:02:34then three from this guy and then three
  7467. 4:02:35from those guys
  7468. 4:02:36then say select are they sorry format
  7469. 4:02:38table
  7470. 4:02:39format table uh let's just say time and
  7471. 4:02:43message
  7472. 4:02:44property time and message
  7473. 4:02:48oh time we need to do time um um it's
  7474. 4:02:51time written
  7475. 4:02:52yeah time written so uh let's do time
  7476. 4:02:56written oops and i need to actually
  7477. 4:02:59write it in here you guys get the idea
  7478. 4:03:01but let me just get the and then maybe
  7479. 4:03:02it's auto auto uh
  7480. 4:03:05and oh this is getting better and then
  7481. 4:03:07with the format commands guys the format
  7482. 4:03:09commands are wonderful you should take a
  7483. 4:03:10look at them
  7484. 4:03:11format table one of my favorite ones
  7485. 4:03:12because it has auto size
  7486. 4:03:18is that crazy that is totally crazy so
  7487. 4:03:20looking at that one liner
  7488. 4:03:22what we're bringing back and this is
  7489. 4:03:24this is a great thing is that we can
  7490. 4:03:26then continue the pipeline and
  7491. 4:03:27sort and select and still work with this
  7492. 4:03:29exactly that's
  7493. 4:03:30why the power of objects is so important
  7494. 4:03:33because you know when you go do this
  7495. 4:03:34stuff it's not about text
  7496. 4:03:36it's about giving the objects and now
  7497. 4:03:38all of a sudden like when i'm over there
  7498. 4:03:40and i'm doing stuff i can manipulate the
  7499. 4:03:41objects there and that's great
  7500. 4:03:43but when i do remoting what i can do is
  7501. 4:03:45i can get the objects from a very large
  7502. 4:03:47set of machines
  7503. 4:03:49bring them here and operate against the
  7504. 4:03:51object so imagine
  7505. 4:03:52imagine you say oh i got somebody and i
  7506. 4:03:55need to give them
  7507. 4:03:56i need to give them a share you can go
  7508. 4:03:58out to all your file servers get the
  7509. 4:04:00disk space from all your file servers
  7510. 4:04:02as a collection of objects sorted by
  7511. 4:04:04free space
  7512. 4:04:05and then you can say give me the top
  7513. 4:04:06three and then you can look at those and
  7514. 4:04:08say
  7515. 4:04:09yeah that's the one i want imagine how
  7516. 4:04:10else you do it you go to this one find
  7517. 4:04:12it write it down
  7518. 4:04:13you go to that one write it down you go
  7519. 4:04:15to that one how many of you guys are
  7520. 4:04:16actually
  7521. 4:04:17still sending people out to do that go
  7522. 4:04:19check that file server see how much disk
  7523. 4:04:21space it is put it into the spreadsheet
  7524. 4:04:23so we can keep track of
  7525. 4:04:24this as opposed to and there's several
  7526. 4:04:26ways to do it what he's talking about
  7527. 4:04:28but as opposed to
  7528. 4:04:29um let's just use what is it get volume
  7529. 4:04:32right is that is one of the new tests
  7530. 4:04:35or get i think get volume will give you
  7531. 4:04:37free space in science
  7532. 4:04:38we're going to find out in a minute
  7533. 4:04:39we're going to find out what's inside
  7534. 4:04:40size remaining in size
  7535. 4:04:42so yeah do it don't do it do it do it do
  7536. 4:04:44it do it
  7537. 4:04:46do it do it do it do it so let's do uh
  7538. 4:04:49what do you want to do
  7539. 4:04:50command and we'll do it to the way can
  7540. 4:04:52we show them this short way
  7541. 4:04:54this is this yeah yeah here's the short
  7542. 4:04:56way yeah
  7543. 4:04:57yeah i see icm and then and then the
  7544. 4:05:00names
  7545. 4:05:01or just do the names yeah because it's
  7546. 4:05:02positional so dc s1
  7547. 4:05:05s2 that's the short way and we want to
  7548. 4:05:07do
  7549. 4:05:08let's see get volume and pipe it to sort
  7550. 4:05:11size remaining
  7551. 4:05:13[Music]
  7552. 4:05:14volume
  7553. 4:05:16sort size
  7554. 4:05:19i can't spell anymore it's a long day
  7555. 4:05:23sort size remaining let's just try that
  7556. 4:05:24see what we get
  7557. 4:05:25[Music]
  7558. 4:05:28oh god look look look the size remaining
  7559. 4:05:31no wait wait wait no here's the thing
  7560. 4:05:32go back up scroll up scroll up
  7561. 4:05:35scroll up okay notice see you see notice
  7562. 4:05:39how the formatting's no
  7563. 4:05:40i want to show the previous previous one
  7564. 4:05:42so notice here it just shows you
  7565. 4:05:44drive letter to size but now you go
  7566. 4:05:47scroll down
  7567. 4:05:48notice we have ps computer name when the
  7568. 4:05:51objects come back
  7569. 4:05:52we add properties to it and we add where
  7570. 4:05:56did this thing come from
  7571. 4:05:57so that when i do this sort and then you
  7572. 4:05:59go down at the bottom
  7573. 4:06:01i can see okay well there's my volume
  7574. 4:06:03but where did the volume come from and
  7575. 4:06:04the answer is
  7576. 4:06:05s2 that's right so and guys party on my
  7577. 4:06:09friends
  7578. 4:06:09oh and here's the thing that commandlet
  7579. 4:06:11you can
  7580. 4:06:12just say just show me the c drive you
  7581. 4:06:15can sort and filter this out more where
  7582. 4:06:16i just want to see the computer name and
  7583. 4:06:18the size remaining
  7584. 4:06:19and just get a nice short terse list
  7585. 4:06:22then
  7586. 4:06:23export to csv you got your report done
  7587. 4:06:25and you did it on as many computers as
  7588. 4:06:27you wanted to
  7589. 4:06:28in seconds you show them select last
  7590. 4:06:32yeah yeah yeah so here this might have
  7591. 4:06:34been like if i'd done this to like lots
  7592. 4:06:36of machines and there were file services
  7593. 4:06:37and lots of stuff on it
  7594. 4:06:38this would be pretty big and you don't
  7595. 4:06:39want to mess with that right so what you
  7596. 4:06:41do is you say select minus last
  7597. 4:06:43let's pick the last three three
  7598. 4:06:47and what it'll do is give you the last
  7599. 4:06:49three just exactly what you think it
  7600. 4:06:51would do boom
  7601. 4:06:51boom there's the last three so we can
  7602. 4:06:54show rocks
  7603. 4:06:55at powershell so rocks we have first we
  7604. 4:06:57have last there's
  7605. 4:06:58all kinds of ways this is the importance
  7606. 4:07:00of taking a look at those help files
  7607. 4:07:02skip exactly so make sure you look
  7608. 4:07:04inside these help files because
  7609. 4:07:06you can do it it's not something well i
  7610. 4:07:08can't figure out how to do it
  7611. 4:07:09you don't need bizarre long links of
  7612. 4:07:11code you need to look at the help files
  7613. 4:07:13they've really thought this stuff
  7614. 4:07:15through
  7615. 4:07:15and if you get stuck powershell.org
  7616. 4:07:18and ask on the forum yeah lots of really
  7617. 4:07:21helpful people out there
  7618. 4:07:22and just as a side note i it's it's it's
  7619. 4:07:25fascinating that
  7620. 4:07:26how strong the powershell community is
  7621. 4:07:29you guys have noticed
  7622. 4:07:30this is not necessarily the easiest tool
  7623. 4:07:32in the world for you to learn it's the
  7624. 4:07:33most powerful one in your toolbox but
  7625. 4:07:35it's not an easy tool to learn because
  7626. 4:07:37you're just staring at a prompt and now
  7627. 4:07:39what do i do
  7628. 4:07:40we've all gone through this and so the
  7629. 4:07:42powershell community
  7630. 4:07:44is so strong they want to help you so
  7631. 4:07:46avail yourself of those resources and
  7632. 4:07:48i'll give you some more here in a little
  7633. 4:07:50bit
  7634. 4:07:50yeah can you riff on that a second yeah
  7635. 4:07:51so here's the thing you know we found as
  7636. 4:07:54we were rolling out powershell that the
  7637. 4:07:55community just flourished and it's like
  7638. 4:07:57wow and people are having a blast
  7639. 4:07:59now here's the interesting thing turns
  7640. 4:08:01out that this this like hurts the
  7641. 4:08:03community
  7642. 4:08:04no seriously it hurts the community why
  7643. 4:08:06and so and we noticed this because
  7644. 4:08:07at some point we're putting things
  7645. 4:08:08together and everyone like hey did you
  7646. 4:08:10see what bruce did no what did bruce do
  7647. 4:08:12we all run into bruce's office
  7648. 4:08:14and he shows what he does he's like oh
  7649. 4:08:16man that's awesome can you send that to
  7650. 4:08:17me he sends it to me and i'm doing it
  7651. 4:08:19and then i change it and they're like oh
  7652. 4:08:21check out what jeffrey did and everybody
  7653. 4:08:22comes running
  7654. 4:08:23and we were just having a blast with
  7655. 4:08:24this and when lois we thought we said we
  7656. 4:08:26talked about this a little last night we
  7657. 4:08:28said
  7658. 4:08:28boy we're really having fun here and
  7659. 4:08:30like it used to
  7660. 4:08:31computers always used to be fun and then
  7661. 4:08:33for some point
  7662. 4:08:34they stopped being fun it just seemed
  7663. 4:08:36like it was a job
  7664. 4:08:38it became mundane mundane and i think it
  7665. 4:08:40was because of this damn thing
  7666. 4:08:42the mouse right and so here's the idea
  7667. 4:08:44like like i never
  7668. 4:08:46i never never never say hey come on guy
  7669. 4:08:49did you
  7670. 4:08:49check to see the way jason was clicking
  7671. 4:08:51that mouse my god
  7672. 4:08:53you were such a clever guy did you see
  7673. 4:08:55the snap on that thing see i love you
  7674. 4:08:57man because man i work on my mouse moves
  7675. 4:08:59and
  7676. 4:09:00so it's yeah well no that's the point so
  7677. 4:09:02when when i see you
  7678. 4:09:03program when you script and you write
  7679. 4:09:05together as command line
  7680. 4:09:07i see how you think and i'm able to say
  7681. 4:09:09wow that's really clever that's really
  7682. 4:09:11neat
  7683. 4:09:11and you're able to then then i say oh
  7684. 4:09:14can i have that
  7685. 4:09:15right and you give it to me and all of a
  7686. 4:09:16sudden you've helped me
  7687. 4:09:18like you click let's say you're a god at
  7688. 4:09:20clicking that mouse right
  7689. 4:09:22how can you help me like step back and
  7690. 4:09:24be impressed i guess
  7691. 4:09:29right but with a script you can help me
  7692. 4:09:30and i can take it and i've modified it
  7693. 4:09:32meets my needs and i look great to my
  7694. 4:09:34boss
  7695. 4:09:34and all of a sudden you know what two
  7696. 4:09:35things one is you feel good because you
  7697. 4:09:37help me
  7698. 4:09:38two i feel good i have a debt of
  7699. 4:09:40gratitude to you i mean thank you very
  7700. 4:09:41much
  7701. 4:09:42that's very awesome and you buy your
  7702. 4:09:44beer or something like that
  7703. 4:09:45and also i say hey you know what i
  7704. 4:09:47should help other people too
  7705. 4:09:48so really you should help other people
  7706. 4:09:50first be aware
  7707. 4:09:52there's lots of people in the community
  7708. 4:09:53out there more than willing to help you
  7709. 4:09:55should not be sitting
  7710. 4:09:57you know suffering in silence no no if
  7711. 4:09:59you're confused or anything
  7712. 4:10:01i guarantee you nobody's going to be and
  7713. 4:10:04you should not be embarrassed by any of
  7714. 4:10:05your questions people aren't going to
  7715. 4:10:07make fun of you
  7716. 4:10:08that's not going to happen the barrier
  7717. 4:10:10for you asking a question should be
  7718. 4:10:12extraordinarily low just
  7719. 4:10:14ask the question in a form in twitter
  7720. 4:10:16twitter
  7721. 4:10:17very useful place as well just ask that
  7722. 4:10:19question people will help you
  7723. 4:10:20and it turns out then when and then you
  7724. 4:10:23should participate
  7725. 4:10:24you should say hey i found this clever
  7726. 4:10:26way to do things you should blog things
  7727. 4:10:28and here's a great thing right
  7728. 4:10:29so you might know i've been doing this
  7729. 4:10:31powershell thing for a little while now
  7730. 4:10:33i blog things i blog things and say oh
  7731. 4:10:35here's what i do and people will say
  7732. 4:10:37jeez why do you do it that way why
  7733. 4:10:39didn't you do it this way i was like
  7734. 4:10:40i didn't know you could do it that way
  7735. 4:10:42and so the community is teaching me how
  7736. 4:10:44to do things
  7737. 4:10:45honestly it's just a wonderful thing and
  7738. 4:10:47i have to say it's
  7739. 4:10:48it's truly amazing and and remember when
  7740. 4:10:51computers were fun when it wasn't i need
  7741. 4:10:52to reset a bunch of passwords and you
  7742. 4:10:54just sat there and went like
  7743. 4:10:55this where now you're actually going oh
  7744. 4:10:57i'm going to figure out how to reset
  7745. 4:10:59these passwords i'm going to figure out
  7746. 4:11:00how to do xyz
  7747. 4:11:02awesome and now i'm going to automate it
  7748. 4:11:05so i never have to do it again but it
  7749. 4:11:07was fun figuring out the problem it used
  7750. 4:11:09to be
  7751. 4:11:09fun solving the problem and powershell's
  7752. 4:11:13brought that back and the community is
  7753. 4:11:14really strong with that
  7754. 4:11:16folks so here's what we're going to do
  7755. 4:11:17is let me show you the um just
  7756. 4:11:19to let you know that with all of this
  7757. 4:11:20stuff we did in remoting is in the
  7758. 4:11:22slides
  7759. 4:11:23and i'm just going to go through these
  7760. 4:11:25real quick but it's not the end yet of
  7761. 4:11:26remoting we've got some more stuff to do
  7762. 4:11:28but we want to start some automation and
  7763. 4:11:29some scripting to come up
  7764. 4:11:32and so um we're going to kind of get
  7765. 4:11:33started on this and before we take a
  7766. 4:11:35break so
  7767. 4:11:36if you have questions or comments please
  7768. 4:11:38make sure you're jumping out there and
  7769. 4:11:39we're going to come back to remoting in
  7770. 4:11:41just a second
  7771. 4:11:42but before we take a break let's get
  7772. 4:11:44started on this concept
  7773. 4:11:46of automation and to do that
  7774. 4:11:49we need to start to talk about things
  7775. 4:11:51like
  7776. 4:11:52security because we're going to talk
  7777. 4:11:54about scripting now
  7778. 4:11:55and so we're going to take the commands
  7779. 4:11:57that you're building as one-liners and
  7780. 4:11:59and so forth
  7781. 4:12:00and we're going to take those commands
  7782. 4:12:01and now automate them by putting them
  7783. 4:12:03into a script and just telling the
  7784. 4:12:05script to run them for us
  7785. 4:12:07no major deal yet it's pretty
  7786. 4:12:09straightforward but to run a script
  7787. 4:12:11requires some special security so
  7788. 4:12:13we're gonna talk about security we're
  7789. 4:12:14gonna talk about variables a place to
  7790. 4:12:16store your stuff
  7791. 4:12:17maybe a little bit with quotes and then
  7792. 4:12:19we'll start getting into the automation
  7793. 4:12:20so the first thing off
  7794. 4:12:22is and by the way that's a picture of me
  7795. 4:12:24right there the big guy in there
  7796. 4:12:26on the next screen usually people say
  7797. 4:12:28that's the picture of me but that's it
  7798. 4:12:30no oh no guys in the background yep
  7799. 4:12:32that's it
  7800. 4:12:34so powershell is secured by default for
  7801. 4:12:37several different with several different
  7802. 4:12:40ways we had some problems in the past
  7803. 4:12:41with
  7804. 4:12:42like vbscript you double click on it it
  7805. 4:12:44runs oh god
  7806. 4:12:45yeah talk a little bit about what
  7807. 4:12:47powershell does for us
  7808. 4:12:49yeah so okay again remember it's secure
  7809. 4:12:51by default you know we did this
  7810. 4:12:52secure secure secure so when you double
  7811. 4:12:54click so what happened if you weren't
  7812. 4:12:56around then uh people would came in one
  7813. 4:12:59morning
  7814. 4:13:00and they got a mail i love you and
  7815. 4:13:02they're like
  7816. 4:13:03oh well i feel i feel special i've got a
  7817. 4:13:05secret admirer
  7818. 4:13:06and even even the people like i bet
  7819. 4:13:08that's not true
  7820. 4:13:10but it might be right so i want to find
  7821. 4:13:12out why not who loves me
  7822. 4:13:14click click and and then it would run
  7823. 4:13:17you click on this thing and it would run
  7824. 4:13:18and guess what
  7825. 4:13:19bad things happen bad things anybody
  7826. 4:13:21who's like giving you something free
  7827. 4:13:23are promising to grow or shrink your
  7828. 4:13:24body parts with just with money
  7829. 4:13:27just doesn't work okay and so too
  7830. 4:13:29somebody sends you love
  7831. 4:13:30don't click on that stuff anyway so with
  7832. 4:13:32powershell somebody sends you that
  7833. 4:13:34and you double click on it it brings up
  7834. 4:13:36it in the editor it doesn't run it
  7835. 4:13:38it doesn't run it that is the key so
  7836. 4:13:42let me do a quick demonstration of that
  7837. 4:13:43let's uh let's just make a really quick
  7838. 4:13:45script and guys
  7839. 4:13:46do we will get cooler than this but i'm
  7840. 4:13:48going to make a really quick script and
  7841. 4:13:50i've been doing this git service bits
  7842. 4:13:51thing all morning i'm getting sick and
  7843. 4:13:53tired of typing this in
  7844. 4:13:54and i'm going to make sure that it works
  7845. 4:13:56it works i'm going to take this right
  7846. 4:13:57now and i'm
  7847. 4:13:59copying it and i'm going to start up
  7848. 4:14:01notepad
  7849. 4:14:02and i'm going to yeah we're using
  7850. 4:14:04notepad right now don't worry we're
  7851. 4:14:06going to get to the ise i'm going to
  7852. 4:14:07paste it in there
  7853. 4:14:08file save as and here's the magic to
  7854. 4:14:12making a script
  7855. 4:14:13well let me put it on my desktop so we
  7856. 4:14:14can see it is what do you want to call
  7857. 4:14:16this script let's
  7858. 4:14:17call it i love you i love you
  7859. 4:14:21and uh let's uh dot ps1
  7860. 4:14:25uh ps1 and i don't actually want to put
  7861. 4:14:28on my desktop i'm going to put it under
  7862. 4:14:30my scripts folder here so i can get to
  7863. 4:14:32it and
  7864. 4:14:34there's a scripts folder right there i
  7865. 4:14:36love you ps1 you gotta get rid of the
  7866. 4:14:37text
  7867. 4:14:38i gotta hear oh yeah yeah yeah files
  7868. 4:14:41all files and save stick with me guy
  7869. 4:14:44i'll help you out
  7870. 4:14:47so i i've got a script what i want you
  7871. 4:14:49to see is is yes i'm going to show you
  7872. 4:14:51this graphically first because i want to
  7873. 4:14:53see what
  7874. 4:14:53what jeffrey just said i'm going to go
  7875. 4:14:55out here and if somebody were to send
  7876. 4:14:57this to me
  7877. 4:14:58i love you ps1 and i'm going to double
  7878. 4:15:01click it
  7879. 4:15:02see brings it up in notepad or whatever
  7880. 4:15:05editor you're
  7881. 4:15:06you're you're they've set for it then
  7882. 4:15:08what they didn't look
  7883. 4:15:09they didn't actually love me it didn't
  7884. 4:15:10execute my script now this is a good
  7885. 4:15:12thing
  7886. 4:15:12for so many reasons as you guys already
  7887. 4:15:14know you don't want scripts to
  7888. 4:15:15automatically execute but i want to
  7889. 4:15:17bring something up
  7890. 4:15:18a lot of the security that we're going
  7891. 4:15:19to be talking about and the next thing
  7892. 4:15:21which is execution policy which we're
  7893. 4:15:23going to do before we go and break um
  7894. 4:15:25i need to tell you that this is this
  7895. 4:15:28security
  7896. 4:15:29is is is designed to take an
  7897. 4:15:31unintentional
  7898. 4:15:32user to stop them from doing
  7899. 4:15:34unintentionally malicious things in
  7900. 4:15:36other words
  7901. 4:15:37i want you to think about i downloaded a
  7902. 4:15:39script i double click on it i didn't
  7903. 4:15:41want it to run i just i wanted to look
  7904. 4:15:42at it
  7905. 4:15:44we this helps you now if you
  7906. 4:15:47are a power user that wants to be
  7907. 4:15:50malicious
  7908. 4:15:51can we change this well yeah
  7909. 4:15:54i mean power i mean yeah i can i know
  7910. 4:15:57how to change the association of the ps1
  7911. 4:16:00to make it actually execute that's just
  7912. 4:16:03not a good idea
  7913. 4:16:04don't do that the point is is we're not
  7914. 4:16:06going to stop you from doing that but
  7915. 4:16:08this helps you for making foolish
  7916. 4:16:10mistakes like this
  7917. 4:16:11so let's try to execute this script and
  7918. 4:16:13watch what happens
  7919. 4:16:15there's another security feature the
  7920. 4:16:17whole path thing
  7921. 4:16:18you you make us type in the path yeah
  7922. 4:16:20well first just try and type it
  7923. 4:16:22so c colon scripts and i was i love you
  7924. 4:16:26cd to there oh okay
  7925. 4:16:30and then just type i love you i love
  7926. 4:16:33you i love you i no that's not going to
  7927. 4:16:36work
  7928. 4:16:37well i love ip i love ip i love ip i p
  7929. 4:16:39therefore i am there we go i love you
  7930. 4:16:41what what what what what
  7931. 4:16:44says no no no no no not recognized as
  7932. 4:16:48the name of a commandlet a function or a
  7933. 4:16:50script
  7934. 4:16:50file check the spelling well look at the
  7935. 4:16:54suggestion have you ever known someone
  7936. 4:16:55did you notice that the command i love
  7937. 4:16:57you was not found but
  7938. 4:16:59does exist in the current location you
  7939. 4:17:01never know
  7940. 4:17:02i never noticed that tricky tricky so
  7941. 4:17:04now that's just going to confuse me more
  7942. 4:17:06because it's going to say
  7943. 4:17:07oh but then it actually tells me how to
  7944. 4:17:09solve it yeah
  7945. 4:17:10type dot slash now here's the reason why
  7946. 4:17:13this is what's called a you know kind of
  7947. 4:17:14a trolling attack so what would happen
  7948. 4:17:17is
  7949. 4:17:17and this is the old-time unix problem
  7950. 4:17:20your admin
  7951. 4:17:21and your cd to somewhere and you say
  7952. 4:17:22print working directory
  7953. 4:17:24and a bad guy would go in that directory
  7954. 4:17:26and they'd put something called
  7955. 4:17:28print working right directory they would
  7956. 4:17:29rename iloveyou.vbs to print working
  7957. 4:17:31directory directory
  7958. 4:17:32so you cd there you do print working
  7959. 4:17:34directory you run that code
  7960. 4:17:37and so and bad things would happen and
  7961. 4:17:39so what we said was no no
  7962. 4:17:41if you want to run something in the
  7963. 4:17:42current directory you have to be
  7964. 4:17:44clear that that's what you want to do
  7965. 4:17:46we're very clear
  7966. 4:17:47very big on intentionality you have to
  7967. 4:17:49tell me that that's what you want
  7968. 4:17:51otherwise no i remember uh root kits
  7969. 4:17:54used to come in there was a dir
  7970. 4:17:55root kit and you would go dir and you
  7971. 4:17:58were running the root kit
  7972. 4:18:01yeah bad bad so what this prevents from
  7973. 4:18:03is let me show you this two ways one is
  7974. 4:18:05i could try to run the script by typing
  7975. 4:18:07in the full path to the script
  7976. 4:18:09i love you or i can be in the current
  7977. 4:18:13directory and let me show you that one
  7978. 4:18:14if i'm in the current directory with the
  7979. 4:18:15script and try to run it
  7980. 4:18:19it's dot slash i love you ps1
  7981. 4:18:22and that's what that general message at
  7982. 4:18:24the bottom told you to do is because it
  7983. 4:18:26saw it there
  7984. 4:18:27this will run my script oh
  7985. 4:18:30no i'm a failure i'm a failure in life
  7986. 4:18:32because it found it but it
  7987. 4:18:34says it can't be loaded because the
  7988. 4:18:36running of scripts is disabled on this
  7989. 4:18:39system
  7990. 4:18:39for more information in other words
  7991. 4:18:41you're not allowed to run
  7992. 4:18:42scripts and when we come back from break
  7993. 4:18:45we're going to show you
  7994. 4:18:47why you're not allowed to run scripts
  7995. 4:18:49and then how to change that so
  7996. 4:18:51we'll see you guys in 10 minutes yeah 10
  7997. 4:18:53minutes cheers
  7998. 4:19:12[Music]
  7999. 4:19:20oh now see i was talking for like a
  8000. 4:19:22minute and a half and they didn't turn
  8001. 4:19:24the cameras on
  8002. 4:19:25so so back to what we were
  8003. 4:19:29back to what we were doing there they
  8004. 4:19:31are where are you back
  8005. 4:19:32there where have you been um so here's
  8006. 4:19:35the deal
  8007. 4:19:36we need to work with the execution
  8008. 4:19:37policy now i just want you to take a
  8009. 4:19:38quick look at this slide because it it
  8010. 4:19:40lists the execution policy
  8011. 4:19:42for us kind of quick now we have a
  8012. 4:19:44couple of commandlets that'll let us
  8013. 4:19:45work with the execution policy and by
  8014. 4:19:47default
  8015. 4:19:48you are restricted in other words no
  8016. 4:19:51scripty allowed to run
  8017. 4:19:52now interactive only yeah and i just
  8018. 4:19:54want to point out
  8019. 4:19:56that see the word under here called
  8020. 4:19:58unrestricted
  8021. 4:19:59can we just right now kind of put into
  8022. 4:20:01our heads that that's not an option for
  8023. 4:20:03you to set
  8024. 4:20:04it did it with bypass bypass because
  8025. 4:20:06there bypass like
  8026. 4:20:08yeah but unrestricted and bypass so can
  8027. 4:20:11you kind of i know you i don't want you
  8028. 4:20:13drawing on your computers but can you
  8029. 4:20:14just kind of cross those off
  8030. 4:20:16restricted unrestricted well restricted
  8031. 4:20:18is good for
  8032. 4:20:19but no crossover unrestricted bypass can
  8033. 4:20:22we focus on the two that we really want
  8034. 4:20:24you to focus on which is
  8035. 4:20:26remote signed and all signed
  8036. 4:20:30so do you want to talk about the the the
  8037. 4:20:32what is this signed
  8038. 4:20:33thing in the first place that we're
  8039. 4:20:35talking about so basically basically
  8040. 4:20:36digital signatures now in the past like
  8041. 4:20:38vbscript had this
  8042. 4:20:40that was really bad stuff all it did was
  8043. 4:20:41said hey if
  8044. 4:20:43a script is digitally signed i'll run it
  8045. 4:20:45not
  8046. 4:20:46digitally signed by someone i trust
  8047. 4:20:47trust yeah so
  8048. 4:20:49we took a different approach we said it
  8049. 4:20:51has to be digitally signed
  8050. 4:20:52and you have to trust them so before we
  8051. 4:20:55talk about the difference between
  8052. 4:20:56all signed and remote signed can you
  8053. 4:20:58show us what's what it's like to sign a
  8054. 4:21:00script
  8055. 4:21:00okay so let me first go i i've created a
  8056. 4:21:03new
  8057. 4:21:04a self-signed certificate and if you
  8058. 4:21:06ever wonder about that you just say new
  8059. 4:21:08self signed certificate you can go
  8060. 4:21:12create your own
  8061. 4:21:13i've already created some and what i do
  8062. 4:21:15is they're in the cert drive not if
  8063. 4:21:17we've talked about this there are these
  8064. 4:21:18things called providers
  8065. 4:21:19get ps drive okay and you'll see the
  8066. 4:21:23traditional drives like the c
  8067. 4:21:24drive that we've been showing but
  8068. 4:21:26there's a certificate drive oh
  8069. 4:21:28so what i can do is i can do a dir of
  8070. 4:21:30the certificate drive and i do tab
  8071. 4:21:32completion here
  8072. 4:21:33sorry current user and what i'm doing is
  8073. 4:21:35i'm looking for a code signing search so
  8074. 4:21:37the interesting thing is when i'm in the
  8075. 4:21:38certificate drive
  8076. 4:21:39i can do things like well i can do
  8077. 4:21:41recurse on any drive of course
  8078. 4:21:43but i can say give me the code signing
  8079. 4:21:45certs
  8080. 4:21:46how strange and then what i'm going to
  8081. 4:21:48do is i'm going to say ov
  8082. 4:21:49or output put variable
  8083. 4:21:53a okay so what that did was it got me
  8084. 4:21:57did a recursive search found me my code
  8085. 4:21:59signing certs
  8086. 4:22:00i now put them in dollar sign a and then
  8087. 4:22:03what i'm going to say is dollar sign
  8088. 4:22:04cert equals dollar sign a zero so now
  8089. 4:22:06i've got a particular code signing cert
  8090. 4:22:08okay so now let's see let's get my
  8091. 4:22:11execution policy
  8092. 4:22:13get execution policy and you see it's
  8093. 4:22:16remote sign here i'm going to change
  8094. 4:22:18that to
  8095. 4:22:21set execution policy equals
  8096. 4:22:25all signed okay oops sorry
  8097. 4:22:29a equals what am i doing i'm making an
  8098. 4:22:30idiot set execution all signed
  8099. 4:22:33it says yep do it now here i am and i
  8100. 4:22:36have this
  8101. 4:22:36test script oop let me just edit that
  8102. 4:22:39test script
  8103. 4:22:43let me just get rid of this because i
  8104. 4:22:44already signed it that's not right
  8105. 4:22:49don't you see that
  8106. 4:22:52okay so there's my test script
  8107. 4:22:56right and i go and i run it
  8108. 4:23:00it says no you can't do it because
  8109. 4:23:03uh it's not digitally signed okay
  8110. 4:23:06because you went to all signed which
  8111. 4:23:07means
  8112. 4:23:08everything must be signed talk about
  8113. 4:23:10remote signed in a second but everything
  8114. 4:23:12must be signed
  8115. 4:23:12so now i say well i'd like to sign it
  8116. 4:23:14because i trust this i first
  8117. 4:23:16don't sign stuff you haven't understood
  8118. 4:23:18like sign it saying
  8119. 4:23:20sign it is remember i said earlier like
  8120. 4:23:22i take my badge out i put it on the
  8121. 4:23:24table and i say
  8122. 4:23:25i guarantee is it going to work when
  8123. 4:23:27you're digitally signing something
  8124. 4:23:28you're taking your badge out you're
  8125. 4:23:30putting on the table and say anything
  8126. 4:23:31wrong
  8127. 4:23:32take my badge okay so be careful so you
  8128. 4:23:35probably want to take a look at the
  8129. 4:23:36script you're going to smell probably
  8130. 4:23:37yeah i take a look then i said i'm
  8131. 4:23:41so you want to set the auth
  8132. 4:23:45authentication code signature
  8133. 4:23:48of i give my cert and my dollar sign
  8134. 4:23:51cert and
  8135. 4:23:55the file pack yeah okay now notice
  8136. 4:23:59now when i do this test.ps1
  8137. 4:24:03here i'll cat it cat test
  8138. 4:24:08oh look at that thing look at that
  8139. 4:24:11wow yeah so now i mean that is a
  8140. 4:24:14that's a big beast so now if your script
  8141. 4:24:17actually did something harmful
  8142. 4:24:18we know who you are and we can hunt you
  8143. 4:24:20down yes
  8144. 4:24:21except it's a self-signing script right
  8145. 4:24:23so so yeah but yes we can
  8146. 4:24:25now here's the deal dot slash test now
  8147. 4:24:27watch what happens
  8148. 4:24:29just because it's signed doesn't mean
  8149. 4:24:30i'll run it okay
  8150. 4:24:32so we'll say hey uh do you want to run
  8151. 4:24:34this thing
  8152. 4:24:35and you can say hey never run it
  8153. 4:24:38uh don't run it run it once i'm gonna
  8154. 4:24:40say run it once
  8155. 4:24:42okay now if i said always run it it
  8156. 4:24:45would have then taken that certificate
  8157. 4:24:46and said
  8158. 4:24:47i always trust stuff from this guy from
  8159. 4:24:49this certificate yeah and then you can
  8160. 4:24:51run it
  8161. 4:24:51now here you want to see something crazy
  8162. 4:24:53yeah yeah
  8163. 4:24:54i told you we pay attention to the
  8164. 4:24:56security stuff right
  8165. 4:24:58i told you that okay so now imagine
  8166. 4:25:01imagine i go and i say
  8167. 4:25:02um okay so we say let's say
  8168. 4:25:06now just because it's signed i can run
  8169. 4:25:09it always so i can say set
  8170. 4:25:11execution policy and i'll say
  8171. 4:25:14um uh the remote signed
  8172. 4:25:20okay so fine now
  8173. 4:25:23now i can go and i can run this thing it
  8174. 4:25:26just runs
  8175. 4:25:27okay just run but now watch this now
  8176. 4:25:29again what did i say
  8177. 4:25:31when i get a script from the internet
  8178. 4:25:32you don't want to just run it you want
  8179. 4:25:34to examine it
  8180. 4:25:35okay so imagine i do this thing and i
  8181. 4:25:38say
  8182. 4:25:38hey let let me look at this thing and i
  8183. 4:25:40see that and i say hey you know what
  8184. 4:25:42that's safe
  8185. 4:25:42i'm just going to run it right let me
  8186. 4:25:44take a look is it safe
  8187. 4:25:46it's got a signature it looks and the
  8188. 4:25:48code looks safe yeah okay
  8189. 4:25:49okay but wait what if i do this
  8190. 4:26:00oh that's not safe that's not safe now
  8191. 4:26:03now let's save that that's that's kind
  8192. 4:26:04of mean so
  8193. 4:26:06let's make sure we do this so now again
  8194. 4:26:09you come here and you have this script
  8195. 4:26:11yeah yeah
  8196. 4:26:13that that that's mean man but you say
  8197. 4:26:15hey you evaluate it
  8198. 4:26:16right i'm evaluating and it looks good
  8199. 4:26:18at the top right yeah but what if
  8200. 4:26:20down here or somewhere in there is there
  8201. 4:26:22everybody yeah
  8202. 4:26:24well let's run it what do you think
  8203. 4:26:26should i run it
  8204. 4:26:27yeah let's let's no no because you're
  8205. 4:26:30going to run it it's going to rest no i
  8206. 4:26:31checked it out i read it it looked fine
  8207. 4:26:33look look all right it looks fine it's
  8208. 4:26:36fine
  8209. 4:26:36okay run it i mean it looks great you
  8210. 4:26:38know what could possibly go wrong nobody
  8211. 4:26:40would have
  8212. 4:26:40stuck anything in
  8213. 4:26:45so check this out executable code
  8214. 4:26:48found in the signature block
  8215. 4:26:51so we're aware of this threat we're rare
  8216. 4:26:54that
  8217. 4:26:54that people how they're going to
  8218. 4:26:55evaluate things they're going to look at
  8219. 4:26:57things we're going to see the signature
  8220. 4:26:58block
  8221. 4:26:59they're just going to say yeah yeah yeah
  8222. 4:27:01and so we look for people
  8223. 4:27:03uh sneaking in bad code and so we
  8224. 4:27:06protect you from that and say no we're
  8225. 4:27:07not running that crap
  8226. 4:27:09and we even tell you where it is line
  8227. 4:27:1093.
  8228. 4:27:12oh i just got saved from this horrible
  8229. 4:27:15thing no
  8230. 4:27:15that's totally awesome so i so here's
  8231. 4:27:18here
  8232. 4:27:20all signed versus remote sign all sign
  8233. 4:27:22means every script
  8234. 4:27:23that you download and that you create
  8235. 4:27:25locally
  8236. 4:27:26needs to be signed and just to let you
  8237. 4:27:28know and i'm going to type this on my
  8238. 4:27:29screen
  8239. 4:27:30there is a help file about underscore
  8240. 4:27:32signing that will basically take you
  8241. 4:27:33through
  8242. 4:27:34everything that jeffrey just did to sign
  8243. 4:27:37a script
  8244. 4:27:38but let's talk about something for a
  8245. 4:27:40second remote signed
  8246. 4:27:42a lot of you right now it's going to be
  8247. 4:27:44easier for you to start off with remote
  8248. 4:27:45signed here's what this means anything
  8249. 4:27:47you download
  8250. 4:27:48like from the internet needs to be
  8251. 4:27:50signed do you guys know that
  8252. 4:27:52we know what you download from the
  8253. 4:27:54internet
  8254. 4:27:57okay i'm just saying a bunch of guys
  8255. 4:27:59just went
  8256. 4:28:00i got to delete this uh nah there's
  8257. 4:28:05there was a i can't remember what was
  8258. 4:28:06put in mark of the web was put in
  8259. 4:28:09so that things got tagged if they got
  8260. 4:28:11downloaded from the internet this is to
  8261. 4:28:12protect you this is a feature
  8262. 4:28:14and they tagged it so that it overwrote
  8263. 4:28:16rootkits well powershell knows this and
  8264. 4:28:18powershell knows
  8265. 4:28:20that if you downloaded it from the
  8266. 4:28:21internet if you're set to remote signed
  8267. 4:28:24there needs to be a signature on there
  8268. 4:28:26but if you make the script locally there
  8269. 4:28:29doesn't have to be a signature on it so
  8270. 4:28:31a lot of folks
  8271. 4:28:32will set their policy and this is okay
  8272. 4:28:34to start with to remote sign
  8273. 4:28:36just because it's easier to get started
  8274. 4:28:38with
  8275. 4:28:39[Music]
  8276. 4:28:40which that's fine but as soon as you
  8277. 4:28:42possibly can you really want to remove
  8278. 4:28:44go to all sign because i want you to
  8279. 4:28:46think about this at some point you're
  8280. 4:28:48going to want to have this
  8281. 4:28:49execution policy where you can run
  8282. 4:28:50scripts in other places
  8283. 4:28:52and it'd be nice to be able to control
  8284. 4:28:55this through
  8285. 4:28:56that the scripts have to be signed
  8286. 4:28:57imagine what your users might do if they
  8287. 4:29:00figure out how to turn on scripting
  8288. 4:29:01policy
  8289. 4:29:02they might want to download a script if
  8290. 4:29:05you set this through
  8291. 4:29:06a group policy then you're going to be
  8292. 4:29:09able to help control what could be some
  8293. 4:29:11possible issues of users trying to do
  8294. 4:29:13weird things
  8295. 4:29:14so this is actually really important
  8296. 4:29:16remote signs good to start with all
  8297. 4:29:17signs
  8298. 4:29:18is really the best to get to watch what
  8299. 4:29:21happens now and you've seen it with
  8300. 4:29:22jeffrey now that
  8301. 4:29:23i have an execution policy that works i
  8302. 4:29:26can try to run my script
  8303. 4:29:27and i forgot what my script was i love
  8304. 4:29:30ups one and lo and beholds
  8305. 4:29:32there it goes now so script script
  8306. 4:29:35execution policy need to turn it on yeah
  8307. 4:29:39let me talk about the latest version
  8308. 4:29:40latest version of windows
  8309. 4:29:42top secret top secret topsy we're
  8310. 4:29:44disclosing we're going to bring you into
  8311. 4:29:47the circle of trust
  8312. 4:29:50so the next version of windows server
  8313. 4:29:52let's say windows server 2012 r2
  8314. 4:29:55we change the default execution policy
  8315. 4:29:58to be
  8316. 4:29:58remote signed by default which is
  8317. 4:30:00awesome because that way you don't have
  8318. 4:30:02to run around to your servers
  8319. 4:30:03or issue out a group policy to get this
  8320. 4:30:05because you need your servers
  8321. 4:30:07to have an execution policy so when
  8322. 4:30:09modules load and you want to shoot you
  8323. 4:30:11want to load scripts from all that kind
  8324. 4:30:12of stuff
  8325. 4:30:13it makes life a lot easier so server
  8326. 4:30:152012 r2
  8327. 4:30:17right is when it ships we'll have the
  8328. 4:30:19new poli which is amazing to
  8329. 4:30:21have that set yeah by the way a number
  8330. 4:30:22of people let me just clarify one thing
  8331. 4:30:24we're not going to get into the details
  8332. 4:30:25of the security but i will just point
  8333. 4:30:27out that even if you're
  8334. 4:30:28uh if you have like uh execution policy
  8335. 4:30:31to be
  8336. 4:30:32you know uh unrestricted whatever an
  8337. 4:30:34interactive user basically an
  8338. 4:30:36interactive user can do
  8339. 4:30:37anything and they can bypass that that
  8340. 4:30:41don't worry about that that is not a
  8341. 4:30:43security violation that's not a hole
  8342. 4:30:45there's actually a long explanation for
  8343. 4:30:47that we won't get into it here because
  8344. 4:30:48it's not that interesting
  8345. 4:30:49but just don't freak out if somebody has
  8346. 4:30:51access to a terminal
  8347. 4:30:52i mean basically here's the thought if
  8348. 4:30:54they have access to a terminal uh
  8349. 4:30:56they can uh uh create programs compile
  8350. 4:30:59those programs and run it which means
  8351. 4:31:01they can do anything
  8352. 4:31:02so at this point it's it's not a
  8353. 4:31:04security remember the old the old thing
  8354. 4:31:06of physical access right
  8355. 4:31:07physical access so um guys we want to do
  8356. 4:31:10a couple of things to set us up for some
  8357. 4:31:11scripting one of the things that we want
  8358. 4:31:13to do here oh this is
  8359. 4:31:14we're going to start doing first of all
  8360. 4:31:15variables now uh
  8361. 4:31:17we've already been using them believe it
  8362. 4:31:19or not i just want to show you that
  8363. 4:31:21um watch i'm going to show you there's a
  8364. 4:31:22whole bunch of commandlets so i'm
  8365. 4:31:24thinking to myself
  8366. 4:31:25how would i find if powershell had any
  8367. 4:31:27commandlets to help me with variables
  8368. 4:31:29i can do this variable and
  8369. 4:31:32oh looky there's a whole bunch of clear
  8370. 4:31:34variable get variable new variable
  8371. 4:31:36remove variable set
  8372. 4:31:38stop looking at the screen we're not
  8373. 4:31:40going to use any of them we don't need
  8374. 4:31:41to
  8375. 4:31:42powershell makes working with variables
  8376. 4:31:44really easy we don't necessarily need
  8377. 4:31:45these commandlets
  8378. 4:31:46so let me show you how easy it is to
  8379. 4:31:48make a variable um
  8380. 4:31:50watch variables um have a dollar sign
  8381. 4:31:53and
  8382. 4:31:54there's a lot of reasons for the use of
  8383. 4:31:55this dollar sign we're not going to get
  8384. 4:31:57a chance to go into
  8385. 4:31:58how the parsing engine reads all of this
  8386. 4:32:00but this is not the name
  8387. 4:32:01or part of the name of the variable it
  8388. 4:32:04tells powershell hey
  8389. 4:32:05something's about to happen and if it's
  8390. 4:32:06alphanumeric after it
  8391. 4:32:08my var this is going to be a variable
  8392. 4:32:11if you want to set this variable equal
  8393. 4:32:12to something equals
  8394. 4:32:15hello thank you thank you no commandlets
  8395. 4:32:19required i just created variable
  8396. 4:32:20totally totally awesome you want to see
  8397. 4:32:22what's inside of a variable
  8398. 4:32:24myvar but variables are awesomely cool
  8399. 4:32:27because
  8400. 4:32:28variables don't just take text they
  8401. 4:32:30don't just take integers
  8402. 4:32:32watch my var
  8403. 4:32:35equals get service
  8404. 4:32:40bets guess what's in my var right now
  8405. 4:32:43guess what's in my bar wait a minute let
  8406. 4:32:45me show you this is called my
  8407. 4:32:46bar
  8408. 4:32:50wait wait wait wait wait watch watch
  8409. 4:32:53watch
  8410. 4:32:53get member lookie look look look
  8411. 4:32:56look look what's in my bar i got a
  8412. 4:32:59service controller object in there
  8413. 4:33:01it's not just text guys it's it's
  8414. 4:33:03service controller object so
  8415. 4:33:04i want you to notice something we
  8416. 4:33:06haven't talked much about running
  8417. 4:33:07methods but
  8418. 4:33:08all these properties and look there's a
  8419. 4:33:10couple of methods here there's a start
  8420. 4:33:12and a stop method
  8421. 4:33:14i have an idea i wonder if i could use
  8422. 4:33:16this
  8423. 4:33:17dot notation that you started using
  8424. 4:33:20my var dot let's see a property status
  8425. 4:33:24oh it's running and i wonder if i could
  8426. 4:33:26get it to run
  8427. 4:33:27a method like stop
  8428. 4:33:34now i know you're all saying well prove
  8429. 4:33:35it prove it prove it all right well
  8430. 4:33:37one little thing is i'm going to do my
  8431. 4:33:39var status but you're going to say oh
  8432. 4:33:40so you didn't work no no no no no if we
  8433. 4:33:43refreshed
  8434. 4:33:44everything that existed in windows
  8435. 4:33:46constantly
  8436. 4:33:47oh my god so there's a method to help us
  8437. 4:33:49refresh this so refresh
  8438. 4:33:53and now look at the status boom
  8439. 4:33:56totally awesome vars make your life
  8440. 4:33:59much easier and of course with scripting
  8441. 4:34:02bars become very important now there's a
  8442. 4:34:04lot to do with vars and there's a lot of
  8443. 4:34:06tips and tricks with working with bars
  8444. 4:34:09um can you tell one thing oh absolutely
  8445. 4:34:11so snap to mine
  8446. 4:34:13so here's the thing you i think it's
  8447. 4:34:15because it's a jump start and it's
  8448. 4:34:17tutorial
  8449. 4:34:17um like why do we have this dollar sign
  8450. 4:34:20some people like i hate the dollar sign
  8451. 4:34:21blah blah blah
  8452. 4:34:22well here's why so when we say dollar
  8453. 4:34:24sign my var
  8454. 4:34:27equals get service
  8455. 4:34:31service bits okay right just works right
  8456. 4:34:34but what happens if i do this
  8457. 4:34:37right some people like i don't like
  8458. 4:34:39dollar signs okay fine what happens
  8459. 4:34:42and the answer is an error but look at
  8460. 4:34:43the error the term myvar
  8461. 4:34:46is not recognized as the name of a
  8462. 4:34:48commandlet
  8463. 4:34:50okay so so when you start a command
  8464. 4:34:53when you start a line with a name
  8465. 4:34:56the question is well is it a variable or
  8466. 4:34:58is it a command line right
  8467. 4:34:59and we have to know and so that's why we
  8468. 4:35:02have dollar signs in front of our
  8469. 4:35:03variables because you have to know
  8470. 4:35:05and this remember i talked about the
  8471. 4:35:06struggle between interactive programming
  8472. 4:35:09and
  8473. 4:35:09and systems programming this was the key
  8474. 4:35:11thing that
  8475. 4:35:12interactive commands uh have require a
  8476. 4:35:15special syntax
  8477. 4:35:16in programs you're not running things
  8478. 4:35:18out of the file system
  8479. 4:35:19right right you're running you know apis
  8480. 4:35:22and such
  8481. 4:35:23in an interactive shell you run things
  8482. 4:35:24out of the command so so when you type
  8483. 4:35:26ping you just want ping to work you
  8484. 4:35:28don't want to have to say
  8485. 4:35:30oh well i want to do something special
  8486. 4:35:31for ping
  8487. 4:35:33so that's why you just type ping
  8488. 4:35:36right but if you want dollar sign ping
  8489. 4:35:39to be
  8490. 4:35:40x you type dollar sign ping that's why
  8491. 4:35:44we have the dollar sign that's it
  8492. 4:35:45no and that's actually very important
  8493. 4:35:47everybody's always asking about the
  8494. 4:35:48dollar sign so when you're working with
  8495. 4:35:49vars
  8496. 4:35:50you got to have the dollar sign now a
  8497. 4:35:52couple of little things a little uh
  8498. 4:35:54um oh let's let's play with since we're
  8499. 4:35:57getting ready for scripting we're going
  8500. 4:35:58to take this concept of using a var and
  8501. 4:36:00try something here let's uh watch
  8502. 4:36:02this let's see uh there's a commandlet
  8503. 4:36:04called read host
  8504. 4:36:06it'll actually read things from the host
  8505. 4:36:10the host so let me see dollar sign var
  8506. 4:36:13equals
  8507. 4:36:13read host so whatever we read in is
  8508. 4:36:16going to get stored in the variable and
  8509. 4:36:17i'm gonna say
  8510. 4:36:18enter a computer name now guys you can
  8511. 4:36:21imagine
  8512. 4:36:22this in a script already because watch
  8513. 4:36:24what happens i'm gonna strike enter
  8514. 4:36:25comes up says enter a computer name
  8515. 4:36:26okay i'll enter one now what's stored in
  8516. 4:36:30var right now
  8517. 4:36:32is that computer name you can now use
  8518. 4:36:34that variable
  8519. 4:36:35which is where we're going with all this
  8520. 4:36:37get service
  8521. 4:36:38name bits dash computer name dollar sign
  8522. 4:36:41var
  8523. 4:36:42guess where we're going to go get that
  8524. 4:36:44information from now
  8525. 4:36:45so we're going out to that that that
  8526. 4:36:48that the dc in this case
  8527. 4:36:50so we're storing stuff in the vars and
  8528. 4:36:52then we're going to use those vars
  8529. 4:36:53in our commands with our parameters as
  8530. 4:36:55part of the arguments
  8531. 4:36:57this is going to start us making better
  8532. 4:36:59scripts and being able to do automation
  8533. 4:37:01a little bit better
  8534. 4:37:03but i want to show you just a couple of
  8535. 4:37:04quick things because you're going to
  8536. 4:37:06hear this and you're going to see this a
  8537. 4:37:07lot and i just have to throw it out
  8538. 4:37:09because
  8539. 4:37:10i'm kind of i want to ask about it so
  8540. 4:37:13dollar sign var if i do this it just
  8541. 4:37:15prints it to the screen but we actually
  8542. 4:37:16have a commandlet
  8543. 4:37:18that were is designed to print things to
  8544. 4:37:20the screen for you
  8545. 4:37:21um let's do uh write host real quick
  8546. 4:37:24you're going to see this a lot right
  8547. 4:37:25host dollar sign var
  8548. 4:37:27same result except right host has things
  8549. 4:37:29like foreground color
  8550. 4:37:30red background color green
  8551. 4:37:34yay you can play with the colors
  8552. 4:37:36everybody just got really excited
  8553. 4:37:37because now they can play with colors
  8554. 4:37:38yeah start playing with colors um we
  8555. 4:37:42have ways for you to play with colors
  8556. 4:37:43and i
  8557. 4:37:44you probably have heard the phrase every
  8558. 4:37:47time and
  8559. 4:37:47every time you use write host
  8560. 4:37:50god kills a puppy
  8561. 4:37:53so don't use right house no i i want to
  8562. 4:37:56be straight with you
  8563. 4:37:57there are times to use write host it's
  8564. 4:37:59just i want you to see
  8565. 4:38:00what you're doing and when you start
  8566. 4:38:02scripting this really starts to matter
  8567. 4:38:04yeah
  8568. 4:38:04dollar sign var watch what i'm going to
  8569. 4:38:06do i'm going to pipe this to get member
  8570. 4:38:09you would expect
  8571. 4:38:10a result at this point look at what i'm
  8572. 4:38:13getting
  8573. 4:38:14i get no object has been specified in
  8574. 4:38:16other words
  8575. 4:38:17nothing went across the pipeline right
  8576. 4:38:19host just
  8577. 4:38:21destroyed everything that i've been
  8578. 4:38:23working
  8579. 4:38:24so hard for with objects right host has
  8580. 4:38:27annihilated it by the way notice it
  8581. 4:38:29showed dc on the on the coast
  8582. 4:38:31yeah because it actually wrote it out to
  8583. 4:38:34the house yes
  8584. 4:38:35but there was nothing going down the
  8585. 4:38:37pipeline and the point is we want stuff
  8586. 4:38:38going on the pipeline
  8587. 4:38:40so with right host we have a command
  8588. 4:38:43that watch this
  8589. 4:38:44write output dollar sign var
  8590. 4:38:48and it does the exact same thing but
  8591. 4:38:51it's doing it through the pipeline look
  8592. 4:38:53get member look at what i got
  8593. 4:38:56i got a real object that's crossing
  8594. 4:38:57across there now
  8595. 4:39:00so it matters but everybody says well
  8596. 4:39:02you lost the ability to make colors
  8597. 4:39:04get over the color thing we don't here's
  8598. 4:39:07the deal we have ways for you to make
  8599. 4:39:09colors
  8600. 4:39:09properly you've noticed that powershell
  8601. 4:39:11has a built-in color scheme
  8602. 4:39:13that it uses and as you start to script
  8603. 4:39:15this is going to become
  8604. 4:39:16real paramount as admins we get used to
  8605. 4:39:19certain colors
  8606. 4:39:20popping up so in powershell we've
  8607. 4:39:22included commandlets to use the existing
  8608. 4:39:24color scheme if you just play along
  8609. 4:39:26it'll all be good such as i want to
  8610. 4:39:29write
  8611. 4:39:30a warning please
  8612. 4:39:34don't do that
  8613. 4:39:37look it comes up as a powershell warning
  8614. 4:39:40the yellow on black so it makes
  8615. 4:39:41sense to my brain because i've seen
  8616. 4:39:43those warnings before or things
  8617. 4:39:45that i need to care about i didn't have
  8618. 4:39:46to go through and use right host and
  8619. 4:39:48come up with my own color scheme
  8620. 4:39:50and of course we give you things like
  8621. 4:39:51write error and there's other stuff that
  8622. 4:39:54we have but right error being one
  8623. 4:39:55stop touching me and
  8624. 4:39:59now it looks like a power shell error
  8625. 4:40:01message and i've generated the error and
  8626. 4:40:03it's in the same color scheme in the
  8627. 4:40:05same format so you don't need write host
  8628. 4:40:07most of the time if you want to put
  8629. 4:40:09something on the screen in a different
  8630. 4:40:10color great but try to stick with right
  8631. 4:40:12output and the other right
  8632. 4:40:14commands that we give you to write
  8633. 4:40:16things out to the screen especially when
  8634. 4:40:18you're working with your
  8635. 4:40:19your vars because right host couldn't
  8636. 4:40:21can be
  8637. 4:40:22somewhat problematic you know i'm
  8638. 4:40:24checking this is very analogous to what
  8639. 4:40:26i mentioned about the console
  8640. 4:40:28remember i said i'm trying to kill off
  8641. 4:40:30the console because i'm trying to kill
  8642. 4:40:32off console apps
  8643. 4:40:33because apps that write directly to the
  8644. 4:40:35console can't be
  8645. 4:40:36automated they are the enemy of
  8646. 4:40:38automation right host is another flavor
  8647. 4:40:40of a console app is another flavor of a
  8648. 4:40:43console app so don't do it by the way
  8649. 4:40:44there are times there are times we have
  8650. 4:40:46a special
  8651. 4:40:47like dispensation for people who are
  8652. 4:40:50trying to to do this here's the key
  8653. 4:40:52thing
  8654. 4:40:52your say you want to write a script that
  8655. 4:40:54was well formatted and had colors and
  8656. 4:40:56all that good stuff that's fine
  8657. 4:40:57but use the word show okay whenever you
  8658. 4:41:00see the word
  8659. 4:41:01show you should hear in your head ah
  8660. 4:41:04i'm not going to be able to program or
  8661. 4:41:06script the output of that
  8662. 4:41:08so that's perfectly fine but just make
  8663. 4:41:10sure you use the right term
  8664. 4:41:11show right and then and yes most of the
  8665. 4:41:15time just don't use right house
  8666. 4:41:16okay okay just just don't do it it's
  8667. 4:41:18because you like dogs
  8668. 4:41:20it's because i like dogs and and i have
  8669. 4:41:23to give don jones credit for that phrase
  8670. 4:41:25who uses
  8671. 4:41:26that all the time so let's do something
  8672. 4:41:28kind of fun and kind of exciting at this
  8673. 4:41:30point i
  8674. 4:41:31i i think that's because you show them
  8675. 4:41:32the squiggle brackets
  8676. 4:41:34uh-huh the squiggle brackets you want to
  8677. 4:41:36show them the variables with the
  8678. 4:41:36squiggle brackets yeah
  8679. 4:41:38really that's awesome here i'll do it
  8680. 4:41:40it's okay here's me okay you're doing so
  8681. 4:41:42here's the thing
  8682. 4:41:43hey what can i do like hey this you know
  8683. 4:41:45is this an anglo-centric english thing
  8684. 4:41:47and the answer is no no no my friends
  8685. 4:41:49like let's say you want to have you can
  8686. 4:41:51put
  8687. 4:41:51you can you have variables of any sort
  8688. 4:41:53of names including spaces right
  8689. 4:41:55so you can say hey this is a
  8690. 4:41:58test equals four right
  8691. 4:42:01and then this is a test
  8692. 4:42:04it's four is that cool now check this
  8693. 4:42:06out you can have anything you want in
  8694. 4:42:08here right
  8695. 4:42:09oh sorry get the wrong thing what the
  8696. 4:42:11heck was that
  8697. 4:42:12oh that wasn't good what did i do
  8698. 4:42:16oh good lord help help help help me help
  8699. 4:42:18me
  8700. 4:42:20no i oh here we go
  8701. 4:42:24there we go there that's what i meant to
  8702. 4:42:27do
  8703. 4:42:27okay there you go that's really weird
  8704. 4:42:31wow whoa
  8705. 4:42:34okay so now look that's the name of my
  8706. 4:42:37variable oh did i screw that up i did
  8707. 4:42:39screw that up
  8708. 4:42:40oh no i did equals okay so that's the
  8709. 4:42:43name of my variable is that crazy or
  8710. 4:42:45what
  8711. 4:42:45that's crazy but here it gets a little
  8712. 4:42:47bit cooler
  8713. 4:42:48because we draw this distinction between
  8714. 4:42:50the syntax of a variable and the
  8715. 4:42:51semantics of the variable
  8716. 4:42:53so here the syntax is just showing you
  8717. 4:42:55um
  8718. 4:42:56it's a container and i i mentioned you
  8719. 4:42:58could put any very
  8720. 4:42:59any parameter you want you can use sorry
  8721. 4:43:02any uh
  8722. 4:43:03character you want you can using unicode
  8723. 4:43:05etc it's not entirely true
  8724. 4:43:07there's a special character and that is
  8725. 4:43:10the colon character
  8726. 4:43:11so let me make sure here's where i am
  8727. 4:43:13imagine i do this imagine i do
  8728. 4:43:151.5 okay and then i'm going to put that
  8729. 4:43:18in a file
  8730. 4:43:19test dot txt okay
  8731. 4:43:22so now imagine watch this c colon
  8732. 4:43:26jumpstart test.txt
  8733. 4:43:32so look at that so i did dollar sign
  8734. 4:43:35my parameters and i gave a file path
  8735. 4:43:39and i get the value
  8736. 4:43:42of the file so you're basically saying
  8737. 4:43:45call and do this
  8738. 4:43:46well it is hey this dollar sign syntax
  8739. 4:43:50basically says where do i store my data
  8740. 4:43:52and in general the way we think of
  8741. 4:43:54variables is well you store data in
  8742. 4:43:55memory somewhere and when the process
  8743. 4:43:58goes away
  8744. 4:43:59well that goes away right we'll look
  8745. 4:44:01here look here look here
  8746. 4:44:03wait a second so now i get a second
  8747. 4:44:05command and i can say
  8748. 4:44:07dollar sign c colon
  8749. 4:44:12jump start slash test
  8750. 4:44:17test.txt i did squiggle brackets
  8751. 4:44:26slash slash
  8752. 4:44:29i can get it there now wait so wait so
  8753. 4:44:32equals
  8754. 4:44:41i go to this machine and now
  8755. 4:44:44so now i've got variables that cross
  8756. 4:44:47cross
  8757. 4:44:48that's awesome that is totally awesome
  8758. 4:45:07[Music]
  8759. 4:45:16so when we're doing remoting yes and
  8760. 4:45:18remember in vote command we're now going
  8761. 4:45:19to use the alias
  8762. 4:45:20icm for this just to abbreviate things
  8763. 4:45:24we're actually starting a remote
  8764. 4:45:26powershell session
  8765. 4:45:28yeah like you said we're feeding it a
  8766. 4:45:31command
  8767. 4:45:33then we're closing that powershell
  8768. 4:45:35session and
  8769. 4:45:36leaving right so we start a tcp
  8770. 4:45:38connection tcp we start a process
  8771. 4:45:41we load the clr we load powershell
  8772. 4:45:44we initialize powershell we run all your
  8773. 4:45:47profiles that can be up to four profiles
  8774. 4:45:50we run those and when those are all
  8775. 4:45:51ready then we take the code
  8776. 4:45:54we execute it and we throw all that away
  8777. 4:45:56and then we throw everything away so
  8778. 4:45:58you this is important when you're using
  8779. 4:46:00remoting we're going to connect to that
  8780. 4:46:02box we're going to
  8781. 4:46:03start all this stuff up we're going to
  8782. 4:46:04climb up this mountain we're going to
  8783. 4:46:06give it your
  8784. 4:46:06little tiny code do that
  8785. 4:46:09and then we have to tear all this down
  8786. 4:46:12and walk away
  8787. 4:46:13you can imagine that if you're going to
  8788. 4:46:14do a lot of invoke commands in a row
  8789. 4:46:17that's not very efficient so there's a
  8790. 4:46:20way we can make this more efficient and
  8791. 4:46:21i want to demonstrate it using variables
  8792. 4:46:23first and then
  8793. 4:46:24we'll take a look at some cool things
  8794. 4:46:25that we can do with this so watch guys
  8795. 4:46:27i'm going to go to
  8796. 4:46:28i'm just going to do this on dc first
  8797. 4:46:30and what i'm going to do is
  8798. 4:46:31i'm going to show you what's happening
  8799. 4:46:33i'm going to do dollar sign var equals
  8800. 4:46:352.
  8801. 4:46:36now think this through i'm going to go
  8802. 4:46:38to the domain controller i'm going to
  8803. 4:46:39start up powershell i'm going to
  8804. 4:46:41set a variable and then i'm going to
  8805. 4:46:44destroy powershell
  8806. 4:46:45so what happens is is if i now ask it
  8807. 4:46:49what's that variable on output
  8808. 4:46:53on uh on dc well is anybody shocked that
  8809. 4:46:58it's not there anymore when the console
  8810. 4:47:00dies everything dies
  8811. 4:47:02this is why powershell has to run all
  8812. 4:47:03the time so nothing dies
  8813. 4:47:05but no when the new console dies when
  8814. 4:47:07that execute when powershell exe on the
  8815. 4:47:10other side dies everything dies with it
  8816. 4:47:12what i'd really like to do
  8817. 4:47:15is i'd like to be able to connect to the
  8818. 4:47:16machines go through starting all this up
  8819. 4:47:19and leave it up yeah yeah i'm in you in
  8820. 4:47:22for this yeah so we call those things
  8821. 4:47:25sessions sessions you'd like to create a
  8822. 4:47:27powershell session
  8823. 4:47:28we're going to create a power so watch
  8824. 4:47:30let's create the powershell session so
  8825. 4:47:31what i'm going to do is i'm going to set
  8826. 4:47:32this equal to a variable called
  8827. 4:47:34sessions equals new
  8828. 4:47:37ps session now i'm going to specify the
  8829. 4:47:40computer and right now i'm just going to
  8830. 4:47:41keep it real simple i'm just going to
  8831. 4:47:42use
  8832. 4:47:43the dc right now so what happens is that
  8833. 4:47:46i've created a session
  8834. 4:47:48that's going to keep powershell running
  8835. 4:47:50on that remote machine now i'm only
  8836. 4:47:52doing it to one machine right now but
  8837. 4:47:54it's on that remote machine just to show
  8838. 4:47:56you we have a command for get ps session
  8839. 4:47:58that will show you what sessions you
  8840. 4:47:59have notice
  8841. 4:48:01got a session to that computer it's open
  8842. 4:48:04life is good what i can do now is start
  8843. 4:48:07using invoke command and instead of
  8844. 4:48:08using dash computer name i can specify
  8845. 4:48:10that i want to use
  8846. 4:48:12this session so icm we're going to do
  8847. 4:48:15the exact same example again so let me
  8848. 4:48:17just go ahead and clear the screen here
  8849. 4:48:18and i'm going to do icm
  8850. 4:48:21computer oh no not a computer yeah
  8851. 4:48:24dollar sign sessions of course i had to
  8852. 4:48:25make it long and easy hard to type
  8853. 4:48:27and i'm going to do the same thing var
  8854. 4:48:29equals 2
  8855. 4:48:31and this time i'm going to go back and
  8856. 4:48:34check on it
  8857. 4:48:38fast fast fast fast fast fast and this
  8858. 4:48:40now gives us a lot of power to do a lot
  8859. 4:48:42of
  8860. 4:48:42really really cool things so we can keep
  8861. 4:48:46this session open and we continuously
  8862. 4:48:47fire things we can reference variables
  8863. 4:48:49that we have open
  8864. 4:48:50this is going to make our lives a lot
  8865. 4:48:52easier um happy happy happy
  8866. 4:48:54happy happy happy i can't show them the
  8867. 4:48:55difference in time yeah yeah
  8868. 4:48:57okay do you do measure commit you know
  8869. 4:48:59measure command yeah do measure command
  8870. 4:49:01on
  8871. 4:49:02just invoke command minus command name
  8872. 4:49:03or my computer name
  8873. 4:49:05oh you want to see the difference in
  8874. 4:49:07time oh yeah i wonder if that would
  8875. 4:49:08you think it's going to be apparent here
  8876. 4:49:09computer named dc yeah
  8877. 4:49:11and do get process oh get process yeah
  8878. 4:49:14that's good get process
  8879. 4:49:15and then screw it and then uh no no no
  8880. 4:49:18you put wrap that whole thing in a
  8881. 4:49:19script block
  8882. 4:49:20and put measure command at the beginning
  8883. 4:49:26measure measure command
  8884. 4:49:31so what's happening here is that the
  8885. 4:49:33measure command is going to take what
  8886. 4:49:34we're running
  8887. 4:49:35and so you can see what it's doing is
  8888. 4:49:37that it's it's showing us how long this
  8889. 4:49:39is taking
  8890. 4:49:40yeah i love text um but anyways
  8891. 4:49:42milliseconds
  8892. 4:49:43eight eight six milliseconds now do it
  8893. 4:49:45with a session
  8894. 4:49:47so let's do the same thing so i'm going
  8895. 4:49:49to just do measure command let's just do
  8896. 4:49:50up arrow man
  8897. 4:49:51oh yeah me and my up arrows
  8898. 4:49:54down one there now change computer name
  8899. 4:49:58dc
  8900. 4:49:58to okay let's do that it says 886
  8901. 4:50:02886 to session dollar sign sessions
  8902. 4:50:09five oh probably even faster but it's
  8903. 4:50:12yeah it's going to actually be faster
  8904. 4:50:14and here's the thing
  8905. 4:50:15it is faster doing it this way um
  8906. 4:50:18but now when it's really going to pay
  8907. 4:50:20off being faster
  8908. 4:50:22want to see something cool yeah yeah i'm
  8909. 4:50:24going to draw okay
  8910. 4:50:26watch wow this is when sessions and
  8911. 4:50:29remoting
  8912. 4:50:30change your world so i want to prove to
  8913. 4:50:32you that i'm not lying to you
  8914. 4:50:33so first of all i'm going to kill
  8915. 4:50:35everything so you know that i'm not i'm
  8916. 4:50:36going to kill the shell oink and i'm
  8917. 4:50:38going to bring up a new one
  8918. 4:50:39really that way you know that i've got
  8919. 4:50:41clean shell i'm not hiding no no
  8920. 4:50:43not rabbits nothing up sleeves anything
  8921. 4:50:45like that here we go
  8922. 4:50:47quick demonstration but see if you catch
  8923. 4:50:49what's going to happen here first of all
  8924. 4:50:50dollar signs servers
  8925. 4:50:52equals who let's do s1
  8926. 4:50:55and s2
  8927. 4:50:58so you guys know in dollar sign servers
  8928. 4:51:01well here
  8929. 4:51:02you know cool
  8930. 4:51:05watch i'm going to show you that i'm not
  8931. 4:51:07cheating nothing's being hidden here
  8932. 4:51:09start uh
  8933. 4:51:11[Music]
  8934. 4:51:12let me do it this way dollar sign
  8935. 4:51:14servers
  8936. 4:51:18coffee oh yeah um dollar sign servers
  8937. 4:51:21and watch watch i'm gonna use a command
  8938. 4:51:24called for each and what this is gonna
  8939. 4:51:26let me do
  8940. 4:51:27is iterate through each one of those
  8941. 4:51:29coming across the pipeline so
  8942. 4:51:30you know it's in dollar sign servers i
  8943. 4:51:32got two computer names
  8944. 4:51:34i want to grab the current one across
  8945. 4:51:36the pipeline
  8946. 4:51:37and use it in a special way so what i'm
  8947. 4:51:38going to do is start http oops start i
  8948. 4:51:42explore
  8949. 4:51:45http dollar sign underscore think about
  8950. 4:51:49this for a second guys here's what i'm
  8951. 4:51:50going to do is
  8952. 4:51:50start up i explore for each one of these
  8953. 4:51:53and make it go to those servers to show
  8954. 4:51:55you that there's no websites there
  8955. 4:51:57there's no
  8956. 4:51:58default web pages it's just going to
  8957. 4:51:59come up and it's going to give me an
  8958. 4:52:01error
  8959. 4:52:01this can't be displayed all right so
  8960. 4:52:04that's not that big of a deal but i just
  8961. 4:52:06want you to see that i'm not hiding
  8962. 4:52:07anything
  8963. 4:52:08so now let's do a session and let's do
  8964. 4:52:11something cool
  8965. 4:52:12abandoned session let's just type dollar
  8966. 4:52:15sign yes
  8967. 4:52:16yeah you're right i type in way too much
  8968. 4:52:18um equals new
  8969. 4:52:20ps session and what we've done and what
  8970. 4:52:22i want to do it to is
  8971. 4:52:24dollar sign servers boom i'm going to
  8972. 4:52:27get my sessions to these remote boxes
  8973. 4:52:29now so just so that you see i'm not
  8974. 4:52:31cheating multiple sessions
  8975. 4:52:33multiple sessions you know what i want
  8976. 4:52:35to do and this was an actual business
  8977. 4:52:37problem that i've had several
  8978. 4:52:38times um did i mention i was a web guy
  8979. 4:52:39i'm just saying anyways um
  8980. 4:52:41so here's the business problem i need to
  8981. 4:52:43deploy
  8982. 4:52:44uh actually i had a friend call me up on
  8983. 4:52:46the phone um i need to deploy a web
  8984. 4:52:4950 server website load balanced and i
  8985. 4:52:53need to copy the website out from the
  8986. 4:52:55developers and we have three months to
  8987. 4:52:57do it
  8988. 4:52:57can powershell help me with any of this
  8989. 4:53:01seriously dude when's the last time you
  8990. 4:53:04had a vacation
  8991. 4:53:06well this conversation went on for a
  8992. 4:53:07while me talking about vacations and him
  8993. 4:53:09talking about this three month long
  8994. 4:53:10project
  8995. 4:53:13let's do it so with the session that we
  8996. 4:53:16have
  8997. 4:53:16three months what's that we only have
  8998. 4:53:18like a couple hours
  8999. 4:53:20throughout three months well let's okay
  9000. 4:53:22okay
  9001. 4:53:23okay so you want to challenge me okay
  9002. 4:53:25fine okay fine so
  9003. 4:53:26invoke command on the session that i
  9004. 4:53:28just made which now is shorter dollar
  9005. 4:53:30sign s
  9006. 4:53:31here's what i want to do install windows
  9007. 4:53:34feature
  9008. 4:53:35web dash server now i know guys this
  9009. 4:53:37isn't gonna be all that cool and tricky
  9010. 4:53:39but
  9011. 4:53:39um here's the thing uh for web services
  9012. 4:53:42every component that you need of the web
  9013. 4:53:44service
  9014. 4:53:45you can just put in comma and specify
  9015. 4:53:47every single one
  9016. 4:53:48this doesn't have to be web servers this
  9017. 4:53:49could be hyper-v servers this could be
  9018. 4:53:51whatever it is you need deployed and i
  9019. 4:53:54want you to see that it's happening
  9020. 4:53:59that it pretend that the sessions for
  9021. 4:54:02dollar sign s
  9022. 4:54:03was 50 servers a thousand servers
  9023. 4:54:07now take a look comes up and as it shows
  9024. 4:54:09me as it's finishing the installation on
  9025. 4:54:10those remote boxes
  9026. 4:54:12and i'm maintaining this session so that
  9027. 4:54:13i can still do it it's not
  9028. 4:54:15serial it does it in parallel yeah it
  9029. 4:54:17does it in parallel
  9030. 4:54:18so what's happening is is that it's not
  9031. 4:54:20going to this server
  9032. 4:54:21and then going to this no it's going
  9033. 4:54:23dudes install
  9034. 4:54:27come on we're talking less than four
  9035. 4:54:29minutes i've just deployed
  9036. 4:54:31as many web servers as i want but wait
  9037. 4:54:33we're not done
  9038. 4:54:34watch there's more watch i'm just gonna
  9039. 4:54:37up arrow
  9040. 4:54:39for once and go back to this command
  9041. 4:54:42watch oh oh come on
  9042. 4:54:45oh i got oh come on yeah
  9043. 4:54:48but wait there's one more step you guys
  9044. 4:54:50we got to make our own web page right we
  9045. 4:54:51got to make our own web page
  9046. 4:54:57so three runs baby we're gonna make our
  9047. 4:54:59own web page real quick just to prove
  9048. 4:55:01that you can still do this uh yeah i
  9049. 4:55:02just make this uh default htm and when
  9050. 4:55:04students say
  9051. 4:55:05mva and powershell
  9052. 4:55:09rocks i'm going to save this i want to
  9053. 4:55:12deploy this
  9054. 4:55:14i want to deploy this so i'm going to
  9055. 4:55:16dollar sign
  9056. 4:55:17servers pipe for each
  9057. 4:55:20one of those servers i'm going to have
  9058. 4:55:23it
  9059. 4:55:24copy item god i love i love i love the
  9060. 4:55:28item commands to it to work with stuff
  9061. 4:55:30because we're going to take that default
  9062. 4:55:32htm and
  9063. 4:55:34the coolest thing about powershell
  9064. 4:55:36commandlets is they give you more
  9065. 4:55:37capabilities you've ever had before
  9066. 4:55:39because the destination
  9067. 4:55:40can be a unc so i'm going to say
  9068. 4:55:44backslash backslash dollar signup
  9069. 4:55:46remember that's the current object
  9070. 4:55:48that'll be
  9071. 4:55:48those servers and i want it to go to
  9072. 4:55:50their administrative share
  9073. 4:55:52and i want it to go to inet pub
  9074. 4:55:56this is where the default web page is is
  9075. 4:55:58stored
  9076. 4:55:59and
  9077. 4:56:03and let's go up and run it again and lo
  9078. 4:56:06and behold
  9079. 4:56:08so aruba we're going it's vacation
  9080. 4:56:12time now so in other words in just a
  9081. 4:56:14couple of minutes i've deployed
  9082. 4:56:15out in this case a web server and a
  9083. 4:56:18website it's a small demonstration but
  9084. 4:56:20the idea is this
  9085. 4:56:22it changes how you think about
  9086. 4:56:23administration now it's
  9087. 4:56:25instead of sending guys out going uh go
  9088. 4:56:27out there and install this and install
  9089. 4:56:29that and
  9090. 4:56:30let me know when you're done in three
  9091. 4:56:32months now it's get somebody with a
  9092. 4:56:34screwdriver to rack and drag these
  9093. 4:56:35things
  9094. 4:56:36as soon as they're powered up i'm going
  9095. 4:56:37to remote into these things install what
  9096. 4:56:38they need
  9097. 4:56:39i'll probably script it so i never have
  9098. 4:56:41to actually type these four commands
  9099. 4:56:43again
  9100. 4:56:43and boom it's done
  9101. 4:56:46and now that i've got the script if i
  9102. 4:56:48need to add more just add some more
  9103. 4:56:50add some more or give it to me because i
  9104. 4:56:53have a problem and you give it to me and
  9105. 4:56:55i just do it give it to you like it
  9106. 4:56:56might be more complex like i really
  9107. 4:56:58don't understand this web stuff and i
  9108. 4:56:59say
  9109. 4:57:00oh i have this problem and you can say
  9110. 4:57:02hey jeffrey here's a script i have i
  9111. 4:57:04look and i said
  9112. 4:57:05minus what if yeah do it off to a robot
  9113. 4:57:09i mean that's the thing i think that is
  9114. 4:57:11is some people just sort of don't get
  9115. 4:57:13until they get it
  9116. 4:57:14and that is the transformational effect
  9117. 4:57:17of these technologies
  9118. 4:57:18remoting in particular the fact that all
  9119. 4:57:20of a sudden you're able to do
  9120. 4:57:21just phenomenal things massive things
  9121. 4:57:26in a heartbeat things that your boss is
  9122. 4:57:28probably thinking
  9123. 4:57:29i'm just not even going to ask because
  9124. 4:57:30that's going to take so long
  9125. 4:57:32we don't do things and so you end up
  9126. 4:57:34with a sort of static
  9127. 4:57:36brittle ossified excuse me ossified i.t
  9128. 4:57:39data i.t processes and structures
  9129. 4:57:42all of a sudden now with these tools you
  9130. 4:57:44can become fast
  9131. 4:57:46you can become flexible you can become
  9132. 4:57:48agile you can do things you never
  9133. 4:57:50thought of doing before
  9134. 4:57:51all because of the power of powershell
  9135. 4:57:54well it really is transformational it is
  9136. 4:57:55transformational and also
  9137. 4:57:57my cto doesn't like the answer it's
  9138. 4:58:00going to take three months
  9139. 4:58:02he really likes it when i give him the
  9140. 4:58:04answer of
  9141. 4:58:05it'll be done within the hour as a
  9142. 4:58:07matter of fact it's done now i'm just
  9143. 4:58:09testing
  9144. 4:58:09yeah i mean that's the whole point to
  9145. 4:58:12this is that your management totally
  9146. 4:58:14changes
  9147. 4:58:14not only in scale but what's that or
  9148. 4:58:16like that guy i'll have a tea in the
  9149. 4:58:18morning
  9150. 4:58:18i'm going home yeah i'm going home
  9151. 4:58:20that's the whole thing
  9152. 4:58:21now one other thing i'm remoting that we
  9153. 4:58:23want to show you right now we're
  9154. 4:58:24promoting like
  9155. 4:58:26uh
  9156. 4:58:28[Music]
  9157. 4:58:31there's one other super cool thing in
  9158. 4:58:33remoting that we want to show you before
  9159. 4:58:34we get into the rest of scripting
  9160. 4:58:36and i have to do it with a new console
  9161. 4:58:42you know i don't i'm not going to be at
  9162. 4:58:45this machine
  9163. 4:58:46tomorrow oh oh and i you know what in
  9164. 4:58:50fact
  9165. 4:58:50when i'm out on vacation and i'm using
  9166. 4:58:53powershell web access who knows you know
  9167. 4:58:55i'm going to be at
  9168. 4:58:57some box and the thing is is that guys
  9169. 4:58:59i've been using active directory
  9170. 4:59:01commandlets i've been using all kinds of
  9171. 4:59:02stuff from modules that are
  9172. 4:59:04installed for the remote server
  9173. 4:59:06administration tools and
  9174. 4:59:08you know if i want to manage exchange i
  9175. 4:59:10i need the remote server administration
  9176. 4:59:11tools i
  9177. 4:59:12am going to need to install the exchange
  9178. 4:59:14management tools
  9179. 4:59:16and i do a lot of scvmm stuff i'm going
  9180. 4:59:18to need to install
  9181. 4:59:20oh man all the vmm management tools
  9182. 4:59:23god's going to take me a couple hours to
  9183. 4:59:25do that
  9184. 4:59:26and as soon as i go to a different
  9185. 4:59:28machine
  9186. 4:59:30and none of the commands none of the
  9187. 4:59:32modules will be there none of it exists
  9188. 4:59:34so i want to show you what i think is
  9189. 4:59:36not is is absolutely the coolest thing
  9190. 4:59:38in the world i use it constantly because
  9191. 4:59:40on my box
  9192. 4:59:42i don't install anything i don't install
  9193. 4:59:43the remote server administration tools
  9194. 4:59:44the exchange so it's nothing
  9195. 4:59:46and here's the reason why put your seat
  9196. 4:59:48belts on because this
  9197. 4:59:49is freakish freakishly powerful
  9198. 4:59:52this is this is this is the new world or
  9199. 4:59:54order because here's the deal i don't
  9200. 4:59:56have time to be installing tools
  9201. 4:59:58every time i sit down in a box and the
  9202. 4:59:59other thing is if i walk up to a server
  9203. 5:00:01or something like that
  9204. 5:00:03you're not going to be installing
  9205. 5:00:04anything on there so i need a bunch of
  9206. 5:00:06commandlets we're gonna
  9207. 5:00:07i'm gonna need the active directory
  9208. 5:00:08command i don't know why i'm starting to
  9209. 5:00:10do it like this but it's kind of like
  9210. 5:00:11watching
  9211. 5:00:11godfather yeah it's like watching god i
  9212. 5:00:13don't know what i'm doing um
  9213. 5:00:15you call me funny yeah it's funny i'm
  9214. 5:00:18funny funny
  9215. 5:00:19you say you got powershell you just
  9216. 5:00:20stick down you know so here we go
  9217. 5:00:24so what i'm going to do is i'm going to
  9218. 5:00:25create a session to the
  9219. 5:00:27servers that have the commandlets that i
  9220. 5:00:29want now think about this
  9221. 5:00:32you really want the commandments from
  9222. 5:00:34the servers that
  9223. 5:00:36naturally have them a domain controller
  9224. 5:00:38has the active directory commandments
  9225. 5:00:39an exchange 2007 server has the
  9226. 5:00:43exchange 2007 command let's an exchange
  9227. 5:00:462010 server has the exchange 2010 ones
  9228. 5:00:49i couldn't get all those tools on my box
  9229. 5:00:51if i wanted to
  9230. 5:00:52but watch and you don't want to and you
  9231. 5:00:55don't want to so dollar sign s
  9232. 5:00:56equals new ps session and in this case
  9233. 5:00:59i'm going to uh
  9234. 5:01:00i'm just going to hit a domain
  9235. 5:01:01controller
  9236. 5:01:03so i'm gonna establish a session to this
  9237. 5:01:05domain controller
  9238. 5:01:07import um ps session
  9239. 5:01:12module guys do you see what i'm doing
  9240. 5:01:15there's a module on that remote server
  9241. 5:01:17called active directory so i'm going to
  9242. 5:01:19say
  9243. 5:01:19give me that module active directory
  9244. 5:01:22now because i right now on this vm
  9245. 5:01:26i do have the rsat tools i'm going to
  9246. 5:01:27prefix this so there's a prefix and i'm
  9247. 5:01:29going to call it remote so you know it's
  9248. 5:01:31coming from somewhere else
  9249. 5:01:32then we're going to ask jeffrey how to
  9250. 5:01:34explain how this magical stuff works
  9251. 5:01:36because watch as soon as i do this
  9252. 5:01:39to oops i forgot to give it the session
  9253. 5:01:42darn dollar sign s i was going to do it
  9254. 5:01:44all in one line and i screwed it up i
  9255. 5:01:45forgot the session
  9256. 5:01:47oh yeah no you can't that's a string oh
  9257. 5:01:49it's
  9258. 5:01:50yeah so let me do this you see dollar
  9259. 5:01:52sign session there we go
  9260. 5:01:53way back machine you didn't see that
  9261. 5:01:55click click click ben and black
  9262. 5:01:56men in black men in black so module
  9263. 5:02:01session dollar sign ass
  9264. 5:02:06i don't know if you know what just
  9265. 5:02:07happened right now but check this out
  9266. 5:02:09i wonder if i have any command let's now
  9267. 5:02:11pretend that i had no active directory
  9268. 5:02:13command so what we're going to do is i
  9269. 5:02:14wonder if i have anything for remote
  9270. 5:02:16remote remote remote room ah let's do
  9271. 5:02:18this remote um
  9272. 5:02:20a.d should work
  9273. 5:02:24dudes do dude that's ducey's you see
  9274. 5:02:26what's scrolling across my screen right
  9275. 5:02:27now
  9276. 5:02:28looks and smells like i suddenly have
  9277. 5:02:30all these commandlets i just asked for
  9278. 5:02:31look at all these active directory
  9279. 5:02:32commits yes they're prefixed with remote
  9280. 5:02:34so
  9281. 5:02:35i have these command matter of fact i
  9282. 5:02:36can do this watch get
  9283. 5:02:38remote a d computer
  9284. 5:02:42filter fiddler
  9285. 5:02:45yeah this is brother anyways the star
  9286. 5:02:49so look it ran look at this look look
  9287. 5:02:52look
  9288. 5:02:53i got these commands from a server it's
  9289. 5:02:55nothing's installed how is this working
  9290. 5:02:56explain to me how this is working
  9291. 5:02:58because this is like freaking me out
  9292. 5:02:59right now it's magic baby i love
  9293. 5:03:01magic so here's the deal um here let me
  9294. 5:03:04show you this
  9295. 5:03:05so here we've been showing people get
  9296. 5:03:08command
  9297. 5:03:09or sorry get help get help but get help
  9298. 5:03:12get help
  9299. 5:03:12get process okay
  9300. 5:03:16and that gives you this but there's
  9301. 5:03:18another thing that's called get
  9302. 5:03:20command and people have often asked well
  9303. 5:03:22what's the difference between these two
  9304. 5:03:23get help versus get command and the
  9305. 5:03:25answer is that get command
  9306. 5:03:27is more structural programmatic
  9307. 5:03:30information so watch this dollar sign
  9308. 5:03:32c dollar signs hello oh wrong one
  9309. 5:03:36i'll assign c equals get command dollar
  9310. 5:03:38sign c dot
  9311. 5:03:39parameters okay and then let's take a
  9312. 5:03:42look at this parameter
  9313. 5:03:43say name oops sorry name
  9314. 5:03:48okay and look we've got all the
  9315. 5:03:49information the name its type etc yeah
  9316. 5:03:52okay
  9317. 5:03:53and so what happens is when i go and
  9318. 5:03:56i do that import what i do is i go to
  9319. 5:03:59that remote machine
  9320. 5:04:00i load the module that you asked for and
  9321. 5:04:03i do a get command on all the things
  9322. 5:04:06and i get that data structure and what i
  9323. 5:04:08do is on this side on now on
  9324. 5:04:10on my side i go and i take that
  9325. 5:04:13information
  9326. 5:04:14and i recreate a set of scripts with
  9327. 5:04:16exactly the same signature
  9328. 5:04:19and then the body of the function
  9329. 5:04:21basically says hey when you go do this
  9330. 5:04:23gather all that stuff up and run it over
  9331. 5:04:26there
  9332. 5:04:26using invoke command i don't actually
  9333. 5:04:29have these commandlets
  9334. 5:04:30on my machine i have a a a like a
  9335. 5:04:33proxy yeah or or a shortcut
  9336. 5:04:37that is saying take all the information
  9337. 5:04:39from the parameters and then go run it
  9338. 5:04:40on the desk
  9339. 5:04:41the source machine exactly so do this do
  9340. 5:04:43on your machine now
  9341. 5:04:44type get command get command get dash
  9342. 5:04:48star 80 computer get dash
  9343. 5:04:51star 80 computer
  9344. 5:04:56okay so look notice one the get 80
  9345. 5:04:59computers commandlet now that
  9346. 5:05:00that command net code okay okay but look
  9347. 5:05:04at the function
  9348. 5:05:06so now take a look and do this uh type
  9349. 5:05:10parentheses paren get command
  9350. 5:05:14get remote 80 computer
  9351. 5:05:17get remote ad computer and
  9352. 5:05:21print dot definition
  9353. 5:05:24ah definition will it ah
  9354. 5:05:28yeah so look at this this was
  9355. 5:05:30dynamically generated
  9356. 5:05:31code dynamically generated code on my
  9357. 5:05:35side
  9358. 5:05:35on your side that says grab these
  9359. 5:05:37parameters oh so you know what let me
  9360. 5:05:39just say
  9361. 5:05:39in in powershell version two was a
  9362. 5:05:42pivotal technology
  9363. 5:05:43in powershell version one uh uh
  9364. 5:05:45commandlets
  9365. 5:05:47had to be.net in powershell version two
  9366. 5:05:50we said commandlets could be dotnet
  9367. 5:05:53or powershell itself okay so now
  9368. 5:05:57powershell scripts are full commandlets
  9369. 5:06:00which you're going to see in a little
  9370. 5:06:01bit guys now this was a
  9371. 5:06:03transformational technology because what
  9372. 5:06:04it means is now the sudden
  9373. 5:06:06you can write programs which generate
  9374. 5:06:09commandlets
  9375. 5:06:10dynamically and that's what we do here
  9376. 5:06:12that's what that import ps session does
  9377. 5:06:15we go and we get a data structure we
  9378. 5:06:17have a program that
  9379. 5:06:18dynamically generates a powershell
  9380. 5:06:21script
  9381. 5:06:22that has exactly the same signature as
  9382. 5:06:25the
  9383. 5:06:25net commandlet on the remote machine has
  9384. 5:06:28exactly the same signature
  9385. 5:06:30i gather up all that information and i
  9386. 5:06:32then
  9387. 5:06:33run it on the remote machine and i think
  9388. 5:06:35what the is so to make sure the concept
  9389. 5:06:37is good
  9390. 5:06:38is that we're just like jeffrey said
  9391. 5:06:40this is
  9392. 5:06:41it looks and tastes and feels like the
  9393. 5:06:43commandlets are here on my machine but
  9394. 5:06:45they're not they're functions that are
  9395. 5:06:47going back and running it on the remote
  9396. 5:06:49machine
  9397. 5:06:49so think about this who's going to be
  9398. 5:06:51better at running get ad computer
  9399. 5:06:53anyways your box or the domain
  9400. 5:06:56controller
  9401. 5:06:57so first of all that's going to be
  9402. 5:06:59faster but you know you were telling me
  9403. 5:07:00about this scenario and
  9404. 5:07:02i i love this scenario about the guy who
  9405. 5:07:04had to do a migration from exchange
  9406. 5:07:06yeah of of um i had to
  9407. 5:07:09do a migration from exchange 2007 to
  9408. 5:07:12exchange 2010.
  9409. 5:07:13you're not going to get those tools all
  9410. 5:07:16installed on your box
  9411. 5:07:17but you can import both sets of
  9412. 5:07:20commandlets
  9413. 5:07:21prefix one with 2007 prefix another with
  9414. 5:07:242010
  9415. 5:07:25now you got both sets of commandlets all
  9416. 5:07:27in the same place
  9417. 5:07:28and you can get the two products to work
  9418. 5:07:30together exactly it was doing the
  9419. 5:07:31equivalent of like
  9420. 5:07:32get uh like i'll just say v1 v2 get v1
  9421. 5:07:36uh user pipe to set v2 user
  9422. 5:07:40right and what's happening is he's on
  9423. 5:07:41this box he's getting the
  9424. 5:07:43users from this machine and he's setting
  9425. 5:07:45them on that machine and this is the
  9426. 5:07:46power of this stuff now
  9427. 5:07:48all of a sudden i mean it used to be
  9428. 5:07:49that integration was just
  9429. 5:07:51painful right i got to find all this
  9430. 5:07:53stuff i got to get it all in this box so
  9431. 5:07:55it bloats the box i'm
  9432. 5:07:57running out of disk space oh wait this
  9433. 5:07:59guy updated something i got gotta patch
  9434. 5:08:01it
  9435. 5:08:02oh wait they require different versions
  9436. 5:08:04of stuff
  9437. 5:08:05just hideous idiots videos and now the
  9438. 5:08:08answer is
  9439. 5:08:09hey dude i'm sitting right here i import
  9440. 5:08:11the stuff from there i import the stuff
  9441. 5:08:13i
  9442. 5:08:13import the stuff i import the stuff and
  9443. 5:08:15i'm sitting here and by the way type
  9444. 5:08:17type type type type look you got tab
  9445. 5:08:19completion okay
  9446. 5:08:21so get remote and look
  9447. 5:08:24well here let me do remote so that we uh
  9448. 5:08:28look yeah also you got tab completion
  9449. 5:08:31you have help
  9450. 5:08:32everything you got everything and help
  9451. 5:08:34will discover
  9452. 5:08:35all of this so you've got full
  9453. 5:08:36discoverability you got full help
  9454. 5:08:38it looks and feels like it's here but
  9455. 5:08:40it's running in the best place
  9456. 5:08:41possible which is on those machines and
  9457. 5:08:44i didn't have to install
  9458. 5:08:45anything now this is referred to as
  9459. 5:08:47implicit remoting and you're probably
  9460. 5:08:50going to want to do this yourself it's
  9461. 5:08:51already in the slides but we'll also
  9462. 5:08:53give you some more references
  9463. 5:08:55for the implicit remoting and to be
  9464. 5:08:56honest when i'm managing i literally
  9465. 5:08:58this is what i'm doing i don't install
  9466. 5:09:00anything on my local box because i'm not
  9467. 5:09:02too sure as a consultant what box i'm
  9468. 5:09:04going to be
  9469. 5:09:05on so i'll just implicitly remote the
  9470. 5:09:07commands that i need when i need them
  9471. 5:09:09um you know what we here's the other
  9472. 5:09:12thing that's so important
  9473. 5:09:13is when i imagine i'm going to go get
  9474. 5:09:15this stuff from different things
  9475. 5:09:17uh over here i might need a different
  9476. 5:09:19set of credentials than over there
  9477. 5:09:20right so instead of having to type the
  9478. 5:09:23credentials all the time
  9479. 5:09:24you create the session with a set of
  9480. 5:09:26credentials you import the commandlets
  9481. 5:09:27those credentials are then used every
  9482. 5:09:29time and
  9483. 5:09:30guys there's a dash credential parameter
  9484. 5:09:33on this so when you create the session
  9485. 5:09:34yeah you use the credentials that you
  9486. 5:09:36want to use when you do
  9487. 5:09:38the import of the of of the modules
  9488. 5:09:41then it's you're using those credentials
  9489. 5:09:43over and over and over again so you
  9490. 5:09:44don't have to keep track of all of that
  9491. 5:09:46it's it's
  9492. 5:09:47it really makes your life a lot easier
  9493. 5:09:49and cuts down on all the minutia of
  9494. 5:09:51tools and all this kind of stuff yeah i
  9495. 5:09:53really encourage you guys to go
  9496. 5:09:55try this even if you do it locally like
  9497. 5:09:56here let me show you something i'll just
  9498. 5:09:58show you how to do it locally right
  9499. 5:09:59because it's just so freaky
  9500. 5:10:00so here uh you can do
  9501. 5:10:03uh i just say dollar sign s equals new
  9502. 5:10:05session and that'll connect to locally
  9503. 5:10:07right your local machine and then you
  9504. 5:10:09can do import
  9505. 5:10:11ps session dollar sign s
  9506. 5:10:14minus and we'll just like do one command
  9507. 5:10:17like nice command
  9508. 5:10:18get process minus prefix
  9509. 5:10:22prefix wow right and so all of a sudden
  9510. 5:10:25you get get
  9511. 5:10:27wow process
  9512. 5:10:31and and it just works okay
  9513. 5:10:34so the point is you know just try it
  9514. 5:10:36right because you don't necessarily have
  9515. 5:10:38to have access to some remote machine
  9516. 5:10:39with the main controllers and all that
  9517. 5:10:41stuff you can do it on your local box
  9518. 5:10:43uh but it is so freakishly cool i mean
  9519. 5:10:45you just want to have fun with it
  9520. 5:10:47it's seriously going to solve a lot of
  9521. 5:10:49business problems for you going forward
  9522. 5:10:51i mean just grabbing the commands from
  9523. 5:10:53the machines that have them you've got
  9524. 5:10:54the correct versions
  9525. 5:10:56you know of whatever product you're
  9526. 5:10:57working with implicit remoting is truly
  9527. 5:10:59a godsend
  9528. 5:11:00for this now guys we're going to take
  9529. 5:11:02another 10 minute break and we're going
  9530. 5:11:03to have our last session
  9531. 5:11:05for today for today today and it's going
  9532. 5:11:08to be
  9533. 5:11:09on we're going to start scripting we're
  9534. 5:11:11going to start
  9535. 5:11:12seeing what the script looks like so
  9536. 5:11:14come back and join us in 10 minutes and
  9537. 5:11:15let's automate
  9538. 5:11:16and then in two weeks we do the advanced
  9539. 5:11:18one now the advanced one
  9540. 5:11:20we roll up our well they already rolled
  9541. 5:11:22up we roll up our sleeves and we get
  9542. 5:11:24into the scripting the automation et
  9543. 5:11:26cetera
  9544. 5:11:27yeah the hardcore stuff but this is a
  9545. 5:11:28taste that i think you're going to enjoy
  9546. 5:11:30and it'll get you working
  9547. 5:11:31and it'll get you prepped for what you
  9548. 5:11:32need in two weeks so see you in 10
  9549. 5:11:38[Music]
  9550. 5:11:44minutes
  9551. 5:11:52[Music]
  9552. 5:12:00and and we're back for our last session
  9553. 5:12:03for today
  9554. 5:12:04last and best last and best session for
  9555. 5:12:06today guys before we forget we should
  9556. 5:12:08just give a super shout out to the mvps
  9557. 5:12:10uh
  9558. 5:12:10answering all those great questions yeah
  9559. 5:12:13thank you
  9560. 5:12:14again uh just representative example of
  9561. 5:12:16the awesome powershell community
  9562. 5:12:18join be part of the powershell community
  9563. 5:12:20let's go
  9564. 5:12:21and so guys what we're going to do is
  9565. 5:12:23this is kind of a warm-up for what we're
  9566. 5:12:24going to do on august 1st where we go
  9567. 5:12:25through all the details in this this is
  9568. 5:12:28more than just a warm-up though you can
  9569. 5:12:30start immediately using this today i
  9570. 5:12:31like to refer to this as immediately
  9571. 5:12:33effective and so
  9572. 5:12:34let's start off with though
  9573. 5:12:38thank god you're not physically in this
  9574. 5:12:41room because
  9575. 5:12:43what i'm about to show you i've actually
  9576. 5:12:45had people threaten to hit me
  9577. 5:12:48oh so you have to imagine that no don't
  9578. 5:12:51hit me man don't
  9579. 5:12:52you just got punched by jeffrey snowden
  9580. 5:12:54that's going to look really good on my
  9581. 5:12:55resume
  9582. 5:12:56um so we've been spending all of our
  9583. 5:12:59time
  9584. 5:12:59in the console and god i love the
  9585. 5:13:02console and we've been working on
  9586. 5:13:03commands and here's what you want to do
  9587. 5:13:04you want to work stuff out in here
  9588. 5:13:06copy it and like we did earlier paste it
  9589. 5:13:08into a script but i want to show you
  9590. 5:13:10something that comes with
  9591. 5:13:12powershell and it's the ise and
  9592. 5:13:15yeah i know and this is where so i'm
  9593. 5:13:17going to close this console and guys i
  9594. 5:13:18want to show you this real quick so that
  9595. 5:13:20we can kind of get into it but
  9596. 5:13:22i'm going to start the ise and you know
  9597. 5:13:25they're going to do that
  9598. 5:13:25picture-in-picture thing so let me lower
  9599. 5:13:27this thing down here a little bit
  9600. 5:13:30now i'm going to show you don't yell at
  9601. 5:13:32me please don't yell at me first of all
  9602. 5:13:34there's a scripting pane up here down
  9603. 5:13:36here is a console pane then there's this
  9604. 5:13:38commands pane i'm going to
  9605. 5:13:40simplify this screen real quick
  9606. 5:13:44and i want to show you these buttons
  9607. 5:13:45across the top you can have
  9608. 5:13:47the the scripting pane on top and a
  9609. 5:13:49console on the bottom you can have them
  9610. 5:13:51side by side which if you have two
  9611. 5:13:52monitors
  9612. 5:13:53this is awesome yeah to put this between
  9613. 5:13:55the dual monitors
  9614. 5:13:56but i'm going to make it even simpler
  9615. 5:13:58i'm just going to go to one pane and so
  9616. 5:14:00i can kind of shorten things up a little
  9617. 5:14:01bit here
  9618. 5:14:03and and bring this down a little bit
  9619. 5:14:05here's the part that you're going to
  9620. 5:14:07threaten to beat me to death with i'm
  9621. 5:14:09going to hit control r that flips me
  9622. 5:14:11between
  9623. 5:14:11the scripting pane and the console and
  9624. 5:14:14you might be asking yourself
  9625. 5:14:15well this looks kind of like a console
  9626. 5:14:18yeah this is a damn fine console
  9627. 5:14:20remember this morning
  9628. 5:14:22when we were talking and jeffrey was
  9629. 5:14:23saying hey look we can't touch
  9630. 5:14:25that original console thing that you
  9631. 5:14:27know controller
  9632. 5:14:29huh i didn't know that what controller
  9633. 5:14:32yeah it's awesome
  9634. 5:14:33oh i keep trying to remember control d
  9635. 5:14:35versus control i
  9636. 5:14:36like d what the hell is no i think i
  9637. 5:14:38think bruce pan i think bruce payette
  9638. 5:14:40did something with control r and i'm
  9639. 5:14:41like
  9640. 5:14:42so yeah controller oh i've learned
  9641. 5:14:44something oh that's
  9642. 5:14:45uh yeah right on bro so here's the deal
  9643. 5:14:49i'm going to type something here and
  9644. 5:14:51you're going to see that this is not the
  9645. 5:14:53console that
  9646. 5:14:54you think we are first of all let me
  9647. 5:14:56clear it up now watch
  9648. 5:14:58i'm going to do get
  9649. 5:15:01look at what it's doing look at what
  9650. 5:15:02it's doing
  9651. 5:15:04dude this is like it's it's intellisense
  9652. 5:15:08helping me through here this is like
  9653. 5:15:10totally awesome and watch
  9654. 5:15:12you might notice that it's also
  9655. 5:15:16color syntax so
  9656. 5:15:20here's the deal and we're going to ask
  9657. 5:15:21jeffrey about this because
  9658. 5:15:23this is the coolest thing in the world
  9659. 5:15:25you've got a console that has color
  9660. 5:15:26syntax coding which
  9661. 5:15:27helps a lot when you're typing to see if
  9662. 5:15:30you're typing an error
  9663. 5:15:31and it's got this help flying at me as
  9664. 5:15:34i'm typing
  9665. 5:15:37is this your solution to the the the
  9666. 5:15:39console going forward is it because
  9667. 5:15:40this makes it makes it a lot easier yeah
  9668. 5:15:42right take spend a couple of
  9669. 5:15:44hours with this and stop asking me about
  9670. 5:15:46improving the console
  9671. 5:15:47that's that which is what the thing was
  9672. 5:15:49this morning is don't ask about
  9673. 5:15:50improving the console because they're
  9674. 5:15:52doing it right now and this is the way
  9675. 5:15:54to do it so
  9676. 5:15:55let's use this console and let's let's
  9677. 5:15:57let's take a command here let's do a git
  9678. 5:15:59wmi object yeah
  9679. 5:16:00it's okay it's okay we'll all be good
  9680. 5:16:02win32 underscore logical disk
  9681. 5:16:04i just want to show you i want to get
  9682. 5:16:05something to work and i'm going to type
  9683. 5:16:06something in you probably haven't seen
  9684. 5:16:07before
  9685. 5:16:08you will but i'm going to do device
  9686. 5:16:12filter on device id equals
  9687. 5:16:16c i want you to see what it gives me as
  9688. 5:16:19an output well
  9689. 5:16:20absolutely nothing because i screwed up
  9690. 5:16:22the filter
  9691. 5:16:24and so what this command now gives me is
  9692. 5:16:27it gives me some useful information it's
  9693. 5:16:28giving me um i'm having a scroll issue
  9694. 5:16:30here hang on
  9695. 5:16:32it's giving my drive c and it gives me
  9696. 5:16:33free space and size i don't like the
  9697. 5:16:35numbers
  9698. 5:16:36so i'm going to do something in flight i
  9699. 5:16:38want you to notice i'm building a
  9700. 5:16:40command to make sure that it works first
  9701. 5:16:42and then i'm going to show you how easy
  9702. 5:16:43cool this gets so
  9703. 5:16:46what i'd like is i'd like to select and
  9704. 5:16:49i'm only going to take one property for
  9705. 5:16:50this demonstration so i'd like to use
  9706. 5:16:52the free space
  9707. 5:16:53but you know what i can't stand is okay
  9708. 5:16:57let's just do free space watch
  9709. 5:17:00i i don't know about you but i don't
  9710. 5:17:02really like that number because that
  9711. 5:17:03number is like in bytes and
  9712. 5:17:05it's like not making me happy because i
  9713. 5:17:08want to see it like gigabytes or
  9714. 5:17:09something like that
  9715. 5:17:10because can't point sit down yeah
  9716. 5:17:13so you did get wmi object do get sim
  9717. 5:17:16object
  9718. 5:17:18and then yeah wait yeah no let's start
  9719. 5:17:20from scratch
  9720. 5:17:21okay let's start from scratch you want
  9721. 5:17:24you want get
  9722. 5:17:24sim object get sim object get sim object
  9723. 5:17:28or sim instance instant sorry yeah and
  9724. 5:17:30say win32
  9725. 5:17:32lodge and then tap tap tap
  9726. 5:17:43and then control space control space
  9727. 5:17:47and then control space
  9728. 5:17:54that's awesome intellisense against the
  9729. 5:17:56wmi namespaces
  9730. 5:17:58oh and guys when you start working with
  9731. 5:18:00wmi one of the hardest things is dealing
  9732. 5:18:02with the namespaces and finding the
  9733. 5:18:03classes and this is one of the most
  9734. 5:18:05important technologies out there we
  9735. 5:18:06haven't had time today to go through it
  9736. 5:18:07but
  9737. 5:18:08this is awesome oh yeah
  9738. 5:18:12yeah so and you're going to be wanting
  9739. 5:18:13to use get some instance instead of the
  9740. 5:18:15old-fashioned command that i'm going to
  9741. 5:18:16use right now
  9742. 5:18:18okay and so i'm going to do select free
  9743. 5:18:21space i can't stand that number so
  9744. 5:18:23i'm going to do a custom column i'm
  9745. 5:18:25going to just like we had done earlier
  9746. 5:18:27because i don't like that i'm going to
  9747. 5:18:28create my own there's a reason i'm doing
  9748. 5:18:30this but don't panic we're almost there
  9749. 5:18:32and so i'm going to call it free gb
  9750. 5:18:36and uh oops would help if i put in
  9751. 5:18:38something to tell it what i was doing
  9752. 5:18:40and you're not showing the best
  9753. 5:18:44practices
  9754. 5:18:47hit the cancel up to the pipeline and
  9755. 5:18:50now it hit carriage turn oh well but
  9756. 5:18:54but but oh it doesn't do that in the ise
  9757. 5:18:57it doesn't only in the console
  9758. 5:18:59i i know what you so here's what jeffrey
  9759. 5:19:01is saying and i'll show it to you in
  9760. 5:19:02there
  9761. 5:19:02and in here so because i want you to see
  9762. 5:19:04this because you guys this will actually
  9763. 5:19:06be really interesting
  9764. 5:19:08i want you to see that watch so i'm
  9765. 5:19:10doing this this long line here get wmi
  9766. 5:19:13object win32 underscore logical disk
  9767. 5:19:17logical desk
  9768. 5:19:19filter and device id
  9769. 5:19:24equals c colon and guys here's the thing
  9770. 5:19:28is that i want to that's great and
  9771. 5:19:29that's fine that's dandy
  9772. 5:19:31but i'm going to start typing this long
  9773. 5:19:33command that's going to be wrapping
  9774. 5:19:34around
  9775. 5:19:35a really great great way to work at the
  9776. 5:19:37console is to realize that
  9777. 5:19:39there are certain things that
  9778. 5:19:40automatically give us line continuation
  9779. 5:19:42the pipeline being one of them watch
  9780. 5:19:44what happens here when i strike in or
  9781. 5:19:46after the pipeline see these things
  9782. 5:19:51this means i'm not sure but it means
  9783. 5:19:55you're you're we i we get it you're
  9784. 5:19:57still on the same line
  9785. 5:19:58just keep typing so from here i can do
  9786. 5:20:00my select
  9787. 5:20:02it becomes easier to read and it's
  9788. 5:20:04easier to edit when you're doing stuff
  9789. 5:20:06in real time
  9790. 5:20:07um select and i'll do my
  9791. 5:20:10at n equals uh
  9792. 5:20:13free gb and
  9793. 5:20:17oops uh it's late in the day x e
  9794. 5:20:20equals and i'm going to take the current
  9795. 5:20:23object across the pipeline i'm going to
  9796. 5:20:24grab its free space
  9797. 5:20:26and i want to see it in gigabyte so i'm
  9798. 5:20:27going to divide it by
  9799. 5:20:301gb we have these built-in things to
  9800. 5:20:32help us with math because i'm not good
  9801. 5:20:33at math so
  9802. 5:20:34these help me with math and so the
  9803. 5:20:36number looks a strike enter on this line
  9804. 5:20:38number looks better
  9805. 5:20:39but i'd like it all rounded up so i'm
  9806. 5:20:41just going to do this as an integer real
  9807. 5:20:43quick
  9808. 5:20:44now i'm going to do it as an integer
  9809. 5:20:48real quick
  9810. 5:20:48but it's going to yell at me because i
  9811. 5:20:49didn't run both lines
  9812. 5:20:52so let me do this no that's fine that's
  9813. 5:20:54fine and so as int
  9814. 5:20:57and oops now i screwed something up
  9815. 5:20:59right hang on brackets i forgot the
  9816. 5:21:01brackets
  9817. 5:21:03i'll get you a good line of code don't
  9818. 5:21:05panic this is all in the slides too so
  9819. 5:21:07if i can't fail to type
  9820. 5:21:09boom so i've got a nice line now
  9821. 5:21:12i've got something that's giving me
  9822. 5:21:13information that i want it's pretty cool
  9823. 5:21:15got it all worked out what i'm going to
  9824. 5:21:17do is
  9825. 5:21:18cut and paste now from here you know cut
  9826. 5:21:19and paste is kind of hard to do but if
  9827. 5:21:21you did this over here
  9828. 5:21:23cut and paste is really easy to do
  9829. 5:21:24because you know what's funny is they
  9830. 5:21:26figured out how to use things like oh
  9831. 5:21:28let's see and this old this old
  9832. 5:21:30technology called
  9833. 5:21:31control c control v so i'm going to say
  9834. 5:21:34control c
  9835. 5:21:35i'm going to hit control r to flip the
  9836. 5:21:36screen so i'm going to control v
  9837. 5:21:39oh yeah baby now i've got my line
  9838. 5:21:42now we're going to start having some fun
  9839. 5:21:43because we're going to save this as a
  9840. 5:21:44script right now
  9841. 5:21:45file save as we'll uh
  9842. 5:21:49save it uh here in my scripts folder
  9843. 5:21:52we're gonna save it as uh well we did i
  9844. 5:21:53love you uh
  9845. 5:21:54let's do this as let's just call it disk
  9846. 5:21:56info dot ps1
  9847. 5:21:59and i can run it from right here if i
  9848. 5:22:01run it boom shows me a result
  9849. 5:22:02uh it helps if i clear the screen and
  9850. 5:22:05everything else i typed but
  9851. 5:22:07i can run it oink and it shows me the
  9852. 5:22:09results i'm going to hit control r
  9853. 5:22:11everything's good now we want to start
  9854. 5:22:14adding stuff to this
  9855. 5:22:16so let's make this a little better first
  9856. 5:22:17of all you know this is a nice script
  9857. 5:22:19and all this but if i give it to
  9858. 5:22:20somebody else all it's doing right now
  9859. 5:22:21is getting
  9860. 5:22:22information off the c drive on the local
  9861. 5:22:24machine that's not
  9862. 5:22:25cool i wanted to be able to get it from
  9863. 5:22:32whatever computer i want it to get it
  9864. 5:22:34from now i can sit here and hard code
  9865. 5:22:35this
  9866. 5:22:37dude computer name right i'm not
  9867. 5:22:40spelling anything right
  9868. 5:22:41computer
  9869. 5:22:46name localhost and this will work but
  9870. 5:22:50yeah go ahead and save it that's fine
  9871. 5:22:53but
  9872. 5:22:54here's the problem if i give this to a
  9873. 5:22:57friend
  9874. 5:22:59what are they going to have to do
  9875. 5:23:00they're going to have to go in here and
  9876. 5:23:02edit my script and i don't want people
  9877. 5:23:05editing my script
  9878. 5:23:06what could possibly go wrong especially
  9879. 5:23:08if you digitally signed it
  9880. 5:23:10especially if i digitally signed it so
  9881. 5:23:12what i'm going to do is let's do a
  9882. 5:23:13simple concept
  9883. 5:23:14let's make a variable up here called
  9884. 5:23:16dollar sign computer name
  9885. 5:23:18and let's set it right now equal to
  9886. 5:23:20localhost just to have
  9887. 5:23:21some value in there and instead of
  9888. 5:23:24we'll put the variable in here now this
  9889. 5:23:26is kind of common to a lot of other
  9890. 5:23:28scripting languages where
  9891. 5:23:29what you would do is you put your
  9892. 5:23:32variables up here so you'd make it
  9893. 5:23:33easier
  9894. 5:23:35for somebody to edit your script i still
  9895. 5:23:38don't like this
  9896. 5:23:39whole editing my script thing but i want
  9897. 5:23:41you to see that this still works right
  9898. 5:23:43all i'm doing is
  9899. 5:23:44is putting it into dollar sign computer
  9900. 5:23:46name still prints it out
  9901. 5:23:47everything's cool you know
  9902. 5:23:51let me show you how to test the script
  9903. 5:23:53properly from the console
  9904. 5:23:55because i'm about to blow your mind
  9905. 5:23:57something that these guys have done
  9906. 5:23:58is awesome so let's run the script from
  9907. 5:24:01the console since a lot of scripts get
  9908. 5:24:03run from the console i actually like to
  9909. 5:24:04test them from there
  9910. 5:24:06yep cds
  9911. 5:24:10and so we called this disk info
  9912. 5:24:13run it we're good happy happy happy
  9913. 5:24:16happy but you know what
  9914. 5:24:18i've been learning powershell and as an
  9915. 5:24:21administrator
  9916. 5:24:23this isn't exactly what i expect i
  9917. 5:24:25expect i don't want to
  9918. 5:24:26go in and edit computer name no when we
  9919. 5:24:29have commandlets and stuff
  9920. 5:24:31we get parameters that we can adjust so
  9921. 5:24:34you know would be really cool
  9922. 5:24:36i think i think it'd be really cool if
  9923. 5:24:39there's this special keyword called
  9924. 5:24:42param
  9925. 5:24:44open parentheses close parentheses
  9926. 5:24:50indent so that jeffrey loves you that's
  9927. 5:24:52right
  9928. 5:24:53make it look pretty i want you guys to
  9929. 5:24:55notice something i'm going to save this
  9930. 5:24:57so i'm going to hit ctrl s
  9931. 5:24:58and save it i'm going to go back to my
  9932. 5:25:00powershell console
  9933. 5:25:04and watch this i'm going to clear the
  9934. 5:25:05screen dot disk info
  9935. 5:25:08dash oh
  9936. 5:25:15i just made a parameter oh it was so
  9937. 5:25:18easy
  9938. 5:25:19to make a parameter so now i can type in
  9939. 5:25:21any computer i want
  9940. 5:25:23now i'm not selecting out a computer
  9941. 5:25:25name which we will fix but i want you to
  9942. 5:25:27kind of get the concept of
  9943. 5:25:30i just put a variable in here matter of
  9944. 5:25:31fact let's do another one let's just
  9945. 5:25:32call it bogus
  9946. 5:25:34just so you can see i'm going to go back
  9947. 5:25:36here watch watch my chest it's so cool
  9948. 5:25:40um let's do
  9949. 5:25:45i'm making parameters on the fly for
  9950. 5:25:47whatever i need
  9951. 5:25:49this is becoming what's called a
  9952. 5:25:50parameterized
  9953. 5:25:52script and what you're getting is it's
  9954. 5:25:54starting to
  9955. 5:25:55kind of smell look and feel more like a
  9956. 5:25:58commandlet
  9957. 5:25:59it's making my life a little bit easier
  9958. 5:26:02i'm liking this so let's try this i i
  9959. 5:26:06there's another thing that would be
  9960. 5:26:07really nice is if if
  9961. 5:26:09for for an instance at least get help
  9962. 5:26:12dot
  9963. 5:26:12disk uh info yeah
  9964. 5:26:16look at what powershell is doing
  9965. 5:26:17powershell is starting to build that
  9966. 5:26:19syntax for me but i a computer name it
  9967. 5:26:22says it's an
  9968. 5:26:23object no uh let me go in here and you
  9969. 5:26:25can strongly type what the variables
  9970. 5:26:28are we didn't haven't talked much about
  9971. 5:26:29that but i want this to be a
  9972. 5:26:31string so when i go out here and do this
  9973. 5:26:34again
  9974. 5:26:37notice it's now making it a string and i
  9975. 5:26:39want you to notice that between the
  9976. 5:26:41chihuahuas it says string it doesn't say
  9977. 5:26:43that it can take multiple objects we
  9978. 5:26:44don't have any of the binkies in there
  9979. 5:26:46so here's how we put binkies in there
  9980. 5:26:50[Music]
  9981. 5:26:54and
  9982. 5:26:56i'm starting to actually get syntax now
  9983. 5:26:58built on these parameters
  9984. 5:27:00and the only thing i've had to do so far
  9985. 5:27:02is add one keyword different from what
  9986. 5:27:04i'm used to and this one called param
  9987. 5:27:06but wait there's more oh wait it gets
  9988. 5:27:08better
  9989. 5:27:10we're going to turn something on so that
  9990. 5:27:12you can use
  9991. 5:27:14parameter attributes yeah so let's do
  9992. 5:27:17commandlet binding
  9993. 5:27:20this turns on something called parameter
  9994. 5:27:22attributes and here's the thing i don't
  9995. 5:27:23really want to have local host in here
  9996. 5:27:25what i want to do oh whatever
  9997. 5:27:27just hit save just hit save yeah yeah
  9998. 5:27:29and now do get help
  9999. 5:27:30okay oh i see what he okay now what what
  10000. 5:27:33he added one line of code one line
  10001. 5:27:35one line of code and watch what happens
  10002. 5:27:39what well that wasn't that wasn't it did
  10003. 5:27:41i save it i think i saved it
  10004. 5:27:43oh well we got common parameters so yeah
  10005. 5:27:45it did okay we just need to do the
  10006. 5:27:47um yeah so we got common parameters so
  10007. 5:27:49this is actually making the syntax full
  10008. 5:27:51watch watch so command binding will let
  10009. 5:27:54us
  10010. 5:27:54use something called parameter
  10011. 5:27:56attributes things like making things
  10012. 5:27:58mandatory
  10013. 5:27:59let me show you an example i'm going to
  10014. 5:28:00get rid of this default
  10015. 5:28:03and i'm going to go in here and i'm
  10016. 5:28:06going to say
  10017. 5:28:08uh parameter i got to spell this right
  10018. 5:28:13mandatory mandatory
  10019. 5:28:16equals true and i think i got the syntax
  10020. 5:28:20correct now i want to point out that
  10021. 5:28:22this is a parameter attribute i'm going
  10022. 5:28:23to say mandatory is true it only affects
  10023. 5:28:26the next parameter after it's not going
  10024. 5:28:27to affect bogus
  10025. 5:28:29so watch look at what happens to the
  10026. 5:28:31syntax on this
  10027. 5:28:33notice up here
  10028. 5:28:36i had the brackets around it now look
  10029. 5:28:38there's no brackets around that this is
  10030. 5:28:40going to become mandatory so watch as i
  10031. 5:28:42start to try to run this
  10032. 5:28:44i'm going to do disk info i'm going to
  10033. 5:28:47run it
  10034. 5:28:48oh you got to give me a computer name
  10035. 5:28:49man so it's mandatory now
  10036. 5:28:52dc and now it works i can do it
  10037. 5:28:56i've made it mandatory i can also then
  10038. 5:28:58do
  10039. 5:28:59of course i've got the actual parameter
  10040. 5:29:01so in just
  10041. 5:29:02two lines of code we're making our own
  10042. 5:29:05parameters
  10043. 5:29:06on our script a parameterized script and
  10044. 5:29:08we're getting syntax but you know what i
  10045. 5:29:10want to be a nice guy when i give this
  10046. 5:29:11to somebody else
  10047. 5:29:12i want to be a really nice guy when i
  10048. 5:29:14give it to you i want to be a great guy
  10049. 5:29:16so what do you say we add in a little
  10050. 5:29:18bit of help i love it
  10051. 5:29:19love it let's do some help guys this is
  10052. 5:29:22a uh
  10053. 5:29:24a a block comment now usually when you
  10054. 5:29:27type in comments see how they're in
  10055. 5:29:28green
  10056. 5:29:29usually the the parsing engine that will
  10057. 5:29:31just ignore what's ever in there but
  10058. 5:29:33with power shell watch i'm just going to
  10059. 5:29:35type in a couple of things synopsis
  10060. 5:29:38i'm going to say this is the short
  10061. 5:29:41explanation
  10062. 5:29:42it's okay if i have typing mistakes at
  10063. 5:29:43this point because tired
  10064. 5:29:46description this is the long
  10065. 5:29:49disc yeah everybody's gonna be making
  10066. 5:29:51fun of me because i can't type in i'm
  10067. 5:29:53gonna type in
  10068. 5:29:54parameter whoops what's what
  10069. 5:29:57parameter and i'm going to say computer
  10070. 5:29:59name
  10071. 5:30:01and i'm going to say this is for remote
  10072. 5:30:03computers
  10073. 5:30:04and just just a couple more things here
  10074. 5:30:06real quick uh example
  10075. 5:30:08um let's do an example of uh oh let's do
  10076. 5:30:11uh
  10077. 5:30:12disk info uh dash computer name
  10078. 5:30:16you know remote and let's do one more
  10079. 5:30:19this is for this can we do an example
  10080. 5:30:23this oh
  10081. 5:30:28remote computer watch
  10082. 5:30:31look guys just a couple of things this
  10083. 5:30:34is going to be totally amazing
  10084. 5:30:37let's do this all over watch much get
  10085. 5:30:39help
  10086. 5:30:44lookie does it look like powershell help
  10087. 5:30:47now
  10088. 5:30:49so i've got i've got name synopsis look
  10089. 5:30:52it's building the syntax i got
  10090. 5:30:53description but wait that's the
  10091. 5:30:55short help watch watch one watch full
  10092. 5:30:59oh now look what powershell's built for
  10093. 5:31:02me it shows me the parameters the
  10094. 5:31:03parameter definitions
  10095. 5:31:05it's going to i've got an example down
  10096. 5:31:07here for crying out loud
  10097. 5:31:08this is what i want i want to give this
  10098. 5:31:10to somebody else that works with
  10099. 5:31:11powershell because this is what they
  10100. 5:31:13expect
  10101. 5:31:14oh this is making me so happy now can i
  10102. 5:31:17just point something out yes
  10103. 5:31:18absolutely i can never remember any of
  10104. 5:31:20this i can't remember any of this either
  10105. 5:31:22well you did well that's pretty good i
  10106. 5:31:24can't do that
  10107. 5:31:25so show them the amazing control j so
  10108. 5:31:28guys
  10109. 5:31:30i'm going to hit the only way i can deal
  10110. 5:31:32with it and and here's the thing
  10111. 5:31:33and when we come back on august 1st this
  10112. 5:31:35is going to become one of your best
  10113. 5:31:36friends so
  10114. 5:31:37i'm going to start a new tab just i'm
  10115. 5:31:39going to hit ctrl j it's going to bring
  10116. 5:31:41up snippets now i want to point
  10117. 5:31:42something out
  10118. 5:31:43i'm not quite done with this
  10119. 5:31:44demonstration yet but these snippets
  10120. 5:31:46look at this
  10121. 5:31:47commandlet snippet it gives you
  10122. 5:31:50the basics of putting this together and
  10123. 5:31:53the advanced one the complete one
  10124. 5:31:54is super rock and cool but we've got
  10125. 5:31:57comment blocks and we've got
  10126. 5:31:59some of the the constructs and then the
  10127. 5:32:01loops that we're going to be using on
  10128. 5:32:02august 1st that you'll be able to
  10129. 5:32:04work with to help you build this um
  10130. 5:32:08so you could actually pick a a snippet
  10131. 5:32:11and look it auto creates all these
  10132. 5:32:14possibilities for you and oh look
  10133. 5:32:16it see all you got to do now is just go
  10134. 5:32:18in and so if you
  10135. 5:32:19are a deeply flawed human like me and
  10136. 5:32:21cannot smell synopsis
  10137. 5:32:25this is what my problem is so you can
  10138. 5:32:28use this as a
  10139. 5:32:29template and to fill it up but wait
  10140. 5:32:32there's more we're not done yet because
  10141. 5:32:33here's the deal um this is nice this is
  10142. 5:32:36a parameterized script and you can do
  10143. 5:32:38a lot of powerful things with
  10144. 5:32:40parameterized scripts but you know
  10145. 5:32:43i want to take this to the next level
  10146. 5:32:44just a little bit more so you can get an
  10147. 5:32:46idea of where we're going to go on
  10148. 5:32:47august 1st take it to 11.
  10149. 5:32:49take a tool my amp goes to 11. it does
  10150. 5:32:53um so we're going to go we're going to
  10151. 5:32:54crank this bad boy up because
  10152. 5:32:56my ise goes to 11. save script no let's
  10153. 5:32:59do this
  10154. 5:33:01so that you can see the typing what i'm
  10155. 5:33:03going to do is i'm going to remove the
  10156. 5:33:05help for it right now
  10157. 5:33:07okay so don't don't freak out on me i'm
  10158. 5:33:08just going to are you doing that well
  10159. 5:33:10because i want them to oh i guess i can
  10160. 5:33:11just scroll yeah
  10161. 5:33:12no click click the button oh click the
  10162. 5:33:14button on you just
  10163. 5:33:16collapse yeah oh because highest c goes
  10164. 5:33:19to the left oh yeah because ise goes to
  10165. 5:33:2111 so
  10166. 5:33:22here we go guys right now we're running
  10167. 5:33:25this like a script i don't know about
  10168. 5:33:26you but we ain't done this all day long
  10169. 5:33:28we haven't typed in and run this script
  10170. 5:33:30what we've been doing is we've been
  10171. 5:33:31running things
  10172. 5:33:32like verb dash noun verb dash noun
  10173. 5:33:36god i'd like to do the same thing too if
  10174. 5:33:38only i knew how
  10175. 5:33:40well here's how i'm going to add one
  10176. 5:33:43more keyword
  10177. 5:33:45to your day of fun function you need to
  10178. 5:33:49give it a name now we're going to give
  10179. 5:33:51it a proper name
  10180. 5:33:52verb dash now don't do this
  10181. 5:33:57gimme dash stuff no
  10182. 5:34:00gimme is not on the improved verb list
  10183. 5:34:02so knock it off with making up your own
  10184. 5:34:04verbs
  10185. 5:34:04there's and everybody uh you got to do
  10186. 5:34:07it at least once right but here we're
  10187. 5:34:08going to do get dash and we're just
  10188. 5:34:10going to call it disk info
  10189. 5:34:12now the function it has an open squiggly
  10190. 5:34:14and then when you're done with your code
  10191. 5:34:16all the way at the end
  10192. 5:34:17but wait what we're going to we're going
  10193. 5:34:19to do i see later
  10194. 5:34:21we going to do what we're going to talk
  10195. 5:34:22about ise a lot next time
  10196. 5:34:24yeah oh yeah yeah yeah yeah what do you
  10197. 5:34:26what do you want him to see get rid of
  10198. 5:34:27the last squiggle
  10199. 5:34:29the the last one get rid of the last
  10200. 5:34:31squiggle
  10201. 5:34:32okay see the first squiggle see that
  10202. 5:34:33squig see the red oh yeah yeah
  10203. 5:34:36missing clothes so it's trying to help
  10204. 5:34:39us
  10205. 5:34:40understand where we're making that cool
  10206. 5:34:41so you see that little squiggle it's
  10207. 5:34:43actually pretty useful
  10208. 5:34:44and you guys see on the screen the
  10209. 5:34:45little red squiggly that jeffrey's
  10210. 5:34:46talking about is this one right here and
  10211. 5:34:48so if you leave your mouse over it it
  10212. 5:34:49tells you
  10213. 5:34:50hey you're missing something here bro
  10214. 5:34:52and in this case dude
  10215. 5:34:54dude and so we're we're missing that
  10216. 5:34:56bottom squiggly now really going to like
  10217. 5:34:58two
  10218. 5:34:59yeah exactly so i'm going to
  10219. 5:35:02indent this so that it's easier to read
  10220. 5:35:05so you can see that i have a function
  10221. 5:35:06now
  10222. 5:35:08don't do what i'm about to do because
  10223. 5:35:10this is just i'm going to show you
  10224. 5:35:11something much cooler than this i'm
  10225. 5:35:12going to save this
  10226. 5:35:13and i want to show you here's one of the
  10227. 5:35:15interesting things
  10228. 5:35:17i'd like to run that script and then use
  10229. 5:35:18that function well
  10230. 5:35:20here's the challenging thing watch if i
  10231. 5:35:22run disk info and i hit enter
  10232. 5:35:24what happens when you run a script is
  10233. 5:35:26the script runs it executes
  10234. 5:35:28and then everything is discarded out of
  10235. 5:35:30memory this is a good thing
  10236. 5:35:32but here's the problem i just ran a
  10237. 5:35:34script and it has a function called get
  10238. 5:35:36disk info
  10239. 5:35:37so what happened is the script just ran
  10240. 5:35:39it just made this function up in memory
  10241. 5:35:41for me
  10242. 5:35:42and when the script ended it just killed
  10243. 5:35:45it
  10244. 5:35:46so there is no get disk info no no so
  10245. 5:35:48i'll
  10246. 5:35:49show you a unique way to do this now
  10247. 5:35:51this is a great way for testing but i i
  10248. 5:35:52got a better solution for you
  10249. 5:35:54dot space
  10250. 5:35:58i know i love it no it's awesome this
  10251. 5:36:01retains the stuff in your script in
  10252. 5:36:04memory so watch i'm going to run it it's
  10253. 5:36:06not the right explanation okay but
  10254. 5:36:08to tell them okay so here's the way it
  10255. 5:36:10works so what happens is there's a stack
  10256. 5:36:12right and so what happens is uh when you
  10257. 5:36:15run something in general
  10258. 5:36:16you create a new stack and you put all
  10259. 5:36:19your variables in that stack
  10260. 5:36:21and then when you do an exit or a return
  10261. 5:36:23that stack goes away and they all get
  10262. 5:36:24cleared up
  10263. 5:36:26when you dot something what happens is
  10264. 5:36:28it runs it doesn't create a new stack
  10265. 5:36:30it runs it in the current stack so any
  10266. 5:36:32new variables or anything that gets
  10267. 5:36:34created they get created here when you
  10268. 5:36:36exit you just exit but they stick around
  10269. 5:36:38they stick around so
  10270. 5:36:42dot sourcing and your unix guys will you
  10271. 5:36:45like cotton right onto this this is
  10272. 5:36:46dot source isn't that what i said only
  10273. 5:36:48not nearly as well as you said it
  10274. 5:36:50okay okay so watch get disk watch i'm
  10275. 5:36:53going to hit tab completion at this
  10276. 5:36:55point get disk
  10277. 5:36:56get disk image hey tab completion
  10278. 5:36:59it look looks like a commandlet lookie
  10279. 5:37:02look at computer name dc
  10280. 5:37:04we are rock and roll
  10281. 5:37:08i don't like having to do this dot
  10282. 5:37:09source stuff probably did you
  10283. 5:37:11you when you hit that command line wait
  10284. 5:37:12wait do it again do it again
  10285. 5:37:14up arrow up there dash
  10286. 5:37:18o tab
  10287. 5:37:21ooh oh out oh out variable so
  10288. 5:37:25let's um hey what do you want to call it
  10289. 5:37:27a hey everything's a
  10290. 5:37:28everything's a no dallas on a no dollar
  10291. 5:37:30sign a so now i don't you guys see that
  10292. 5:37:33it just sent it out to the variable it's
  10293. 5:37:35some of those common parameters that we
  10294. 5:37:36can use so now we've got
  10295. 5:37:38this stuffed into a variable it's
  10296. 5:37:39awesome so what that meant was when you
  10297. 5:37:41put that commandlet binding there
  10298. 5:37:43it said common parameters there's a
  10299. 5:37:45bunch of common parameters and these are
  10300. 5:37:47functions
  10301. 5:37:48you know just by putting that one thing
  10302. 5:37:49and you say hey powershell engine could
  10303. 5:37:51you do some stuff work for me
  10304. 5:37:52could you like give them output variable
  10305. 5:37:55and then could you do like error action
  10306. 5:37:57an error variable and warning action and
  10307. 5:37:59warranty variable
  10308. 5:38:00oh really cool stuff well you know let's
  10309. 5:38:03take this one step further and you and
  10310. 5:38:04you
  10311. 5:38:05can certainly throw uh stuff into this
  10312. 5:38:07but but guys this is going to be the
  10313. 5:38:09meat of of what we
  10314. 5:38:10we do on august uh first yeah and that's
  10315. 5:38:14you know this is nice but this isn't
  10316. 5:38:16something quite
  10317. 5:38:17yet what we refer to as an advanced
  10318. 5:38:19function although it's getting there
  10319. 5:38:21and what i want to be able to do is i
  10320. 5:38:22don't want to have to dot source
  10321. 5:38:24and run this as a script that doesn't
  10322. 5:38:25make sense to the junior admin that i
  10323. 5:38:27want to give this to
  10324. 5:38:28it's really worth the investment it's
  10325. 5:38:30going to take some time right it's not
  10326. 5:38:32going to be the simplest thing in the
  10327. 5:38:33world
  10328. 5:38:33it's going to take some time but you
  10329. 5:38:34really need to invest in learning about
  10330. 5:38:36modules okay because modules are the
  10331. 5:38:39future they're really worth the
  10332. 5:38:40investment
  10333. 5:38:41yes you know why don't we just like
  10334. 5:38:43settle in and teach them how to do it
  10335. 5:38:45and teach them how to do it so you guys
  10336. 5:38:47ready hardcore here we go yeah we're
  10337. 5:38:49gonna hardcore we're gonna make a module
  10338. 5:38:50wake up first of all i'm gonna show you
  10339. 5:38:53the cheesy way to make a module
  10340. 5:38:54nope cheesy file save as
  10341. 5:38:59notice my my script
  10342. 5:39:06that's that's it that's that's that's it
  10343. 5:39:08that's that's that's it that's that's
  10344. 5:39:10how you make them out you psm
  10345. 5:39:12one watch what watch out what what
  10346. 5:39:16you can now go to sleep yeah you can
  10347. 5:39:17wait watch watch
  10348. 5:39:19now now look because it's not in the
  10349. 5:39:21special place
  10350. 5:39:22that we're going to talk about i'm going
  10351. 5:39:24to have to manually import this module
  10352. 5:39:26and this module is called psm1
  10353. 5:39:31so this is kind of like the old v2 way
  10354. 5:39:33we'd always have to
  10355. 5:39:34do that but watch
  10356. 5:39:38do it again
  10357. 5:39:42verbose you want to do dash force that
  10358. 5:39:46does it again
  10359. 5:39:46for us force the other force the other
  10360. 5:39:49force and then dash for both for both
  10361. 5:39:51and just this just
  10362. 5:39:52shows you yeah see ah
  10363. 5:39:55removing one important oh i love that i
  10364. 5:39:57love that so yeah it's importing the get
  10365. 5:39:59disk info
  10366. 5:40:00and this is actually when you especially
  10367. 5:40:02especially on august 1st when we're
  10368. 5:40:04working with you know you have to you
  10369. 5:40:05have to reload modules you have to do
  10370. 5:40:07this is actually very useful to have
  10371. 5:40:09around so i've got a module that's
  10372. 5:40:11imported now i can just do get disk info
  10373. 5:40:13but you know
  10374. 5:40:15this is still not exactly the way that i
  10375. 5:40:18want it because i don't want to have to
  10376. 5:40:20say here's this thing i made you this
  10377. 5:40:22pretty
  10378. 5:40:23module it's a psm1 file and i
  10379. 5:40:26you're going to have to import it every
  10380. 5:40:27time you want to use anything in it that
  10381. 5:40:29just doesn't make sense
  10382. 5:40:31dude so hard was that it was easy i know
  10383. 5:40:33it was easy but you guys have like
  10384. 5:40:34magical locations
  10385. 5:40:36oh there is the magic yeah yeah so it's
  10386. 5:40:38going to let them in on the secrets well
  10387. 5:40:39i don't know i
  10388. 5:40:40see um env
  10389. 5:40:43is it ps module path it shows us all the
  10390. 5:40:45magic
  10391. 5:40:46so there are two paths here
  10392. 5:40:50these are the magic locations right now
  10393. 5:40:52as far as we're going to talk about the
  10394. 5:40:53magic locations
  10395. 5:40:55if you put your module in these
  10396. 5:40:57locations in a special way
  10397. 5:41:00they too will be dynamically loaded dude
  10398. 5:41:02what are you doing there that's odd
  10399. 5:41:04i never do it that way what do you want
  10400. 5:41:06to do show it my way
  10401. 5:41:07okay we'll do it your way
  10402. 5:41:10okay so what i do is i do i do oh
  10403. 5:41:14let's make this bigger i do dollar sign
  10404. 5:41:18okay and that looks the same but check
  10405. 5:41:21this out because we need to do dollar
  10406. 5:41:22signs dollars
  10407. 5:41:25split do it your way yeah
  10408. 5:41:30and then you break it out now you can
  10409. 5:41:31read it yeah let's do it that way let's
  10410. 5:41:33do it
  10411. 5:41:34back to him split up so i can't spell
  10412. 5:41:37split i can spell spit apparently
  10413. 5:41:40and what are we we're doing on what the
  10414. 5:41:41semicolon yeah
  10415. 5:41:43there's quotes a quote it's called it's
  10416. 5:41:45called it's quotes
  10417. 5:41:46ah oh now we can read the two paths this
  10418. 5:41:51makes a lot
  10419. 5:41:52much better so here's the first path
  10420. 5:41:54that i want you guys to take notice of
  10421. 5:41:56this is the path and i'm going to show
  10422. 5:41:57this to you graphically for a second
  10423. 5:41:59just so you can kind of see this i'm
  10424. 5:42:00going to go out
  10425. 5:42:01this is where powershell gets installed
  10426. 5:42:03windows system 32
  10427. 5:42:05and there's a reason i'm showing it
  10428. 5:42:06graphically sometimes this makes more
  10429. 5:42:07sense
  10430. 5:42:08and so i'm going to go out where it says
  10431. 5:42:09windows powershell
  10432. 5:42:13and you'll see this folder called
  10433. 5:42:15modules you see all these modules
  10434. 5:42:17these are modules here's the thing don't
  10435. 5:42:20put yours here
  10436. 5:42:20yeah this is not for you a lot of guys
  10437. 5:42:23will say oh just put it in there because
  10438. 5:42:25i
  10439. 5:42:25know where it is all that kind of stuff
  10440. 5:42:26no don't put your stuff there this is
  10441. 5:42:28the special place for microsoft
  10442. 5:42:30you have your own special place
  10443. 5:42:34and that is this one
  10444. 5:42:38your account documents windows
  10445. 5:42:40powershell modules but
  10446. 5:42:41this doesn't exist let me show you let
  10447. 5:42:44me show you graphically sometimes this
  10448. 5:42:46makes a little bit more sense so i'm
  10449. 5:42:47going to
  10450. 5:42:48go out here to users
  10451. 5:42:51and i'll go out to student company is my
  10452. 5:42:54account and it's my documents through
  10453. 5:42:56here
  10454. 5:42:57you see there's no module called a
  10455. 5:42:59windows powershell and there's nothing
  10456. 5:43:01called
  10457. 5:43:03modules so you will need to make it now
  10458. 5:43:05i i know
  10459. 5:43:06i'm making it graphically just because i
  10460. 5:43:07happen to be here but
  10461. 5:43:09you can do it with powershell of course
  10462. 5:43:11windows powershell
  10463. 5:43:13and then underneath of it you make
  10464. 5:43:17it been faster if i'd done it in
  10465. 5:43:18powershell oh my god what the hell's the
  10466. 5:43:20matter with me
  10467. 5:43:21so modules because now you're going to
  10468. 5:43:23have to type it right now i'm going to
  10469. 5:43:24have to type it right now here's the
  10470. 5:43:25thing
  10471. 5:43:26and this is very very important the name
  10472. 5:43:30of your module you know the thing i call
  10473. 5:43:33diskinfo.psm1
  10474. 5:43:35needs to be the name of the folder that
  10475. 5:43:37you're going to create here they need to
  10476. 5:43:39match
  10477. 5:43:40so i'm going to say new folder
  10478. 5:43:44i'm going to say disk info now
  10479. 5:43:47i've got this folder let's do this
  10480. 5:43:51i need to put my module in there so let
  10481. 5:43:54me go grab my module
  10482. 5:43:56which was this psm1 disk info
  10483. 5:44:00i'm gonna take it put it out to here
  10484. 5:44:03oh yeah i should have never done this
  10485. 5:44:05graphically but now i'm here
  10486. 5:44:07i'm gonna put it now here's the
  10487. 5:44:09important thing see look module name
  10488. 5:44:12the the module folder name and then
  10489. 5:44:16the name of the duder inside watch
  10490. 5:44:19let's close this so you know i'm not
  10491. 5:44:21cheating
  10492. 5:44:24let's see i wonder if i can get some
  10493. 5:44:26help on
  10494. 5:44:28uh did you start a fresh window yeah i
  10495. 5:44:30started a brand new one
  10496. 5:44:31a brand new one oh here just in case
  10497. 5:44:33anybody missed it i don't want you to
  10498. 5:44:34miss it i'm not cheating let me close
  10499. 5:44:36this thing up
  10500. 5:44:36i'm not cheating brand new window
  10501. 5:44:40get help um is there anything
  10502. 5:44:43uh in commandlet's on disk information
  10503. 5:44:48hmm wait wait wait wait wait
  10504. 5:44:52oh
  10505. 5:44:54[Music]
  10506. 5:44:58inside my module and well let's just try
  10507. 5:45:00it get uh
  10508. 5:45:01disk uh info or not image info
  10509. 5:45:05dash computer name dc
  10510. 5:45:08oh okay
  10511. 5:45:12you can tell that we're getting up to
  10512. 5:45:13the end of the day because the guys
  10513. 5:45:15in the back are are now going oh
  10514. 5:45:19so let me let me let me just show you
  10515. 5:45:21the uh the code again
  10516. 5:45:22and jeffrey please go ahead and add in
  10517. 5:45:24so all you're really doing is
  10518. 5:45:26doing functions we're properly naming
  10519. 5:45:28them so that they look like commandlets
  10520. 5:45:29notice
  10521. 5:45:30i just gave it a little bit of help
  10522. 5:45:31there are about underscore comment based
  10523. 5:45:33help
  10524. 5:45:34files for this to help you with this or
  10525. 5:45:36you can use
  10526. 5:45:37ctrl j to get the snippets and notice i
  10527. 5:45:40took a working line of code
  10528. 5:45:42the only thing i did was i added param
  10529. 5:45:45a couple of variables in there maybe an
  10530. 5:45:47attribute and believe me on august 1st
  10531. 5:45:49we'll talk a lot more about attributes
  10532. 5:45:51that speeds rock
  10533. 5:45:52oh they totally rock so with this simple
  10534. 5:45:54little bit of code
  10535. 5:45:55and saving it in the special place as a
  10536. 5:45:57psm1 file
  10537. 5:45:59i've made a module in fact in like all
  10538. 5:46:02modules
  10539. 5:46:02i'm not just going to put one function
  10540. 5:46:04in here i'm going to put as many
  10541. 5:46:06functions i'm going to make as many
  10542. 5:46:08tools
  10543. 5:46:09as i need and i'm going to put them into
  10544. 5:46:11this module so just
  10545. 5:46:13i'll just make it foo and i'll make
  10546. 5:46:15function
  10547. 5:46:16bar no i know they're not properly named
  10548. 5:46:19but
  10549. 5:46:20you get the idea now in that with that
  10550. 5:46:22module i'm just adding more and more
  10551. 5:46:24tools to this module now can do that
  10552. 5:46:26save it save it save it
  10553. 5:46:30uh so um important
  10554. 5:46:33import import module and it's uh
  10555. 5:46:36i forgot the name of disc info right and
  10556. 5:46:38then we want to s force
  10557. 5:46:40force and verbose or that's fine
  10558. 5:46:45hmm oh did you expect it to come up and
  10559. 5:46:48do the whole
  10560. 5:46:48you're using a yeah not improved you
  10561. 5:46:51know
  10562. 5:46:51what he's talking about is and matter of
  10563. 5:46:53fact i have to play with this i think
  10564. 5:46:56well let's do uh gimme dash
  10565. 5:47:00foo and uh
  10566. 5:47:04yeah yeah bar dash foo and let me save
  10567. 5:47:08it
  10568. 5:47:13oh you know it's the force that's the
  10569. 5:47:15problem oh it's the force that's doing
  10570. 5:47:16it
  10571. 5:47:16so move it remove it so module remove
  10572. 5:47:19module
  10573. 5:47:20by the way so force basically says i
  10574. 5:47:23you're telling us
  10575. 5:47:24we know what you're doing ignore all the
  10576. 5:47:27errors just do what i told you to do
  10577. 5:47:29dang it so watch what happens if you
  10578. 5:47:31don't type force
  10579. 5:47:32and this is actually uh disk info
  10580. 5:47:38oh dude i don't know why it's i'm not
  10581. 5:47:40saying it okay
  10582. 5:47:41i don't know why it's not saying but
  10583. 5:47:42here's what usually happens if you use
  10584. 5:47:44an unapproved verb it comes up and it
  10585. 5:47:46says in yellow
  10586. 5:47:47knock it off stop using unapproved verbs
  10587. 5:47:49don't be a dope
  10588. 5:47:50don't be a dope so use the proved verbs
  10589. 5:47:52and what are we doing on this uh
  10590. 5:47:54today i see something up it gives us uh
  10591. 5:47:57oh oh oh i they were trying to
  10592. 5:48:01you guys don't understand what's up on
  10593. 5:48:02the teleprompters in here right now
  10594. 5:48:05the guys the production team was trying
  10595. 5:48:07to be effing
  10596. 5:48:08funny they didn't use the appropriate
  10597. 5:48:11verb
  10598. 5:48:11and so first of all here's what they
  10599. 5:48:13typed in so you all can see it they said
  10600. 5:48:16dollar sign mentioned this
  10601. 5:48:19pipe to and i can't even read what
  10602. 5:48:22character they're using
  10603. 5:48:23this is were you guys up on
  10604. 5:48:26site um and then was it a squiggly
  10605. 5:48:30uh squiggly um it gives
  10606. 5:48:35us good feedback
  10607. 5:48:38in squeeze this is this is have you guys
  10608. 5:48:40been awake at all today this is the
  10609. 5:48:41crappiest powershell i've ever seen
  10610. 5:48:47this is remarkable we've been we've been
  10611. 5:48:50busting our bums all day long
  10612. 5:48:52and you type this in please
  10613. 5:48:55one of the mvps in the forums somebody
  10614. 5:48:57you don't even be an mvp
  10615. 5:48:58you take this and show them how it
  10616. 5:49:00really should be done in the cliff note
  10617. 5:49:02version
  10618. 5:49:02yeah but the point is i thought we had a
  10619. 5:49:05goodwill hunting moment there
  10620. 5:49:08not so much that's good yeah here you go
  10621. 5:49:12stay in av um what i think they're
  10622. 5:49:15trying to say is that there's a poll
  10623. 5:49:17up am i correct there's a poll up and
  10624. 5:49:19it's a real important poll
  10625. 5:49:21so make sure you you do the poll up on
  10626. 5:49:23the site because the feedback
  10627. 5:49:25for this session is is very important as
  10628. 5:49:27a matter of fact we're we're starting to
  10629. 5:49:29get kind of towards the end of
  10630. 5:49:31what we we've done for the the day but
  10631. 5:49:33your feedback on the session is very
  10632. 5:49:35important
  10633. 5:49:35um just so that you know we're going to
  10634. 5:49:39dive
  10635. 5:49:39deep deep deep and we're going to do it
  10636. 5:49:41in a day so it's going to be
  10637. 5:49:43definitely a day chewy chewy stuff
  10638. 5:49:46into tool making basically making uh
  10639. 5:49:49tools is going to show the different
  10640. 5:49:51kind of parameter attributes
  10641. 5:49:53more about the help how to see we've
  10642. 5:49:56only scratched the surface
  10643. 5:49:58our commandlet right now doesn't accept
  10644. 5:50:01pipeline
  10645. 5:50:01input it's not making changes so we're
  10646. 5:50:04not supporting what if and confirm
  10647. 5:50:07and you know we might want to make our
  10648. 5:50:09own views we there's so many things that
  10649. 5:50:12we're going to want to do
  10650. 5:50:14so we've actually still got a lot of
  10651. 5:50:16work to do we're just not going to do
  10652. 5:50:17much more of it
  10653. 5:50:19today so before we do a review
  10654. 5:50:23is there anything you want to add to the
  10655. 5:50:24stuff that we've done today is it
  10656. 5:50:25telling you
  10657. 5:50:26i think we i think we've been having fun
  10658. 5:50:28we've walked through a bunch of stuff
  10659. 5:50:29ton more
  10660. 5:50:30ton more but again the key things i want
  10661. 5:50:32you guys to to walk away with are
  10662. 5:50:35one uh this spirit of exploration
  10663. 5:50:38right go explore explore the help
  10664. 5:50:41explore the help
  10665. 5:50:42do you explore the help explore the
  10666. 5:50:44forums go on the internet try some
  10667. 5:50:46things
  10668. 5:50:47and when you get confused ask questions
  10669. 5:50:50do not be embarrassed not sit there say
  10670. 5:50:52oh that's a dumb question no
  10671. 5:50:53no ask that question you have a great
  10672. 5:50:56community that will give you help
  10673. 5:50:58and just a is hopefully you've seen the
  10674. 5:51:01sense of fun
  10675. 5:51:02there's just an incredible amount of
  10676. 5:51:03power in powershell
  10677. 5:51:05and it's fun to do this exploration by
  10678. 5:51:07the way and it's safe too
  10679. 5:51:08because you know you go and you have the
  10680. 5:51:10minus what if and the
  10681. 5:51:12and the uh confirm and verbose so you
  10682. 5:51:15know it's uh you can explore and you can
  10683. 5:51:17have fun and
  10684. 5:51:18and do it safely and do it safely and it
  10685. 5:51:21noticed that we've been having a lot of
  10686. 5:51:22fun today because it's been a joy for
  10687. 5:51:24the two of us to be able to spend the
  10688. 5:51:25day talking with everybody about
  10689. 5:51:27powershell
  10690. 5:51:27because it is just a lot of fun
  10691. 5:51:29especially when you get past some of the
  10692. 5:51:31learning curve stuff
  10693. 5:51:32so you we did get help and the the
  10694. 5:51:34amazing discoverability of get help
  10695. 5:51:37of finding commandlets regardless of
  10696. 5:51:39what product that you're working with
  10697. 5:51:40it'll find it for you
  10698. 5:51:42and then you can go into the help files
  10699. 5:51:44the examples the rich
  10700. 5:51:46the syntax that's in there the
  10701. 5:51:47definitions of the parameters
  10702. 5:51:49so get help is definitely number one
  10703. 5:51:52tool
  10704. 5:51:53something you definitely want to get
  10705. 5:51:54good at though is that middle piece we
  10706. 5:51:56did just after the meal break
  10707. 5:51:59of understanding the pipeline and how
  10708. 5:52:01the pipeline works because
  10709. 5:52:03if you can't figure out how to get two
  10710. 5:52:05commandments to work together
  10711. 5:52:07you're just not going to have a lot of
  10712. 5:52:09fun that's so very important so
  10713. 5:52:11remember don jones has a great book on
  10714. 5:52:13learn windows powershell in the month of
  10715. 5:52:14lunches it's chapter nine i know it
  10716. 5:52:16sounds like i'm trying to sell a book i
  10717. 5:52:17just want you to have
  10718. 5:52:18more resource information on working
  10719. 5:52:21through that and go out to the forums on
  10720. 5:52:23powershell.org and ask about that
  10721. 5:52:25also the thing that really changes and i
  10722. 5:52:27i have to say
  10723. 5:52:28you know understanding the pipeline that
  10724. 5:52:31made a huge difference for me
  10725. 5:52:33when v2 shipped and remoting that's what
  10726. 5:52:36changed
  10727. 5:52:37administration for me and it's changed
  10728. 5:52:39it forever
  10729. 5:52:40the remoting being able to hit multiple
  10730. 5:52:43machines being able to do
  10731. 5:52:44multiple things at once being able to
  10732. 5:52:46put those into scripts
  10733. 5:52:49has really really made a huge a huge
  10734. 5:52:51difference
  10735. 5:52:52so that's the stuff everybody you know
  10736. 5:52:53powershell is running all of our
  10737. 5:52:54websites
  10738. 5:52:55you know all of our big internet sites
  10739. 5:52:57and then that's why
  10740. 5:52:58because i got a gazillion of these
  10741. 5:53:00things how am i going to do things how
  10742. 5:53:01am i going to do things and i think you
  10743. 5:53:02guys have seen today
  10744. 5:53:03a great example that powershell you can
  10745. 5:53:06learn it you've learned a lot of it
  10746. 5:53:07today
  10747. 5:53:08and you know what i didn't tell them
  10748. 5:53:09about what did you tell our sacred vow
  10749. 5:53:12the sacred vow so uh so here's the
  10750. 5:53:15sacred vowel the whole story behind the
  10751. 5:53:16sacred vowel the sacred vowel is
  10752. 5:53:17basically the story that says
  10753. 5:53:19hey you're i.t pros your hair's on fire
  10754. 5:53:21the last thing the world
  10755. 5:53:22we know the last thing in the world you
  10756. 5:53:23want to do is take your time to go
  10757. 5:53:25learn a new tool and yet here i am and
  10758. 5:53:28i'm sitting here asking you
  10759. 5:53:29to learn this new tool and why and the
  10760. 5:53:32answer is because it's going to help you
  10761. 5:53:35and there's a set of things that you
  10762. 5:53:36have to learn you have to learn the
  10763. 5:53:38verbs you have to learn the syntax
  10764. 5:53:39i have to learn the pipeline and you
  10765. 5:53:41have to learn how to do things how to
  10766. 5:53:43explore et cetera
  10767. 5:53:44but my sacred vow to you is that if you
  10768. 5:53:47learn those things
  10769. 5:53:48i'm going to do everything in my power
  10770. 5:53:50to reuse those words
  10771. 5:53:52those concepts those techniques over
  10772. 5:53:55and over and over and over again so that
  10773. 5:53:58your investment in learning
  10774. 5:54:00is the best payback the best investment
  10775. 5:54:03you ever made
  10776. 5:54:04now let me get concrete about what that
  10777. 5:54:06means when we decided hey we need to
  10778. 5:54:08support
  10779. 5:54:08workflow the original design for
  10780. 5:54:11workflow was this very unusual thing
  10781. 5:54:13oh you know you got some weird syntax
  10782. 5:54:15for workflow
  10783. 5:54:16steps and workflow sequences
  10784. 5:54:19and all that i said guys whack you
  10785. 5:54:22forgot our sacred vow
  10786. 5:54:24our sacred vow is they've already
  10787. 5:54:25learned powershell use that over and
  10788. 5:54:28over and over again
  10789. 5:54:29so now when you when we teach you about
  10790. 5:54:31workflow what you're going to see is
  10791. 5:54:32you just type instead of function foo
  10792. 5:54:35you type workflow
  10793. 5:54:36foo and then you write powershell
  10794. 5:54:39and the difference is that now it looks
  10795. 5:54:42just like powershell
  10796. 5:54:43except it's got very different semantics
  10797. 5:54:45it isn't run
  10798. 5:54:46by the traditional powershell engine we
  10799. 5:54:49take that powershell syntax
  10800. 5:54:51and we transcode it into a windows
  10801. 5:54:54workflow
  10802. 5:54:54object graph and we give it to the
  10803. 5:54:56windows workflow
  10804. 5:54:57engine to execute its execution engine
  10805. 5:55:00but you
  10806. 5:55:01your experience looks just like
  10807. 5:55:04powershell even though underneath the
  10808. 5:55:05covers
  10809. 5:55:06it's very very different why because of
  10810. 5:55:08our sacred vow
  10811. 5:55:10you learn this stuff and we're going to
  10812. 5:55:11do it over and over and over again
  10813. 5:55:14use those techniques over and over and
  10814. 5:55:15over again you learn how to manage
  10815. 5:55:17exchange you're going to be able to let
  10816. 5:55:18manage link having learned
  10817. 5:55:20those two things you're going to be able
  10818. 5:55:22to learn how to manage azure and
  10819. 5:55:25sql and all that because of the sacred
  10820. 5:55:27vow and we take that
  10821. 5:55:28super seriously and i have to say it's
  10822. 5:55:30it's a great honor to sit here next to
  10823. 5:55:32jeffrey snover and it's been a great
  10824. 5:55:33honor to be able to talk with with
  10825. 5:55:35members of the powershell team because
  10826. 5:55:36guys
  10827. 5:55:37you got to realize that sacred vow
  10828. 5:55:38they've stuck to it they've
  10829. 5:55:40stuck to it over the over several you
  10830. 5:55:42know the last five six years that i've
  10831. 5:55:44been doing this
  10832. 5:55:45there's one guarantee that i've always
  10833. 5:55:47had and that's if i'm going to take
  10834. 5:55:49the investment to learn this they're not
  10835. 5:55:50going to screw me on the back end by
  10836. 5:55:52suddenly
  10837. 5:55:52ripping everything out replacing it and
  10838. 5:55:54totally changing everything nope
  10839. 5:55:56i'm going to get commandments i'm going
  10840. 5:55:57to get parameters i've got a scripting
  10841. 5:55:59environment that makes sense that's
  10842. 5:56:00stable
  10843. 5:56:01that's being moved forward it's always
  10844. 5:56:03going to be improved but
  10845. 5:56:04i know exactly what to expect and i know
  10846. 5:56:06what to expect
  10847. 5:56:07when i go to active directory to manage
  10848. 5:56:09exchange to manage whatever
  10849. 5:56:11it's the same and that experience makes
  10850. 5:56:14this initial investment
  10851. 5:56:16a little painful at first but it will
  10852. 5:56:18pay off and it'll pay off
  10853. 5:56:20for years and years and years and you've
  10854. 5:56:22heard it from the architect they are
  10855. 5:56:24so totally committed to that so
  10856. 5:56:28a little bit of information of how you
  10857. 5:56:30get some more information so let me just
  10858. 5:56:32uh
  10859. 5:56:33yeah we're going to leave your guys's
  10860. 5:56:35mistake up on there a very embarrassing
  10861. 5:56:37thing that you did
  10862. 5:56:38and i want to just put up um a couple of
  10863. 5:56:41things
  10864. 5:56:42for you all first of all you know that
  10865. 5:56:44at the
  10866. 5:56:45nba where you're at or yeah mvs mba
  10867. 5:56:47stuff
  10868. 5:56:48we're going to have another presentation
  10869. 5:56:49this is going to be on scripting and
  10870. 5:56:51tool making
  10871. 5:56:53now it's on august 1st but if you're
  10872. 5:56:54watching this is a video look for the
  10873. 5:56:56next title scripting and tool making so
  10874. 5:56:58we'll
  10875. 5:56:59we're going to do that it's going to be
  10876. 5:57:00awesome it's gonna be totally awesome
  10877. 5:57:02a couple of other things if you have a
  10878. 5:57:04question please don't
  10879. 5:57:06don't the only mistake you're gonna make
  10880. 5:57:08if you have a question
  10881. 5:57:09is not ask it so there are a couple of
  10882. 5:57:12places you can go
  10883. 5:57:13to get an answer of course
  10884. 5:57:15powershell.org i think i've said that
  10885. 5:57:16like 15 times a day
  10886. 5:57:18but trust me the community nobody gets
  10887. 5:57:20paid for this we're doing it because we
  10888. 5:57:22actually care and we want to help
  10889. 5:57:23go ask a question you'll get an answer
  10890. 5:57:25we've all been through this
  10891. 5:57:27i also want to give you something else
  10892. 5:57:28something that's kind of uncommon i bet
  10893. 5:57:30you you guys do this
  10894. 5:57:32but every time i talk to a group of it
  10895. 5:57:34pros something happens that's kind of
  10896. 5:57:35bizarre i'll ask this question
  10897. 5:57:37to a bunch of it pros how many of you
  10898. 5:57:39use twitter and everybody will go like
  10899. 5:57:41this
  10900. 5:57:43that's not the correct answer knock it
  10901. 5:57:45off so
  10902. 5:57:47i i'm not saying go go i'm not saying
  10903. 5:57:49set up twitter and start tweeting us
  10904. 5:57:51what you had for lunch matter of fact
  10905. 5:57:52don't do that please um but you need
  10906. 5:57:56to get a twitter account even if you
  10907. 5:57:57just want to look because where you're
  10908. 5:57:59going to find
  10909. 5:58:00the things that are going on is that a
  10910. 5:58:02twitter hashtag called
  10911. 5:58:05powershell that's where you're going to
  10912. 5:58:07hear him you're going to hear the mvps
  10913. 5:58:09and i'm not saying that they're just
  10914. 5:58:10talking about here's a cool command no
  10915. 5:58:12you're going to see
  10916. 5:58:13pointers to here's how i solve this
  10917. 5:58:16exchange problem here's how i solve this
  10918. 5:58:18scvmm issue here's how i built this
  10919. 5:58:22this is where the latest and greatest
  10920. 5:58:23information is happening so get on
  10921. 5:58:25twitter and
  10922. 5:58:26while you're out there on twitter
  10923. 5:58:27following the powershell stuff
  10924. 5:58:30there's always at chase snover that's
  10925. 5:58:33him
  10926. 5:58:34see you can show them how to do they
  10927. 5:58:35know how to use twitter
  10928. 5:58:38ie you want me to bring up the tweeter
  10929. 5:58:42the tweeter
  10930. 5:58:43yeah well now i'm just the tweeter
  10931. 5:58:46and twitter i don't know if i can use it
  10932. 5:58:48this way okay you're gonna have to help
  10933. 5:58:50me because
  10934. 5:58:50this is actually hi can it be
  10935. 5:58:54well i have to sign in don't you know
  10936. 5:58:56how to do that well okay you want me to
  10937. 5:58:58sign in
  10938. 5:58:58really yeah okay i don't
  10939. 5:59:01laugh at my sign-in
  10940. 5:59:11it is what it is guys it just is what it
  10941. 5:59:13is
  10942. 5:59:16oops i think i did the password wrong
  10943. 5:59:17let me let me
  10944. 5:59:19wait a minute i'm signing into my
  10945. 5:59:20twitter you're going to see all the
  10946. 5:59:21stuff that i follow
  10947. 5:59:22oh just wait a minute oh for crying out
  10948. 5:59:24loud why wouldn't it let me in
  10949. 5:59:26oh wait a minute
  10950. 5:59:30wait a minute wait a minute i know i
  10951. 5:59:31know i know oh my lord
  10952. 5:59:33i know this is i i don't this isn't how
  10953. 5:59:36i get to it
  10954. 5:59:38oh and now it's making me type in all
  10955. 5:59:39the device stuff are you kidding me guys
  10956. 5:59:42here switch to mine switch to his i
  10957. 5:59:44think his probably works
  10958. 5:59:50oh there you go but did you finally get
  10959. 5:59:52it no we're looking at yours
  10960. 5:59:54see that's there's mine there's there's
  10961. 5:59:56there's there's there's
  10962. 5:59:57there's let's see let me see if i can
  10963. 5:59:59finally get in ks
  10964. 6:00:01ah what is that a w i hate these things
  10965. 6:00:04e
  10966. 6:00:04you're missing a what am i missing why
  10967. 6:00:06don't i last
  10968. 6:00:07had had a turkey sandwich for lunch um
  10969. 6:00:10never mind
  10970. 6:00:10that's that's i can't get signed into
  10971. 6:00:12this awesome
  10972. 6:00:13so twitter's awesome so you're going to
  10973. 6:00:15want the first thing
  10974. 6:00:17even if you can't get a hell of a
  10975. 6:00:18twitter like obviously can't even use
  10976. 6:00:20twitter
  10977. 6:00:21but can use powershot so clearly did you
  10978. 6:00:23guys see
  10979. 6:00:24the problem with the internet today and
  10980. 6:00:25he had to teach me um was it the host
  10981. 6:00:28file
  10982. 6:00:29it's e-hosts exactly so
  10983. 6:00:33if you can't use twitter doesn't mean
  10984. 6:00:34you can't use powershell that's right
  10985. 6:00:36that's right so
  10986. 6:00:37use powershell so ladies and gentlemen
  10987. 6:00:39um
  10988. 6:00:40on on behalf of the folks at mba and of
  10989. 6:00:42myself i'd like to thank you for
  10990. 6:00:44attending this
  10991. 6:00:44this full day session and i would really
  10992. 6:00:47sir
  10993. 6:00:48like to thank you oh for spending the
  10994. 6:00:50entire day it's been such a
  10995. 6:00:52great fun it's been a blast had a great
  10996. 6:00:54time with you and i i had a great time
  10997. 6:00:55with you
  10998. 6:00:56don't you guys remember fill out those
  10999. 6:00:58polls we really do you know microsoft
  11000. 6:01:00really pays attention to that stuff you
  11001. 6:01:02know i know everywhere you go they're
  11002. 6:01:03like oh yeah i fill out the poll
  11003. 6:01:04no no we pay attention to that stuff if
  11004. 6:01:07i get a vibe mark they'll fire me so
  11005. 6:01:11just saying just
  11006. 6:01:15it's been a true honor to be able to
  11007. 6:01:17yeah exactly
  11008. 6:01:18it's been a true honor to have the
  11009. 6:01:20actual architect distinguished engineer
  11010. 6:01:22jeffrey snover to be able to sit down
  11011. 6:01:23and talk with us about powershell god
  11012. 6:01:25knows i've learned a lot and now i have
  11013. 6:01:26to go
  11014. 6:01:27and study because now i've i've learned
  11015. 6:01:30more and i have to study
  11016. 6:01:31thank you sir this has been wonderful
  11017. 6:01:33thanks a lot thanks a lot guys and
  11018. 6:01:35thanks for joining us we're going to see
  11019. 6:01:36at the next one
  11020. 6:01:36scripting and tool making
  11021. 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.