Category Archives: Articles

Articles I Write

Intro to Powershell

I’m not sure if a lot of people out there are using powershell.  If you are working in a technical position I think that you should definitely investigate the possibility of using it to manage day to day tasks.

Microsoft has been requiring all of their software releases to include an interface for powershell.  This has been especially evident in the newer operating systems as well as Exchange and Active Directory.

What I hear most often is, “Well it seems complicated and I can’t program anyway; its really hard.” In actual fact its really easy; much easier than driving a car or riding a bike.  Don’t believe me?  Try it.

From any Windows 7 (or newer windows computer) try clicking on start and then type in “powershell” into the little run box and press enter.

Start - Run - Powershell

So… thats it… powershell should open and you can start typing in commands.  If you are familiar with DOS commands they should work here (almost) like they always have.  (try dir, cd, copy etc..).  Also, probably due to a lot of complaining, you can use unix type commands (try ls, cd, cp).  Both should work!  Finally!! Forward slash AND backslash work… which… makes sense.

So you are probably thinking to yourself, “Big deal, you said this was easy, that stuff is really hard.” Did you know that all of the commands in powershell are actual verb-noun pairs?  In fact, even the short commands like the ones I listed above are actually aliases for verb-noun pairs.  For example, dir or ls are ACTUALLY aliases for a command called Get-ChildItem; Don’t believe me?  Type “alias dir” and you should see something like:

PS C:\data> alias dir
CommandType     Name                            Definition
-----------     ----                            ----------
Alias           dir                             Get-ChildItem

Hmm… Thats interesting.

So what is going on here?  Why is that useful?  Well, the answer is really quite simple.  Those old commands were made back in the olden days when computers couldn’t even store a program with a name greater than 8 characters!  Like 20 years ago! The nerds of back in the day love their commands and they can still use them and newbies can jump right in and get their feet wet.  The basic fact that they are verb-noun pairs means that you can GUESS at what the commands actually are.  For example type get-  (that’s get and a dash) and start pressing the tab key in powershell.  Did you notice that starts suggesting commands to you?  Pretty cool huh?  Whats even more important is that you can read the noun and probably GUESS at what each command does; even without a book.  Other cool verbs to try are (set-, start-, export-, stop-, select- and many more!! You can even add your own).

Alright, so whats next?  Well… I hope I’m keeping you interested and you are learning quickly.  After all, thats the point of this exercise.  In my opinion, you need to learn how to use 1 command to actually learn all of powershell; but understanding about 4 of them would actually take you to the next level.  So what is that command?

help

