Navigating a PowerShell session is no different than navigating a DOS window
or CMD window that you hopefully have done in the past.
You can use really the same commands to get started.
So let's say I want to change directory to the Windows folder.
I can do cd, for change directory, and then the path to the folder
that I want to change to, and then press Enter.
You can see the prompt changes.
I can type the dir command to get a list of all the files in that
directory. If I want just the executable files, I can say, hey,
give me the directory listing of *.exe. Let's go ahead and change
to an environmental variable to the %appdata directory. Now in
PowerShell, you're going to type it like this. So I'm going to do
cd and then $env:appdata.
Now the $env is a way of telling PowerShell to use
the environmental variable AppData.
Again, I know I'm showing you some things that you probably haven't learned yet,
so just kind of follow along in the demo file.
Eventually, you'll understand exactly what you're typing
and why it works the way that it does.
So now I'm in the AppData variable for my artd user.
And again, I can do a directory listing.
Now, if you're from the CMD world,
you may be thinking, know what, I want to look in that Microsoft
directory and I want to search all these subdirectories. So you'll
type a command like this, and that fails.
Now don't worry about the error message other than the
fact that you know that it did not work.
What you need to know for just right now is that even
though we're using the dir command,
technically what we're using is an alias for a
PowerShell command that does the same thing.
The command that we're running in PowerShell, this dir
command, doesn't understand what /s is.
Eventually you will learn about how to get help for these PowerShell commands.
For now, let me just let you know that instead of using /s,
you will use ‑Recurse. And this will go through, and now I get that recursion
that I was looking for. I can do similar things saying,
hey,
I want to search in that Microsoft directory for all my link files recursively,
and you can see that that all works.
I can go back to the root of C,
and I can use cls, or clear host, to clear the screen.
Other things that we used to do in this DOS world, the cmd world,
still work also here in PowerShell. If I want I can just echo some
text to the screen, like Hello, World.
I can direct that text to a text file.
Now here I'm using the legacy operators, that angle brackets,
which is the redirection character,
and I'm redirecting it to the documents folder to a file called
hello.txt. That little squiggle there you see in front of documents,
that's a legacy shell shortcut that PowerShell knows,
just like the DOS shell does, the CMD shell knows, it knows
where your documents folder is. And if I want,
I can also append information to it using the double angle brackets,
that's the legacy DOS APPEND operator, it works fine here in PowerShell.
And to do a directory listing, so there it is,
that little squiggle there resolved to C:\Users\artd. I didn't have
to try to remember who I was or the path to that.
That's a nice little shortcut there.
And, of course, I can also use, again, DOS type commands to say,
hey,
show me the contents of that text file. Let's clear the
screen here. Let's make a directory.
Let's make a work folder. In the DOS world we used the mkdir command.
You know what?
I can use that also here in PowerShell. So I just created the work folder.
Let's copy a file, let's copy a Notepad, and let's copy it to the
work folder. And take a look, and sure enough,
there it is.
If I wanted to, I can also delete that file.
And if we verify that, you can see that that executable is now gone.
And if I really am done here, I can even remove the directory again,
just like we did in the DOS world.
And now you can see that the work folder is missing.
I can launch applications from PowerShell just like I can from any other
session, any other window like in DOS or the CMD window.
I can type Notepad. I could type calc, and there I get the Windows calculator,
although what's really cool here is that I can do
math in the PowerShell session.
I can do 2+7+1, or 15*2, 25/5, or something like that.
Navigating and working in the PowerShell shell is really not that difficult.
When you're done, you can either just close with the X or you can type exit, and that will exit the shell.