PowerShell_unix PowerShell is definitely gaining momentum in the windows scripting world but I still hear folks wanting to rely on unix based tools to get their job done.  In this series of posts I’m going to look at converting some of the more popular Unix based tools to PowerShell.


The Unix head command will print the first 10 lines of each file to standard output.  With more than one file, it will precede each with a header giving the file name.  This command is useful when you just want to quickly scan the first few lines of a collection of files.  PowerShell has the equivalent Get-Content Cmdlet but it only allows you to specify the first “n” lines, it does not include support for querying the first “n” bytes like the unix “head” command does.  So, I’ve added some code around the Get-Content cmdlet to allow for querying the first “n” number of bytes as well.