No, that wasn’t a typo, I want you to learn help!  Help has many names in powershell.  Its also known as Get-Help (verb-noun pair 😉 and has an alias of man for the linux nerds; for normal humans “man” actually means “manual”.

So when you type get-help, help tells you how to use help! I know it all seems a bit redundant but you need to wrap your head around the concept of how help works.  EVERY single command in powershell should be in the manual and hence… you don’t need the book.  If you want to see examples of help for a particular command, you would add “-examples” to the end of your help command and the shell will actually tell you what to type in. The help command would actually tell you more about this if you wanted to see the FULL information about help… to do that type:

help -full

At this point you should get the same information that you got before plus another 3 pages of information about help and using help.  I STRONGLY recommend you read this if you want to learn powershell in any capacity.

The next thing you need to learn are the following commands:

get-psdrive
get-command
get-member
get-alias

How do you learn those commands?  Don’t make me smack you! Type:

get-help get-psdrive -full

Get it?

Its all pretty easy, I’ve already given you everything you actually need to know in order to “learn powershell”. To make it a bit more fun, how about a real example?

Now lets say your friend is bugging you. You don’t like it, but its your friend and you don’t want to actually hurt their feelings.  What is a good way to annoy them?  How about opening 30 copies of notepad on their computer?  That would be great!! It would annoy them a little bit and you get to use your powershell skills to make the job easy.  Type the following command:

for ($x=0; $x -lte 30; $x++) { Start-Process notepad }

Press enter and voila!  You just opened 30 copies of notepad.  Sweet! So what is going on there?  How did I do that.  Well the command above is actually something called a loop.  The first part says set the letter X to the number 0, make sure X is less-than-equal (-lte) than 30 and each time add 1 to X ($x++).  The part in between the curly brackets is what we want to do 30 times.  In this case we specified a command to start notepad.  Pretty nifty and fun too. If you want to learn more about for loops try:

 get-help about_for

You might think to yourself, that was actually not a nice thing to do to your friend and you don’t want to have all those notepads open on their computer and actually you want to clean it all up for them.  Well… in that case you would type something like:

Get-Process notepad | Stop-Process

Wow!! Cool, it just closed all those notepads in one command!! How did that work?  Well… the command above introduces a concept of something called “the pipeline”.  Yes, I know the pipeline is something that surfers strive to ride, and good for them; in this case, it means something completely different.  The “pipe” is that “|” character.  It basically says, take everything from the last command and send it to the next command.  The command above instructs the computer to find all the processes running on the computer that have notepad running and take those OBJECTS and pass them to the stop-process command.  You could of course just typed “get-process notepad” and it would have done something different.

The pipeline is a pretty cool concept. Imagine all of those verb-noun pairs and linking them all together.  The possibilities are endless; I hope you benefited from my powershell introduction. Obviously some of the commands in powershell are dangerous; so be careful.  I wonder what the stop-computer command does?

Happy powershelling!

~JCF

7 Reasons For A Personal Website

Having a website of your own equals entering into an invaluable communication environment. There are at least 7 reasons why it is highly advisable for you to be present online:

1. Represents your personal profile

A website can be your virtual portrait, showing off your personal self to the world on a 24/7 basis.  Among the most popular ways of presenting your personality online is keeping a webblog (otherwise known as online diary) or a photo gallery, where your friends can stay up-to-date with your daily living.

2. Spreads your voice across the world

A website can be your global “tribune” where you are able to share your knowledge, experience and enthusiasm with people who have common interests, but with whom you might not otherwise have crossed paths. A very popular idea-voicing tool is the discussion board, better known as “forum”. You can also have a guestbook on your site, where people can discuss your postings.

3. Lets you be in touch with people at a distance

A website can be a meeting place for making new acquaintances with people of different religion, nationality and age, as well as for keeping in touch with friends who may be on the other side of the world. Thanks to the almost unlimited online communication possibilities you can conduct one-to-one conversations with many different people directly from your website.

4. Broadens disabled people’s interaction with the world

A website empowers people with limited access, due to handicap or illness, to broaden their communication with others. A website can be a physically disabled person’s door to the dynamic world, allowing him/her to bridge over the difficulties of having a “different” everyday life. It can even be their office, where they can present and deliver certain home-made products/services directly from their living room.

5. Creates a web skill development environment

A website can introduce you to the secrets of www. The contemporary web design technologies have brought the art of creating a website just a few clicks away from the inexperienced user. Thanks to the popular WYSWYG(what you see is what you get) web design tools, absolutely everyone (irrespective of age or education degree) can build their own web page without any previous experience.

6. Makes extra profit for you with minimum investment on your part

A website can make residual profit for you, while you are sleeping or enjoying your free time. Thanks to the up-to-date techniques for bringing traffic to your website, you can earn easy money by simply having visitors click on certain product/service promos or links that are relevant to your site content pages (e.g. Google Adsense/Adwords ad solutions) without any initial investment.

7. Makes you a member of the biggest community of the world

A website is a must-have personal attribute nowadays, just like mobile phones and computers are. The fast developing technologies have converted having a website from a whim into a modern necessity. As of today, almost everyone has a web site, whereas twice as many people are expected to be having their own personal space in the global World Wide Web cosmos in the near future. Be forward-thinking, join this trend now.