PowerShell for *nix people

PowerShell is becoming (has become) the replacement for VBScript on Microsoft operating systems. It is a fairly robust scripting language that I think most administrators will be happy to see.

If you have a supported Microsoft operating system (i.e., not Windows XP) at your disposal, you will find it is already installed.

Below is a simple example to get you started. This simply finds all files in a given directory tree and prints the name.

PS C:\Users\showard> Get-ChildItem C:\users\showard\downloads *.txt -recurse | Foreach-Object {echo $_.FullName}
C:\users\showard\downloads\20131015_cmh.txt
C:\users\showard\downloads\20131016_cmh.txt
C:\users\showard\downloads\20131017_cmh.txt
C:\users\showard\downloads\20131018_cmh.txt



C:\users\showard\downloads\second_hang.txt
PS C:\Users\showard> $_.FullName

The example below will get registered network information for a given URL…

PS C:\Users\showard> for ($i = 1; $i -le 4; $i++)
>> {[System.Net.Dns]::GetHostAddresses("cmh-dev$i-www.express.com")}
>>


Address           : 819007584
AddressFamily     : InterNetwork
ScopeId           :
IsIPv6Multicast   : False
IsIPv6LinkLocal   : False
IsIPv6SiteLocal   : False
IPAddressToString : 96.16.209.48

Address           : 819007584
AddressFamily     : InterNetwork
ScopeId           :
IsIPv6Multicast   : False
IsIPv6LinkLocal   : False
IsIPv6SiteLocal   : False
IPAddressToString : 96.16.209.48

Address           : 819007584
AddressFamily     : InterNetwork
ScopeId           :
IsIPv6Multicast   : False
IsIPv6LinkLocal   : False
IsIPv6SiteLocal   : False
IPAddressToString : 96.16.209.48

Address           : 819007584
AddressFamily     : InterNetwork
ScopeId           :
IsIPv6Multicast   : False
IsIPv6LinkLocal   : False
IsIPv6SiteLocal   : False
IPAddressToString : 96.16.209.48



PS C:\Users\showard>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.