So that's enough talk, enough slides.
Let's jump into PowerShell,
and let me give you some examples of how to use PowerShell help.
All right, so let's take a look at PowerShell help in PowerShell 7.
Now just so you know, I'm running PowerShell 7 in a Windows terminal.
It makes no difference whether you use a Windows
terminal or the PowerShell console,
the commands and everything is going to behave the same.
So let me start here by just doing get‑help for the get‑service command.
And this is a brand new installation of PowerShell 7 on Windows 10.
So you can see, it goes through very quickly,
and I get that little remarks at the end saying hey,
PowerShell does not have all of the updated help.
It's only displaying partial help.
And it gives me instructions there on how to run Update‑Help.
So I'm going to go ahead and run Update‑Help right now,
and then we'll talk about it while this is running
because this will take a few minutes.
So a few things here about Update‑Help, and you can see that it's working there.
There is no indication when you are running PowerShell that
there is new help to download other than what you see here
when you have a new installation.
In order to update help, you must be running in an elevated PowerShell session,
meaning you must run it as administrator.
And now you can see there in the title bar of my terminal,
I'm running PowerShell as administrator.
So that's the first thing.
You also need to know that when you run update‑help,
what this is doing is going out,
typically to Microsoft or wherever the link in the help is pointing to and
downloading the CAB file that have the help documentation.
Now by default, Microsoft really only wants you to go out once per day.
So if I were to run Update‑Help again immediately after this,
nothing really is going to happen unless you use the ‑Force parameter.
So if you're testing and need to make sure you get help updated,
include the ‑Force parameter.
‑Force will also skip any sort of version checking,
and it will also download files that exceed 1GB in size,
although I'm not sure I've ever really come across that.
Now as this is running,
you can expect when it's finished to see some errors because sometimes
there will be links in the PowerShell help that point to a place on the
internet or on Microsoft that don't exist.
Maybe they're just a placeholder for future content or the link is there,
but has not been modified.
So we're just going to let this run here, and this may take a few more minutes.
And when it comes back, oh, it's all finished there.
You can see that I got some error messages there.
So a few error messages are to be expected.
If you get a lot of error messages,
that means you probably are not running as administrator.
So let's take a look here at Update‑Help, the help for us.
So you can see that you can specify a different module.
You can specify different cultures.
You can specify the ‑Force.
The More is what you get when you run the help command so that pages it.
Get‑Help just runs the full thing without any sort of paging.
So if you're not used to the More command, Enter just go to the next page.
Spacebar goes to the next page.
Sorry, Enter just goes the next line, Spacebar is next page.
Or you can just do q to quit and get back to your prompt.
So just to show you here, I'm going to rerun Update‑Help.
And I'm just going to get a single module.
And just to demonstrate, I'm going to specify the German culture,
and I'll use the ‑Force for this to go out again.
So this is going to go out and this failed because there
is no content for the German culture.
You'll find that a lot of help content pretty much defaults to the
English US, although you can always check if you have a different
culture. You can try specifying your particular culture.
I don't have a culture‑specific machine to really test with or show you.
All right, so let's clear the screen here.
Now let's go back to our original command.
So we're going to do Get‑Help on Get‑Service. So
this scrolls all the way through.
And if I scroll up here,
you can see I now have NAME, SYNOPSIS, SYNTAX, DESCRIPTION, RELATED LINKS.
I no longer have that same error message saying that I have to update help.
So I now have help, and I can use it and get all the information that I need.
Now another thing that you can do with Update‑Help is you can
save it locally and then install it locally.
You may want to do this if you are in a team
environment because there's no reason for,
you know,
10 people to all go out to Microsoft where all you have to do is just
save the help locally and then install it locally.
So there is a command that you can run.
We'll get to it here in a moment. So I'm going to save all my help
and make a directory called help on my local hard drive. And I'm
going to use the command Save‑Help.
I'm going to let you look at the help eventually to see how to use this.
But I'm going to run Save‑Help and specify the module.
I'm just going to do a couple sample modules,
specify the destination, and do Force because I've
already kind of run Update‑Help once.
So this is going out now and saving and downloading all of the
content, all these CAB files to the local hard drive, to the
destination that I specify. That destination could be a UNC or it
could be some team drive or whatever you want.
And again, there is an error message there about PSReadline,
although if I look at the help directory,
I can actually see that I've actually got content.
So I'm not quite sure where that error message is coming from.
One thing about Save‑Help though, this is very important,
Save‑Help will only download help for modules. And in this
case, I specified the modules.
If I just did Save‑Help without specifying anything,
it would then do all of the modules.
But this is only going to install help for modules
on my machine or, in this case, Save‑Help is what I'm running.
Keep this in mind because if someone else then goes to
update the help and they have a different module, they're
not going to get the updated help.
So that is one potential drawback.
You kind of need to make sure that when you are saving help,
whoever is going to be up loading or updating help from your
source that you all have the same modules.
So now on another machine, I could run Update‑Help. Again, the
modules, I'm just using my samples here, specifying the source path.
And now PowerShell, instead of going out to Microsoft or out to the
vendor wherever the link is pointing to,
we'll download the help files from that source path and
then save them locally to my machine. So that really kind
of speeds up the whole process.
So now I can run help for get‑psreadline option, one of
the commands on the PSReadline module. And I have
everything there and same thing here.
Let's look at get‑smbshare, another command from the other
module. And I have everything that I am expecting.
So I know now that Save‑Help worked,
and I'm real improved much good to go. As a note, although I'm not going to
really get into because it's not that kind of course,
you can also use group policy to configure those source paths.
So if you want to make sure that people are downloading
and saving help from an internal source,
you can configure that through group policy.
One last thing here about Update‑Help before we move on to the next demo,
Update and Save‑Help are version‑specific, meaning this also will work in
Windows PowerShell. But when you do Update or Save‑Help,
you're going to get the PowerShell 5 or 5.1 versions of help,
not the PowerShell 7 versions.
If by chance you still had, say,
an old PowerShell core machine running PowerShell 6.
something, again Update‑Help, Save‑Help is going to get that
version‑specific help of PowerShell.
So keep that in mind if you end up building some sort of mechanism to download and save help.