[MUSIC] >> Hey, welcome to
Microsoft Ignite 2021. It's great to see you. >> In person, this is wonderful. >> In person. We're
not in a Teams call or not on the phone
kind of thing. >> No VR. >> No VR. That's right. This is our annual
PowerShell Unplug. >> Yeah, boy, I'm so
excited to talk about all the great things have been
going on with PowerShell, and if you're new to
PowerShell Unplug, this is where Jason and
I get down and we say, "Hey, what are the
things that excited us that are going on." We go and demonstrate
them and lot of demos. We'll have a couple slides
tell you where we are, but lots of demos and we make mistakes that's part
of the point of this. You see, people have
been doing this for 15 plus years and
they make mistakes. Then when you make mistakes, you're not beating yourself up. Don't beat yourself
up. Making mistakes is natural and you'll see that
we'll make lots of mistakes. >> I make lots.
They keep telling me I wear my mask wrong, so apparently I making mistakes. It's all good. Let's take a look at the agenda
that we have here. First of all, PowerShell continues to make
you more productive. I think we're going
to show that here, both past and going
on into the future, making you more productive. For our agenda, a big long list here of agenda items,
we'll get through it. Are you taking full
advantage of PowerShell? That's one of the things
we want to check out. Of course, we're
going to talk about what's our upcoming release, some of the information
for that of 7.2. But then we're going to
look at some other things. Wow, what are we
going to do with all of these native command,
these console commands? There's something we
can do with that, after all of these years
they're still out there. Not everything is a cmdlet. Well, we're going
to fix that too. We're going to take a look
at protecting things with like SecretManagement,
which is being released. Also, adding color to your life. If you've been using
PowerShell for a long time, you're pretty much
the white text on the blue screen or the
white text on black screen. Now we're going to
change some of that. We're going to make
some new progress. We've got some new progress
bars, and quite honestly, there's some new Tab
Completion stuff to help everybody out and you're doing
some stuff in there too. >> Yes. I strongly
believe that most people know a small fraction of the stuff that we delivered
in PowerShell Version 1. I'm going to show how some
of the great stuff that we're just adding now combined with some of the stuff that
you might not know about in Version 1 combine together to produce some
really interesting stuff. Now the real point of
that is we're going to do some 400 level stuff, so if you get confused,
don't worry about it. It's recorded, go back. But it's all about exploring, about exploring. In fact,
getting ready for this, I went down some path
and it didn't work out, and I had to go
down another path. I'm going to show
you both the path that worked and the
path that didn't, because they're both
very illustrative of some of the mechanics
behind PowerShell. Again, PowerShell is powerful. Honestly, we just have these
sessions, it's just fun. We just love exploring
the tool and try that. You're going to see
some fun stuff. >> Now, as Jeffrey mentioned, I'll hit it up on the slide. This unplugged,
we're doing this, just having fun and we're doing stuff that we will make
mistakes on it, that's okay. The interesting thing as
Jeffrey just mentioned, even if you're brand
new to PowerShell, make sure you hang with the advanced session
because you'll see, we make mistakes,
we figure it out, we work our way around
different things. It's worth the
experience right there. Now, first of all, a couple of things on
the slide for 7.2. We're getting ready
to release 7.2. This is a long-term
service release, which means, three years. Take a look what to
expect with 7.2. Yes. We've gotten tons of bug fixes and features
from the community. Thank you for coming out to GitHub and spending
some time with us. We've got also lots of
features outside of PowerShell that we want to talk about
today. Oh, wait a minute. Can I say, if you're not using PowerShell 7, if
you say, oh I'm waiting for long-term
service release, I'm still on
PowerShell Version 5, you got to get on
PowerShell Version 7. There's some great big features. We're going to talk about
those big features. But it's these little features, these little things
that we have added, the community has added. It just has a completely
different feel to it. It just feels so
much more polished. You're going to
really enjoy that. Again, if you're on
the fence and "I'm going to wait
till the long-term service releases coming out." >> It's boom. We're ready, and just as a little note, this is probably the most
commonly asked questions. When is PowerShell 7
going to ship in Windows? Then what I'd like to
tell you this is that you probably will not see it when you first
get Windows 11, but we are getting closer. We are working with
the Windows team and the Windows team and
the PowerShell team. We both want the same goal
of PowerShell in Windows, but we have some
technical issues we're working with and we're working through
to get there. But look forward to
hearing more from us next year as we're getting
closer to the target. Now. >> But that said
it's so easy to get. You can't swing a cat without hidden way to get
PowerShell on the box. >> It's so easy to get. You're going to hear his talk about all the different ways, you can get it from GitHub, you can get it from the Store. As a matter of fact,
let me show you the slide. How do I get? General availability
for PowerShell will be coming in November, is
what our current plan is. About the time
that you see this, it's going to be available. Whether you want it
for Windows, Linux, Mac, different
versions of Linux. It's all right there. >> Yeah. It's on a
snap in a Ubuntu. >> In a Ubuntu. >> Just built-in. It's crazy. >> PowerShell is there for you. The LTS support
means that you've got three years of support
from this release. Now if you're working on 7.1, that was one-year support, that's coming to an end shortly. This will have three
years long-term support. Now, as soon as I say that, I also want to point out
that after our release, expect to start seeing
previews from us on 7.3. That will be awfully exciting. Also a big note, PowerShell 7 is
available in the Store. You can download it. There are so many different ways as
Jeffrey just mentioned, that you could get it. One thing that I want to highlight to you that's
going to be brand new. A lot of you have
asked for this. Can you update PowerShell
through Microsoft Update? The answer is yes. We've added that into our later previews and
will be in release. In fact, really quick, I just want to show you I've
got a link on the screen, (not that I can get my mouse
pointer to work for me.) I just want to show
you real quick. Yes, there is a doc all about
using the Microsoft update. I want to show you. Look
at this beautiful screen. You've got two options here. I don't want you to
be confused by this. The first option basically adds a registry key saying yes, you want to be updated
for PowerShell. The second checkbox indicates whether you want to receive that update through
Microsoft Update. Now most of you will select both checkboxes, that's
the recommended. However, those of
you that have WSUS, you're using SCCM and
you've gotten WSUS, maybe you don't want it
through Microsoft Update, that's why we made them
both available to you. But check out this
documentation for using the brand new
Microsoft Update. Last but not least, before we just fully dive in, we've got lots of improvements
both inside PowerShell, and here's the interesting
thing: outside PowerShell. There's a phrase that
you like to use. >> What we're really
doing here and there's lot of engineering work
required to do it. But effectively what
we're trying to do is to decompose PowerShell into
a set of swim lanes, so that each team can go in
their swim lane and go at their own pace and
not have to interact with the other teams to
get their work done. Really what we're trying
to do is to increase the overall bandwidth for innovation that we
deliver to you. If it's all within one
thing, there's one schedule. This allows teams to
go much, much faster. We've broken out a number
of things in the past, we're going to
continue to do that, and we're going to
continue to do that. You'll see some
things that are in PowerShell today. In the future, we're looking to figure out
a way that we can take them out so that they can innovate faster. Can we talk about those? >> Sure. >> Go ahead. >> Anything you what. >> Your defining policy. >> Anything technical fellow
wants to talk about. Yeah. >> Exactly. >> Look at the basics.
We're going to have a lot more information about this, but the basics is this, we are trying very hard
to move the things that make sense on the outside of PowerShell, just
as Jeffrey mentioned, so that those individual
things that you care about they can be developed
and worked on and shipped to you even faster. But also wouldn't it be nice for the size of PowerShell to be reduced with stuff
that you don't need? It's easier to secure. It works better in
different scenarios, so we're working
on that as well. The idea being we're building
a lot of stuff outside of PowerShell and that's
where you want to enjoy your experience
with PowerShell. You can add the things in that you need.
You're ready to go? >> Let's go. >> I want to do this.
Now we're going to get started on our first demos. But before we dive in
with this first demo, Jeffrey, we actually did
this demo last year. We started this demo. What I did is, we were
talking about this. It was an experiment, a proof of concept. Now, thanks to you and
everybody for all your help, we're getting ready to release something called
PowerShell Crescendo. Let me just show you
how cool this is. First of all, when
PowerShell V1 came out, there was like a 100. >> 28. >> What's that? >> One hundred and
twenty eight Cmdlets. >> There's the guy. I
heard it was a 129, no. I'm sure you're right 128. Now, here's the thing though, when PowerShell v1 came out, it also shipped with, at the same time
that Exchange 2007. Now Exchange added
another 500 Cmdlets for managing Exchange, but let's face it folks, 128 Cmdlets that wasn't a
whole lot to manage with. Today we have thousands, but not everything is a
Cmdlet. Let's face it. It's easier for a lot of
development to go right to a console command and so you see a lot of
console commands, both Legacy and Brand new. Well, we've got a way for you to be able to take care of that. Let me dive in here
and show you quick. Come on mouse
pointer you can do it. >> Just to be clear,
we are fine with that. If you recall, PowerShell is, the very first time I started
talking about PowerShell, I said, the world always
has been, the world is, and the world always will be a messy place and the
goal of PowerShell is to allow you to manage
that messy place and to be able to turn it into
a place of predictability. We start off with PowerShell
Cmdlets written in .net, then we added the ability to
write them in PowerShell, but really we broke the back of critical mass of PowerShell
Cmdlets when we said, Hey, you can write
them in WMI and so it was WMI and then
we put a PowerShell, high-level task current that
abstraction on top of that and then Azure
gazillions of commands, those are all using rest APIs. Here we're going to
show you is, Hey, we can just produce
some new Cmdlets, but what powers
them is a native, what would each call, Legacy? Alternate parser CLI. It's like, that's fine, whatever. >> I love your description
of the world's a messy place because let's see if we can
take some of the mess out of it. Take a look at my screen
over here and first of all, I'm running on one of
our latest previews, by the time you see this, it will be released. You all know the
ipconfig command. Let me just go ahead
and run that for you. We live and breathe
off ipconfig, but you notice if you're
looking at my screen, I'll do ipconfig and do
a slash all real quick. What I have a hard time doing, is grabbing that IPv4 address so that I could use
it in my Automation. I just want the IP address, but that's going to be hard. I have to figure
out how to scrape this string and all that. Wouldn't it be cool
if instead of that, I could just have a Cmdlet. In my case, I'll do -all. I've got get ipconfig. Isn't it cool?
That's pretty cool, but here's the best part. Get ipconfig, not only is it a Cmdlet, but all of that output
that you're seeing, that's in an object, and for a PowerShell user, when the data's in an object, we have now complete control
over it in the pipeline. As you can see here,
if I wanted to use that for automation, I could select and just grab that IPv4 address.
I'm rockin' and rollin'. Now that's what we had
talked about before, but we've added more stuff. We've added the ability
for you to be able to handle elevation
with your commands. We've added a lot of features to handle the
scenarios that you're in. Let me show you really
quick, ooh, this cool. Let me show you quick how
to elevate a command. Yeah, I'm sure you've
all worked with the Windows Firewall and
if you're an IT person, sometimes you just
want to turn it off, do something quick to
test something and then you want to turn it back on because you
want the security. Well, I want to turn it off and then turn it
back on real quick. Look at my screen,
how many of you ever use the netsh command? That's an easy
command to work with. In this case, if I wanted to
turn off the Firewall, wow, I'll never remember any of this, but what I've done is I've
let PowerShell Crescendo, take care of this for me, so now I can set Win-Firewall, in my case, it's already on, I'll set it to off and
here what I want you to notice is this is
going to come up. Well, first of all,
it's not going to do anything because it
wasn't recognized. Let me quickly, I know why. I can show you ipconfig
and let's do this. Let me go into Ignite. >> One of the part where
we're going to make mistakes. >> This would be one of them. I'm letting the cat out
of the bag a little bit, but it's good that
you can see this. Now, I'm going to
import a module. This module was built for me by Crescendo and now what I'll
do is set that firewall off. What I want you to
notice, it's prompting me for credentials. The reason is to change
the state of the firewall, you need to be an administrator. This is pretty simple. I'm just going to dive
right in and type in administrator and put in my password and you're going
to see that it's going to, it popped up and turned
the Firewall off. We have Command elevation. It's all good. I should show you though how I actually did it, really quickly. I'll be very brief. Let's do code. Yeah. >> Ramping the native
Cmdlet with Crescendo basically transforms a
command with a question mark syntax, right, everyone's got their own syntax,
and then -all. What does -all
mean? I don't know. What it does is, it says, hey, we know what we expect
this PowerShell Cmdlet, verb - noun - parameter name, that
makes sense to us. Then when I get the output, I get objects because I don't want to do this
prayer-based parsing. Go down twenty
eight, twenty seven, twenty three lines,
go over so many. Oh there's a tab...
with your prayer- based parsing that very fragile because as soon
as they update it, it breaks all your scripts, so instead you put
it into objects. That's what you're getting here. >> Now, really quick, how Crescendo works is, you as the author that wants to take whatever
console command, I refer to it as native command
platform specific Linux, Mac, or Windows, we
can do this with, that's the important part. You can take that and if you
take a look at the screen, there is PowerShell Crescendo. You need to download this
from the gallery in order to author your own
Crescendo-ed commands. Once you do that, you go in and you
create a JSON file. This is the configuration file. You just need to add a
few settings in there. Tell me what verb, what noun you'd like to have it. What original native
command it points to, and tell me what you'd like
to call the parameters. I'll show you a quick
example once you do that in this very simple JSON, now Crescendo does
the magic for you. You export this using the export Cmdlet and what
you'll get at the end, is a module, not
just any kind of module, a PowerShell module. A pure, clean PowerShell module. Here's the best part:
that module can be deployed to any system
on your network, it can be shared
with other people in the gallery, and
the best part is... >> It doesn't need
Crescendo, correct? >> It does not need Crescendo. >> Crescendo is an
authoring tool. >> Yeah, Crescendo's
the authoring site, but once you deploy this module, it's fine all by itself. Take a look at my
screen right here. I lost my mouse, there is my mouse. I'm going
to go into Windows. Notice this is
Windows PowerShell. Here's the best part. I'm going to go into... >> Wait, like PowerShell
version 5? >> Windows PowerShell 5.1, that's Windows PowerShell,
it's beautiful, it's great. I'm going to go
into PowerShell 5.1 and I'm going to
load this module. Import the module and not the alias module wall
and make this ipconfig. Now watch, get IP config select "IPv4", there it goes. Crescendo will let
you wrap everything. It'll work down-level to Windows PowerShell 5.1,
that's pretty cool. Also Crescendo will
let you work on Linux, so you can wrap Linux commands, you can wrap whatever
makes you happy. Now the best part
about this, well no, I've already told
you the best part, but let me show you another
part too really quick. >> While you're
figuring that out. Let me just highlight, this one of the values of breaking things into
their own swim lanes. Crescendo, awesome features,
awesome functionality, and we didn't want to say the only way you want to get that is if it's the latest
version of PowerShell. When we break things out, each technology can decide
what makes sense for it. Does it make sense
to go down-level? Maximum flexibility, maximum
bandwidth for innovation. >> Maximum flexibility. Folks, what I've got on my
screen right now is that little short
configuration file that you need to create in
order to use Crescendo. Now we have cmdlets
that will help you get started on creating this, and you'll be able to fill in. We've got plenty of
documentation that we're coming out with as
it gets released. In this case, what I'd like to do is show you really briefly, I've specified the verb, the noun, the native
command I've gone through, and I've specified
some parameters. That's all I did for
the ipconfig one. But for elevation, and the reason I want you to see the elevation is you can, of course do that
with Crescendo. The reason I'd like you to see the elevation is I'm
going to change it. Same idea, you see the verb, the noun, the string
to the native command. You'll see parameters, but
in this section down here, we now support
elevation on Windows. We support Windows elevation
through start process. We also make it so
that you can change to your own elevation provider if you want to use
something different. On Linux, you just use the Sudoers file as any
Linux admin would do, that's pretty straightforward, but I want you to notice here, I've got "-credential," and right now I'm
saying "get-credential." That's why it said, hey, put in your
username, and password. I could easily change this
to "get-secret Jason." "Get-secret" is our new
SecretManagement, and our new SecretManagement is a vault that you can
have on your system. You have cmdlets that
let you manage secrets, and you can put secrets into it, pull secrets out of it, there's no reason
to run a script again with the username
and password in it. Can we say that
that's a bad idea? >> That's a terrible idea. Yeah. We've been
passionate about this, and we've done a bunch of
things in PowerShell from the very beginning to help
avoid using passwords. But it's still, it turns
out that API keys, and legacy cmdlets, etc, that passwords are
still ended up in the scripts no matter what so what we did was we invented this new technology,
SecretsManagement. You can think of as a
Key Chain or Key Vault. It basically says, I'm going
to put my keys in here, give him a name, and
then when I want them, I ask for them by
name, and I get them. Then in your script, you
say, grab the password, grab the secret for
my Azure storage API, and pulls it out,
and then you use that variable in your script. The great thing about
this is it then that vault can be personal
to be on your machine or you can have a team
vault hosted up in Azure, and this is a pluggable system so partners can go
to the same thing, and other Cloud vendors. You have any number of
implementations that you want, and so when you do it
in Azure Key Vault, then all of a sudden we
write this one script, we hand it around and then
everybody is able to run it as long as they have permissions to the
Azure Key Vault. >> I think the
important part is, is that the idea is that your problem needs
to be able to scale so when you start it with
its small PowerShell is there to help
you as you grow. Of course, when
you need to scale, you always look to the Cloud, and the Cloud is going
to help you there. It's the perfect solution. I wish we had this
15 years ago, right? If you take a
quick look at my screen, I want you to be able to
find SecretManagement. SecretManagement has
already GA-ed, it's in 1.1. You can get it from
the gallery as I have there and something else I wanted to
point out to you. Notice how I did my fine
module SecretManagement star. That'll give you a list
of the different types of stores or vaults that you can use with SecretManagement, you'll notice some
familiar ones, ones that you may
already be working with. A lot of the
community wrote these. >> What? >> The community's amazing. They did all of this. >> Seriously? >> Yeah, the community
jumped in and did this. Make sure you stay secure, make sure you run your scripts secured for your automation. Now you have
SecretManagement in a vault to do that with. >> Again, the scripts, it's not just internally. All of a sudden I
can take a script, and I can require secrets, and I can publish
it to the world, not with my secrets, but a reference to the secret up in the
Cloud or in some vault, and then when I say, you want to run it, different company, you just have to get your key into the vault with
the same name, and then the script runs
without modifications. In fact, I could digitally
sign the script, and give it to you, and
you can just trust me, put your key up there,
everything works. >> I absolutely trust you. Also, and Jeffrey,
here's the new thing. Did you even notice my screen? Did you something kind of
weird? Because if I was running this demo
in PowerShell 5, this would be white
text on blue. What do you notice here? You
notice is it all white text. >> Yeah, no! Colors. >> We have colors. Now look, we're starting
to add in some colors, and let you have some
control over colors. The idea here is, we're starting off small,
but we're working on this. You can now control the
colors for a lot of things, and let me start this out by
saying "$psstyle." That gives you a
list of things that you can colorize and the
different colors you can use, and I encourage you to
take a look at this list. You might be
surprised at some of the things that you
might see there. >> It's important to do
that because when you just run "psstyle," like I did, you'd see the last set of
things and it looks like it's a set of
enumerations for color, you know, asking sequences
to set a color. But if you scroll up you see, it's that, and a bunch more. You can add these
settings to your profile, but until, don't add
them to your profile until you've decided what
colors that you want. Let me give you a quick example. I'm going to change
the table headers. If I can keep this. Notice right now they're
green. I don't like green. I want to actually,
I do like green, I just want to make
them something else. I will do "$psstyle.format." Fortunately, I've got tab completion to
help me through this, and I want to do
the table header, and I want to set this
"=psstyle.foreground" >> Yeah. You have foreground, and background and then a color, and you can also have an arbitrary RGB value,
that's a function. >> I've changed
it, theoretically. >> What did you
change it to? >> Yeah, I like hot pink. It's a little red. Also you'll notice you can change things for
your executables, your PowerShell
files to get them to stand out a little bit better, you can add these settings
into your profile. >> Yeah, notice the first
one there, artifacts. That's a directory, and so we have a light blue
background. Make it pop. >> Now, besides colors, we've also added something, we hope this will
make you feel better, it certainly makes
me feel better. Taking a look at my
screen, you guys remember, when you do something
that takes some progress, you get the big progress
bar that goes like that? >> Yes. You know what it looks like.
See you got to say it. I was hoping we'd let
you change that where you can put in whatever you
wanted, but we never did. >> Me too. >> Let's do this. I'm going
to do the progress bar now under PowerShell
7.2 look at that. Bright, nice, tight, clean, very nice. Of course, you can always change the color of this with PS
style if you want to change. But let me show
you a cute trick. When I'm in my Mac. This is a cool trick. I'm going to bring up
the terminal in my Mac. First of all, this still never stops me from being just thrilled to
death when I can do this. Watch. I'm on a Mac and I'm
going to launch PowerShell. It just thrills me to know
that this works today. Thank you to everyone that
worked on PowerShell 6. Steve, right on. Here, I'll just do "update-help" really quick so
you can see a progress bar. But what I want you to notice
is when this gets going, I'm going to actually
add two tabs. This one's going to start
running the update any second. What you'll do is you'll see a spinning ball up
here in the corner, so that when I go to this tab, I can go back to work and this
spinning ball will turn to a bright blue thing
when it's all done. I think you can do
that on Windows too. >> Yes. >> You figured
this out for me. I had this problem. We
were figuring this out. I'm like, "It works great on my Mac," and he's like, "It
doesn't work on Windows. I don't know why." You
want to tell them how? >> I forgot. I'll sign PS. >> Here's that spinning
ball. Now it's blue. It's spinning and it's blue. You can see it's over here doing its thing, and now it's done. >> If we can go on mine. There's that "$psstyle" OSC
indicator and its default on
Windows is false. If you just set
that to true or 1, then if you do the same thing, what did you do? Update help? >> Yeah, just to get a quick. >> There it is. There's
the little thing. Notice how this is different. Now I can be working in
this script by this tab, and I can just monitor what's going on in
the other than one. It's still working, so I
can't use that one for awhile, but I can just work
in this one. Very cool. >> By the way. What do you
think of Windows Terminal? >> Oh my gosh. Well, you know I'm reminded
of when we first demo-ed PowerShell to
Bill Gates and he said, "Wow, this is clearly
an example of going from the worst in
the industry to the best." My feeling is that's what the Windows Terminal
folks have done, because command.exe
man, it's just sad. >> That console was very sad. >> That now Windows Terminal
is just freaking amazing. >> Back in the day when
PowerShell V1 came out, for me, one of the most helpful
things is tab completion. >> Tab completion. >> Now, if you're just
starting off with PowerShell, let me show you real quick
what tab completion is. When you start typing, if you're a touch typist, what I do is I stick my pinky up over the Tab
key because I end up using that more than
anything else on my keyboard. When I start typing,
if I start typing "Get-ch" and I
hit the "Tab" key, it will auto-complete that
for me. Now let me back up. If I only put in get-c and
I start hitting "Tab", it'll cycle through
everything that'll match that and I can hit "Shift," "Tab" and
cycle backwards. But wait, it gets better. Once you have a command
like tab completion, first of all, it makes
it easier to spell. I'm a terrible typist, so this saves a lot. Also, when you get
to a parameter, I hit dash and I hit the
"Tab key" it'll start cycling through the
available parameters. If my memory isn't as
good, I can go, "Oh, that's the one I
wanted," and fill it in. Tab completion for me is one of the best discoverability among
most helpful things ever. It really solved
with PowerShell. >> PSReadLine. >> PSReadLine. >> Thank you Jason. >> But. >> But. >> Tab completion
does a great job for cmdlets and
for parameters. But once you've figured out some rocking command with
pipelines and all that, tab completion doesn't
really help you with that. Also, a couple of other things. How did you guys get help? Now, if you're like me, you update your help and you use help on your local system. But whenever you do "get-help" and you do something
like "Get-ChildItem," man, it takes up my screen
and I got to read it, so I have to go to
another tab or I bring up another Console
Windows and I work and I read. Well, we've done
some improvements around tab completion in the PSReadLine module to make your life a
little bit better. First of all, let me just solve
the help problem for you. If I type in
"Get-ChildItem" right now and I want help for this, today you press "F1." F1 will take you to
this virtual terminal. The help is being displayed. You can arrow up and
you can go through. It's the full help. Notice you can hit "Q" and it takes you right back
to where you're working. No matter what you're
doing, in fact. >> Not escape colon. >> Not escape colon.
That's right. You don't have to
worry about what keyboard things
do I have to do now. >> That's a VI joke. >> It's a VI joke. Also on
parameters, take a look. If I do F1, when I'm
up on a parameter, it'll take me right to the
help for the parameter. >> That is so helpful. >> Let me tell you, I
wish we had this with v1. Although v1, how it handled
help was fantastic, this is a little bit better. I appreciate this a lot more. My favorite part is you can copy the
example, or whatever, and it takes you right back to where you were working
so that you don't have to have multiple
Windows going and all that stuff.
This is great. But you've probably seen this already on my screen
in light green. Another way that we
wanted to help you is with all those big commands. When I start typing something, you're going to see there's a whole command prediction here. This is part of our new
predictive IntelliSense, that's a part of PSReadLine. What this does is pretty simple. It takes a look at your history. Now, if you've been working with PowerShell for a long time, especially since the v1
days, what we did is, we record your history
in that session and you can use "get-history"
and go look at it, all that stuff, but it was
just for that session. PSReadLine records your history through all of your sessions. Much more useful. Now you can get suggestions from your history anytime you correctly complete a command, it can now be part of
this predictive history. What we've found is this, if you're a highly
experienced PowerShell user, this really accelerates you. You can bang through
it really quick. If you're new to PowerShell, it'll help you, but I've
got something else for you. But before we get there, let me just show you; with predictive IntelliSense,
there's a couple of views. I'm going to do get-c.
I'm not doing a good job. Yes, but if I press "F2", this gives you what's
called a ListView. We've got two views. ListView where you can
see a whole long list of options and you can arrow down and select the
one that you want. Or some of you that are
more comfortable with the Z Shell or rust
experience like I am, you want the inline view. But here's the best part. It's not like you
have to go out and reconfigure all this. Just hit 'F2" and flip between them and use
whichever one at the moment solves your problems. You've got two different views
that you can use on this. What do you think?
Isn't that cool? >> This is crazy. We make less mistakes in
PowerShell now than we used to. >> That's the test. If
you've watched these before, notice we're making
a lot less mistakes. But the interesting
thing about this is that the other perspective
we wanted to look at this is we didn't want
to just help you with what you've already
done successfully, what if you're newer to
PowerShell and you needed some help with understanding
what commands are available, what parameters are available? Let me give you an example. First of all, when
you get PSReadLine, this feature isn't
going to be turned on. Here's how you turn it on. You set "PSReadLine." Thank you predictor,
that's close. Set "PSReadLine" option. I'm going to do
"-PredictionSource history." That will enable this
historical predictor. We don't have it turned on by
default because we figured it'd confuse everybody
at first if they saw it. Now, that'll give
you the history one, but if you're working with
some additional plug-ins, there's one plug-in
that's written today for Azure PowerShell. I'm going to turn that on
and here's the best part. Now when you start
typing "new-az," take a look what's on my
screen and being predicted. Now that Azure predictor
is predicting, these aren't in my history, it's predicting
the full commands, here's the best part, F2. There's nothing in my list
for F2. I don't know why. Usually there is. Let's
see if I get it this way. Well, I'm not
getting it. Let's do Resource Group. I know why. The internet from here
is a little bit slow. That's causing me an issue
with this predictor display. But you get the idea because you can see what's being
displayed already on there. This predictor will not only give you suggestions
for commands, but as you move through
the Azure commands, if you filled out the arguments, it'll reuse those arguments
when it makes sense. If you created a
resource group and now you want to create a VM, it will auto-populate
that for you into those arguments
for those parameters. It will really, not
only accelerate you, but teach you as you
go to work with it. We hope that predictors like this will really
help newer people. >> You're seeing AI getting
introduced step-by-step. One of the things we
want to be able to do is to run AI against
the full corpus of public domain PowerShell
commands to see what are the patterns when
somebody does get through. What are the typical
parameters they use and then highlight those, make them more prominent as opposed to having to
cycle through everything. Watch that space. There's just so much innovation
coming on there. >> Watch the space
that we're doing. The Predictive
IntelliSense things and we refer internally
as this is dynamic help. Things like hitting
F1 to get the help. These are new tools for you to use that will help
accelerate you and we hope, with the AI, help teach
you some of the things that maybe you
didn't already know. We were talking about tab
completion improvements and I'm like, dude, this is a pretty good one, but there's more actually
with tab completion. >> Yes. What I was
going to show is that the tab completions also works for values.
What does that mean? I'll just say "gps"
format table and say, but what we notice
here, start to tab. What's that? These are the properties available
from Get process. I can also say, "-view." Did you know that format
table had a view? Very few people use this. >> I don't think...
this is awesome. >> Why don't you just do
this. Let me show you. "gps w* ft" That is actually
the process view. >> I don't even
think I knew that. >> Tab complete says, look, there are these other things
like priority and StartTime. StartTime, in fact, what you want to do is you want
to sort first by StartTime, sort by StartTime. Then here let's just clear this first and then look at this. Now what we've done is it says it's sorted things by
StartTime and you're formatting the processes based upon grouping them on StartTime. These things started a couple of days ago and these
things started today. Crazy stuff. Then I was looking at this and was like,
"Yeah, this thing's awesome. " "Format table, view" and check
this out, "version info." I said, "Jason, you got a bug. Like version-info. Look, it gives me an
error. What the heck?" He's like, "No. Jeffrey, you forgot. You know so much you forgot." It turns out that get process, I don't know if you knew
this. Check this out. Slash include username,
file version info. Get-Process FileVersioninfo. Then this is showing
you the files associated with the
particular processes. If you said, Get-Process,
let's make this clear. "gps Powershell"
"fileversion info format table view." That's the path to PowerShell. By the way, that's the path
when you install it from the store. Crazy cool stuff. >> One of the things that
Jeffrey is showing here is, he's hitting "Tab"
to get the views. See, the reason that none
of us knew that there were additional views
out there is because, while we didn't know and you
had to manually type them in, but one of the things
that we've lit up for 7.2 is, on views, which there are some out there that you're going to want, you can now get with tab completion. That's why we ran across the file info one and
went, "Hey, this is cool." Then it broke and
he was like, "No, we have to turn it on with the cmdlet," and it
worked beautifully. Hey, that's really cool.
I like that a lot. >> Yeah. Except, look at this. It's like, well I got
colorized table headers, but everything else is the same. Whereas when I do a "dir," look here, I get all
these nice colors. Yellow for the PS1, etc. I want to go down a
path and I want to explore making my
colorized output. Now, PS style is hard-coded
to a set of scenarios, but I'm going to show you
how using techniques in PowerShell version one,
you can do the same thing. I'm going to show you a
path, show you it didn't turn out and then show you
the proper way to do it. But first, what I
said was, PowerShell has an adaptive type system. I said was, I'm just
going to modify the type system so that when you see "ask for process name," you get it colorized. >> That makes sense. >> What does that mean? First, let's go here and say
this is update type data. Update type data, you can
modify the type system. What does that mean? You'll see. First you got to tell us,
what type do you want? I say system diagnostic process. Then what do I want to do? Well, I want to add a member
type, just script property. Its member name is
NewProcessName and its
value is this script. Here, just so you see what
the script says is, hey, if the session ID equals zero, which basically is
a system session, define a variable
color to be red, otherwise make it green, and then emit this script. Basically it says
emit the color and the process name and then reset. Let's see what that says. Now, I add this and
what I can do now is, so first off I say Get-Process, get member star name. You see now, I've got this
new process name here. This as a process
name as a property. This is a script property. You've modified the type system. Now this only happens
for this session. If you wanted to persist
across sessions, there are other ways to do that. But now what I can
do is I can say get process w star to format table. No I can say format table, let's say ID name, process name, new process
name and look at that. All of a sudden, it comes out. >> It looks Christmasy.
I love that. >> Yes, it is Christmasy. That's cool, but now
I want to refine it. First is, this is really cool, except I really don't like this. Some people like this,
but I think you can do better with something
we added in PowerShell. Which version are we
at, I don't know. We just recently added it. It's called the
Ternary Operator. >> It's PowerShell
7 is when we added it. It's either 7.0 or 7.1. >> I forgot to say. This
is what I wanted to show for yucks. Look at this. I don't know if you know this. Question is, how do you
know what the type is? You say get process,
pipe two, get member. I promised these errors. Type to get member. It shows you-all the properties, but up at the top there, it tells you the type, so
it tells you the type. There's another
way you can do it, and that is $A, $B = get process. $A, that's one process. $a.ps type names. This tells you the
type hierarchy. Every type starts in system.object and
then it gets refined. As it gets refined, it
gets more properties, gets more methods,
etc. Check this out. What I'm going to do here is I'm going to go and
I'm going to say, "Hey, everything that
is system.object, which is basically everything, I'm going to add a property, this time a note property called PS owner and its value is JPS." What's that mean?
That means one. PS owner is JPS. I can say Get process
piped W star, pipe to format ID, ID, name, psowner. Everything in the
entire system now has a property called PS
owner and I own it all. This is just some
of the power of the type system and this is a type system you
can modify anything, plugging things on there. Now what I'm going to do is talk about this ternary operator. First is the code as
it typically works. That is this, so you have an if statement. I'll say if dollar sign true, then use PowerShell, otherwise rocks and assign that to a variable x
and then I emit it. It's true so you get PowerShell. If it's false, you get rocks. Now, I gave it in this one
line instead of spread out, because this sets us up to
show you the ternary operator. Basically what it does, it says, now I get rid of the
if and after this, I put question mark and the
"else" I change to colon. Then I have to change these
squiggles to brackets. Now, it does essentially
the same thing. Basically it says, a
ternary operators, this format, this syntax. If something's false, it returns the second
value and if it's true, it returns the first, so we assign that to x and
then we emit x, so rocks. >> Just as a quick note, if you're saying, well, I can already write
an if statement, why would I even mess with
the ternary operator? First of all, a
lot of folks like the ternary operator
because it makes their code easier
for them to read. It may not make it
easier for you to read, but you should be aware that the ternary operator is
out there, how it looks, because you're going
to start seeing an awful lot of demos, a lot of scripts written
using the ternary operator. You don't want that
to throw you off. One other side note for this, if you use a ternary operator, your scripts aren't
going to work down level on Windows PowerShell51. >> Good point, but
I really like it, so I tend to use it. Now I'm going to do the
same thing, but you see, to me, this code is
much more pleasing. I go ahead and do that
and then do it again, newprocessname. Now it's the same. But notice, I got to keep adding
this newprocessname. I did that for scaffolding. What I really want
to do is to say, no, I just want to
change the ProcessName. What I'm going to do now
is to change that and say, now I override the thing. >> Oh, I like the sound of that. You're going to
override ProcessName so you get it colorized
the way that you want it. >> Yes. Now when you go and I just say "Get process" and it asks
for ProcessName, it's going to run my code and it's going to fail
any guesses why? Here's what happens. I
went to the type system, I modified the type
system itself. It's so incredibly
powerful. You modify the type system
itself and I go to processes, and I say it has a new property called
ProcessName and it blows up, of course, it's
going to blow up. It has a new thing called ProcessName and
here's its value. Look here, part of its
value is this.ProcessName, if you try to evaluate it, it refers to itself. It took a while before it blew
up the stack and blew up. Now let's use this to
highlight the type system, like what's really going on there and how do you
avoid this problem? First, let's do this. I'll do this with the Cim because it's a little
bit more interesting. I'll get the BIOS $b. Oh, great. Then I say, what really is
going on here and by the way, when I have this, $b
can do things like just specify the name.
Well, that's great. But what do I really have
b piped to get member. It looks like I have
this nice object with all these wonderful properties.
Turns out there's a lot. In fact, if I did that relates
to a format list star, there is quite a few
properties there, we have this view of it. But what's really going on? That thing there is
in fact a fiction. If I do this for real, I say $b piped to get member
-view, remember view? There are different views. There is an Adapted view, which is what you generally see. There is an All view and
there is a Base view. The Base, remember I
said type PowerShell is about making your life
simple part of that is taking wacky type
systems like Cim, and turn it into something
that makes sense to you. Because guess what if you
had to deal with Cim, this is what you'd
really be seeing. You'd see this. >> Oh, Jeffrey, there's
nothing useful there. There is not the
stuff that tells me this all of a
sudden got harder. >> Every single Cim object
looks exactly like this. There is CimInstanceProperties and there is
CimSystemProperties. Remember when I
did that $b.Name. What you actually
have to do is to $b. Here's the trick to get
to the base object. Every object in PowerShell
has a property. We don't really talk about
it much called psbase. That gets to the core object. That is the real thing. If you wanted to get its name
and we just did partial, didn't do its magic for you, here's what you do. hisname.CimInstanceProperties''Name'' >> Oh yeah. >> Oh no. That's not it. That gives you this
funky data structure. Then you got to
ask for its value. You could ask for
that or b.name. That's why we have
this adaptive type system. Now, remember $b.pstypenames, this gives you the hierarchy. Now notice here, remember I
said everything starts with System.Object and it does,
then it's System.Instance. But then notice everything after that has this pound sign. This is PowerShell's
synthetic type system because every Cim object, be it a BIOS, be it a process, be the disk an IRQ, everything basically has
these first two things, it's a Cim Instance. But how does that help you? We want to say oh if it's
a BIOS, show it this way. If it's IRQ, display
it that way, if it's a process,
display it that way. We've got no hat to
hang or hook on. What we do is we produce the synthetic type
hierarchy on top of it. This is all just made-up stuff. >> I like the made-up
stuff, but obviously, we need to get to the
real object in order to solve the problem
of recursion. >> Exactly. >> I say obviously, I'm
just following along. >> Therein lies the trick. Now what we do is we're
going to go add this system, that was all about showing you how you get around this problem. The problem was, I adapted the type system but I adapted in a way that
created this recursion. What I want to do is I
want to say, I want to replace the existing thing, but then when you go
to get the value, I need to refer to
the core object. I want to refer to the
PSBase.ProcessName. This is the same thing. The only thing I added
here was this PSBase. Therefore when I add
ProcessName, it gets it. Now add that - and I ask for these.
Look at that. >> That is amazing. >> By the way, look here. It shows this way. But then also if I want to
say get process pipe to format table id, name. It shows up if I
say $p = gps lsass. I said I'll assign p.name. Everywhere, you
ask for the name, ProcessName, it shows up. This is crazy. Except it
doesn't work. No, it works. >> I see it what are
you talking about it. >> Imagine I say gps. - name $p.name. Look, it complains. >> Why is it
complaining? > > Because now the name
has asking sequence in front of it, saying "turn
the screen red." If I said psbase.name, anyway, or ProcessName.
It does work. >> There you go. >> It's like yeah, works and
it's cool, fantastic tool. But for this technique that
wasn't the right technique. The right technique is in fact
to extend the view system. Notice when I get process, I'm not specifying
a bunch of stuff. It just happens. Why is that? There's a whole
bunch of default and going on underneath the covers. Let me show you a
little bit about that. Oh, by the way, there's
one thing before it, if you know, I'll show
you one more thing. >> Yes. >> Back to that. Get
process objects or the things that we really
built the type system, used it as a playground for
building the type system. Get processed pipe to get
member -view extended. This shows you all
the extensions, all the difference between the base object and the
object that you get. Look at here, we have
alias properties. That's why I'm able to type
name and it maps to getName, that's why if you type handles
it maps to Handlecount. Because when you're in
front of 700 people and if you forget the
o and Handlecount, it's a terrible demo. I never make that mistake
again. I always use handles. Then we've got CodeProperties, NoteProperties, PropertySet
ScriptProperties. Again it is PropertySet.
What's that mean? Well, imagine I say
gps lsass pipe to format table PSConfiguration. It's a name that maps
to a set of names. If you want to get some things, you always want to
select something. I think I can say this, GPS star, pipe to select, PSConfiguration, I specify one thing and it pulls
out all those parameters. Yeah, so the type
system is crazy fun. >> There's a couple
of morals here. First of all, this all started because we enabled
the feature of tab completions
so that you could tab complete views which
you didn't know you had, but now you know you had. >> Yes. >> That was the first thing. The second thing is that, well, with PowerShell, you
can always solve the problem. As you see, Jeffrey went
down and went, "Hey, I want to take some PS
style, add some color. I want it to be
specific to this." It blew up and hey, "Let me drill into this further. Let me figure out
another way to do it." PowerShell always enables you. Sometimes you have to drill
deeper, but you can do it. >> Yeah. The key thing
is to hopefully get to you understand what's behind the covers and encourage you
to explore and have fun. Obviously this path didn't
quite work the way to do it, the right way to do this is
in fact with formatting. With formatting, what you
have here is my formatting. I created a format table. >> Yes. >> Now the way to do
this is to go find an existing format table
and copy it and modify it. What I did was, I found the format table that was actually in
PowerShell version five that had
the .net types.format.PS1XML. >> That's the one you want. >> What it says here is, "Hey, I got view definitions," and here we select this
by process name. Basically what
happens is it says, "You made an object and the formatting system
gets it and says, 'what is it's type?'" It looks here and
says, "I found it. Somebody's got it, this
is how to format it." If you don't find anything, it then walks down
the type hierarchy. Now what we do is it says, "I want to do it as a table." You specify all the
table columns and then the values or how
to generate the values. Here's what I've done, is now what I've done is I've taken that code from before,
color says, "Hey. Depending upon the session ID, make it red, otherwise
make it green." Then emit the string, giving the color, and
the process structure. >> The PS base process name. >> Then you do a reset. You always do reset
to get rid of that, because when you set
one of these colors, it changes it for everything
going afterwards. So what you do is you set it, emits your text, and then reset. Now that's in this XML file, so what I do is then I've got
to update the format data. You want to say pre-pend
because it's ordered like, hey do you put it at the end or do you put up it
at the beginning? Here I'm overriding
the existing stuff, so I want to pre-pend it, and I say verbose
because, why not? Now I've taken that XML file, I've defined a new way to do it and so then whenever it says, Get process, process object
gets emitted, says, "Hey. What do I do with this thing?" Does this selection, finds
0system.Diagnostic.Process This is the formatting to use when you go to emit ProcessName, run this script, and
emit these colors. >> Couple of little
side notes though. You want to make your own
view and you want to grab your own PS1XML file, you can. They're located
where PowerShell was installed, but be careful. What Jeffrey had
done out of the.net. I can't remember
the.netPS., yeah, that one, was he copied
a section out of it. Don't modify the actual ones, you're going to notice
those are signed and that would not be good. >> That'd be bad day. I got
to say I'm just going to go and apologize that XML
is hideously complex, is not a happy day, and I screwed up every
time that I do it. Because there's tricks, sometimes you don't have to specify the name in the width, and therefore we'll
just pick the right. It's a mess, but you can get it. >> Well sir, guess what?
It's happened again. >> We're out of time? >> Yeah. Take a
look at my slide. >> What's next? >> What's next? Well again, 7.2 is generally available probably at the moment
you're seeing this video. Again just to remind you, it's LTS support, so you get three years of support on this. This is our long-term one. Remember, you can now
get this from the Store. You can now get updates from
Microsoft Updates for it, and update your way through
your PowerShell experience. We've got lots of improvements and a lot of the things
that we talked about here. Also one little note to
mention, we got DSC. Yeah we're working
on DSC as well. Now what can you do? Well, first of all,
get PowerShell 7.2. Look folks, it runs
side-by-side on your Windows box next to
Windows PowerShell 5.1. If you're thinking, "Well, I'm afraid I might break something." Hey, put it on your box, you can now test
everything really quick. You're off and ready to go. We've got lots of projects
out of GitHub.PowerShell, that's where you'll find
all of the stuff with us. Of course, if you want
to follow the team or Mr. Snover or myself,
you certainly can. In summary, well,
PowerShell does make you more productive no matter
what, wherever you are. >> Hey, did you give a shout out to the conference coming up? >> Hey. As a matter of fact, I may have it in here. I do, with a link. Hey, we're gong
to be celebrating PowerShell's 15th birthday. Come join us at the
Automation and DevOps Summit that'll be occurring
right around November. PowerShell's birthday
is the 14th, I think this conference
starts on the 15th, so we will be doing a slightly belated but a happy birthday. >> It's a virtual
conference, correct? >> Yeah, it is. This year's
a virtual conference, they really wanted
to do it in person, come back next year, we'll do it in person. This
year it's virtual. It's going to be a
blast multiple tracks, all that great stuff. It's funny because I've
got this up here that says we're 21 years in
the PowerShell, but PowerShell is
only 15 years old. You started this
a long time ago. Well, just from
everyone, first of all, happy birthday to you, happy birthday to PowerShell, and thanks for 21 years of making one of
the best products I've ever seen in my life
makes us all better because, what's the best tool you
have in your toolbox? It's going to be PowerShell. >> Thank you so much. I hope you got a lot out
of this session. If anything, I just hope
that you walk away with a, "Hey, PowerShell's fun." There's some cool stuff
coming down the road and it's great to explore. There's so much
there, so much to do. When you do that, you
make mistakes again, like I did at the beginning,
and make mistakes all the time. That's normal, do
not beat yourself up and don't stop when
you make a mistake. No, when you make a
mistake, lean in, reach out to the community, have connections, ask
the community for help. The community will help you, the community is a
fantastic community and then also you
help the next guy. Thank you so much for your time. I cannot wait to see you in
person hopefully next year. >> Take care.