Powershell on the Way to Work–Part 3


Hey!  Glad to see you again.   I took the bus today.   Gives me a little more relaxing time to clear my brain.  It’s nice not to be stuck on the HIghway today.

We were playing with getting some basic help on a Powershell Cmdlet.  As we said, most of them are pretty good as they provide examples.

Let’s take a look at one of the simpler Cmdlets called “GET-CONTENT”. 

So who here would like to place bets on what “GET-CONTENT” does?  Anybody?  Anybody?  Bueller?  Bueller?

Let’s find out.

GET-HELP GET-CONTENT –Examples

image

If you look at some of the presented examples you should be quick to pick up that “GET-CONTENT” will GET the CONTENT of a file.  It will Get the Content of any file you specify just like TYPE did.  For example if you were to key in

GET-CONTENT C:\FOO\Somefile.txt

It would output to the screen the content of “Somefile.txt” located in the C:\FOO folder (whether that content may contain legible data is another issue of course)

Unlike TYPE in DOS we have newer features like “Tail” which can view the “Tail end” of the text file.    This line will show me the last 5 lines of a Text file called “Booga.txt” in C:\Stuff folder

GET-CONTENT C:\Stuff\Booga.txt –tail 5

Now here’s a neat trick, try using “TYPE” in Powershell

TYPE C:\Stuff\Boogs.txt

Isn’t that interesting?  It still seems to work.  That's because Powershell offers us a feature called “Aliases” to use other words or short forms to call up the same Cmdlets.

We’ll talk about Aliases a little later on and how you can use them.  Right now my bus has just gotten to it’s stop.

Chat soon!

DSC_0158 (640x425)_thumb

Sean Kearney
Twitter: @energizedtech
www.powershell.ca

Comments (0)

Skip to main content