Topics


Blogs


Forums


Samples


Media


Labs


Resources

 




DevCentral > Weblogs > Joe Pruitt - A Software Architect's take on Network Security

Unix2PowerShell

There are 16 entries for the tag Unix2PowerShell

Unix To PowerShell - Md5

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. md5 The Unix “md5” command (aliased to “openssl dgst –md5” or “md5sum”) calculates and verifies 128-bit MD5 hashes as described in RFC 1321.  The MD5 hash (or checksum) functions as a compact digital fingerprint of a file.  It is extremely unlikely that any two non-identical files existing in the...


posted @ Monday, May 18, 2009 8:08 AM | Feedback (3)

Unix To PowerShell - Touch

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. touch The Unix “touch” command is used to change a file’s access and modification timestamps.  It can also be used to create a new empty file. The options to the Unix touch command are implemented with the following PowerShell parameters: ...


posted @ Thursday, May 07, 2009 10:09 AM | Feedback (2)

Unix To PowerShell – Cut

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. cut The Unix “cut” command is used to extract sections from each link of input.  Extraction of line segments can be done by bytes, characters, or fields separated by a delimiter.  A range must be provided in each case which consists of one of N, N-M, N- (N to...


posted @ Wednesday, May 06, 2009 9:48 AM | Feedback (17)

Unix To PowerShell - Basename

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. basename The Unix “basename” command will delete any prefix up to the last slash (‘/’) character and return the result.  For my PowerShell implementation, I’ve switched the slash path separator character with the Windows backslash (‘\’) path separator.  PowerShell does have the Split-Path cmdlet that...


posted @ Monday, May 04, 2009 9:30 AM | Feedback (2)

Unix To PowerShell - Cat

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. cat The Unix “cat” command is used to concatenate and display files.   Given a file or filename list, it will print the contents of that file to standard output.  There are several options in the Unix command that are implemented with the following PowerShell arguments: ...


posted @ Friday, May 01, 2009 9:00 AM | Feedback (2)

Unix To PowerShell - Dirname

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. dirname The Unix “dirname” command will strip any non-directory suffix from a file name.  Given a NAME, dirname will print the name with it’s trailing “/” component removed.  If NAME contains no “/” characters, it will output “.” (meaning the current directory). Since PowerShell is run on windows,...


posted @ Thursday, April 30, 2009 10:07 AM | Feedback (5)

Unix To PowerShell - Find

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. find The Unix “find” command searches through one or more directory trees of a file system, locating files based on some user specific criteria.  By default, find returns all files below the current working directory.  It also allows you to perform an action to be taken on each matched...


posted @ Wednesday, April 29, 2009 11:44 AM | Feedback (2)

Unix To PowerShell – Factor

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. factor The Unix “factor” command will print out the Prime Factors of each number.  Factors are numbers, when multiplied together, give the original number.  Prime Factors are factors that are Prime Numbers (numbers that can be divided evenly only by one and itself). The algorithm the Unix command...


posted @ Monday, April 27, 2009 7:53 AM | Feedback (8)

Unix To PowerShell - Seq

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. seq The Unix “seq” command prints a sequence of numbers from FIRST to LAST, in steps of INCREMENT. The PowerShell “range” operator “..” will return an array of numbers but it does not give you the ability to modify the increment from 1 (or –1 if the LAST...


posted @ Friday, April 24, 2009 11:37 AM | Feedback (4)

Unix To PowerShell – Tac

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. tac The Unix “tac” command will allow you to see a file line-by-line backwards.  It will print each record in reverse order.  Records are separated by instances of a string (newline being the default).  The “-s” option allows you to change the newline to be any other string you...


posted @ Thursday, April 23, 2009 8:23 AM | Feedback (1)

Unix To PowerShell - Tail

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. tail The Unix “tail” command that is used to display the last 10 lines of each FILE to standard output.  With more than one file, precede each with a header giving the file name.  There is also a mode where it prints out the last “n” bytes in a...


posted @ Wednesday, April 22, 2009 1:38 PM | Feedback (1)

Unix To PowerShell - Fold

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. fold The Unix “fold” command will take as input a list of files and wrap each input line to fit within a specified width.  By default, fold breaks lines wider than 80 columns and the output is split into as many lines as necessary. I’ve included the following...


posted @ Monday, April 20, 2009 11:56 AM | Feedback (1)

Unix To PowerShell - Nl

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. nl The Unix “nl” (number lines) command will take as input a list of files and, for each file, it will write the file to standard output with line numbers added.  There are a lot of options in the unix command and I’ve included the following: ...


posted @ Thursday, April 16, 2009 9:38 AM | Feedback (0)

Unix To PowerShell - Wc

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. wc The Unix “wc” (word count) command will print the character, word, and newline counts for each file specified and a total line if more than one file is specified.  This command is useful for quickly scanning a directory for small and large files or to quickly look at...


posted @ Wednesday, April 15, 2009 9:05 AM | Feedback (3)

Unix To PowerShell – Head

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. head 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...


posted @ Tuesday, April 14, 2009 9:52 AM | Feedback (1)

Unix To PowerShell - Which

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. which For this post, I’m going to tackle the Unix “which” command.  With the which command, you specify a file specification (ie notepad.exe, cs.*, etc) and it will scan your defined lookup paths in your environment for a file matching that specification.  Years and years ago I wrote a...


posted @ Friday, April 10, 2009 3:38 PM | Feedback (2)