windowsnerd.com

notes from an admin for himself. you can read it if you want.

Entries Comments


Custom Search






Power Shell Lesson #1

I learn things by doing them. My style for learning power shell is to skip a lot of the hype/theory and just walk through doing something. I’ll explain a little bit about the commands we use. This round we will download and install Hamachi as a service to get familiar with the power shell environment. Hamachi is a free vpn client that will tunnel through the most painful networks. It is awesome to start as a service because your machines will still be reachable after a reboot. Now we have a practical goal which will just happen to use powershell to execute.

This is all about practice. I may tell you go do things a few times or unnecessarily to practice. Skip ahead, do it 10 times, whatever works for you. Please leave me a comment if it helps or you think it could be better. I want to offer free lessons for the average windows admin who may have gotten along all this time on GUI alone. I know a whole bunch of them including myself so don’t feel like you are behind.

Install powershell and download the latest free hamachi vpn client to prepare.

When you launch powershell you start in your home directory. To start we are going to head to c:\ and start a directory to work in. Type in cd \ to get there.

Build a directory called pslessons by typing “mkdir pslessons” notice we use mkdir like in unixland.

pslessons

Next we are going to use tab completion. Type in “cd psl” and hit tab. it will complete the pslessons word for you. hit enter.

psl tab

Now you are in the pslessons directory. Type in “ls” to check.

“ls” like in unix land. cool huh? Lets also try using “pwd” This will show the current directory.

pwd

Now we are going to find download of hamachi. Here is where it starts to get cool. Using  good old dir we are going to search all of c:\ for hamachi*.exe and sort based on length. Remember to try tab completion for all the words and ignore the permissions erros for now:

 “dir -Recurse -Filter hamachi*.exe c:\ | sort length -descending

find-hamachi-install.JPG

We just used a pipe. This is a fun thing that makes powershell awesome. We are taking the output from the filtered dir command and putting it into the sort command to filter based on length. Not necessary but good practice. Now we know where your download is and we will use that to copy into our practice directory:

cp c:\downloads\software\hamachi (hit tab) c:\pslessons

copy

Check to make sure the copy worked.  

Now we can run the hamachi installer right out of command line. Type H and hit tab. The exe comes up and now we just run it. BUT WAIT! look at what happened when you hit tab. It added something at the beginning. “./” This tells powershell that we are running the hamachi command in the current directory. This is very common in unix. You have to specify the hamachi you want to run. If a command is in your path and also in the current directory it will run the one in the path before running the one you intended in the current directory. 

hamachi tab complete

Now install hamachi, create or join a network and we get in to the fun part.

Now head to Powershell lesson 1B for installing hamachi as a service.

Comments

Comment from Ron
Time: June 22, 2009, 7:39 pm

this is a nice but brief start. Thanks for taking the time to put it together for us newbee’s….

Write a comment