Capturing Text using RegEx in Powershell

Regular expressions go all the way back to 1956. I think I first saw them in the PERL language; but today in 2015, they are very useful in Powershell, C# and most every language. Regular Expressions have three main purposes: 1. Validate if text conforms to a pattern 2. Capture (extract) a string (or series […]

Intro to Oracle for SQLServer Developers and DBAs – Part 2

Intro to Oracle for SQLServer Developers and DBAs 1. Oracle has something called V$ tables, which are essential similar to the Dynamic Management View (DMV) of SQLServer, Here are two examples: select * from v$database; select * from v$thread; Result – this shows that my 11g Express Edition has both an instance name of “xe” […]

Intro to Oracle SQL for SQL Server Developers and DBAs – Part 1

Intro to Oracle SQL for SQL Server Developers and DBAs This is an Intro to Oracle SQL for SQLServer Developers and DBAs, and probably Part 1 of several blogs that I will write as I learn more, and make  more newbie mistakes.  You probably already know that Microsoft implementation (or extension) of the “standard” SQL […]

How to Add and Delete MSMQ Queues from Powershell

This blog shows you how to How to Add and Delete MSMQ Queues from Powershell, programmatically, via a simple re-usable function. I used the code from this blog as a base: http://blogs.msdn.com/b/sajay/archive/2010/03/18/powershell-script-to-create-an-msmq.aspx. His code is fine, but it’s from an administrators perspective, i.e. run this Powershell, pass it some parms. I wanted the same code […]

Powershell – How to get last line of file (and parse it from CSV)

How to Get the Last Line of a File Have you ever needed to read just the last line of a file (i.e. “the last row”) in Powershell? It’s easier than I thought. If you ask for the last several rows (as shown in the commented-out code in the example below, you will get back […]

Base64 Encode/Decode Functions for Powershell

I found the base code for this here: http://vstepic.blogspot.com/2013/02/how-to-convert-string-to-base64-and.html. If you want to know more about Base64, check out this Wikipedia Entry But I’m not a command-line guy, I’m a developer, and I like to have my code in a file where I can edit it, modify it, re-use it, and run it. Function Base64Encode($textIn) […]

Logging Data Variables to a CSV File in Powershell

Powershell has the Add-Content cmdlet to append data to the end of a file. While it also has Export-CSV cmdlet, that seems to be more for dealing with collections where you pipe a collection of objects directly to the CSV (Comma Separated Value) file. What if you have several variables and you want to put […]

Intro/Overview to an EDI X12 850 Purchase Order

The following example is available in the BizTalk SDK, and represents an 850 “Purchase Order Document”,  We will be describing some how to read this EDI data in this blog.


ISA*00*          *00*          *ZZ*THEM           *ZZ*US             *991221*1226*U*00401*000000025*0*T*>
GS*PO*THEM*US*19991221*1226*1*X*004010
ST*850*0001
BEG*00*NE*3859199838**950727***IBM
PER*AA*Andrew Carlson*TE*(708) 555-2930
DTM*002*970523
PO1*1*93*BX*145.39**CB*KOW-20392-10
PID*F****Uninterruptible Power System
PER*AA*Camilla Anderson*TE*(708) 555-2011
PO1*2*25*EA*35.68**CB*1093-4927-001
PID*F****High Volume Printer Stand
PER*AA*Miranda Cappelan*TE*(708) 555-1111
PO1*3*4*PC*2002.91**CB*ABX-2001
PID*F****Electronics Cabinet Package (56" High)
CTT*3
SE*14*0001
GE*1*1
IEA*1*000000025
After installing BizTalk, this file can be found here: “c:\Program Files (x86)\Microsoft BizTalk Server 2010\SDK\EDI Interface Developer Tutorial\ProcessEDI_TestLocations\SamplePO.txt”. It is part of the SDK […]

Why isn’t .Contains() working in Powershell?

I’m building a little app that is driven by an XML configuration file. I need to substitute variables from the XML with a random name or a keyword from another source, so I used $Keyword and $MaleName and $FemaleName. Look at this code, and see if you can spot the bug. Every single text field […]

Read MSMQ from Powershell

<pre> [Reflection.Assembly]::LoadWithPartialName("System.Messaging") cls $queueName = '.\Private$\NealTest' $queue = new-object System.Messaging.MessageQueue $queueName $utf8  = new-object System.Text.UTF8Encoding $msgs = $queue.GetAllMessages() write-host "Number of messages=$($msgs.Length)" foreach ($msg in $msgs)   {       write-host $msg_.Id       write-host $utf8.GetString($msg.BodyStream.ToArray())   } </pre> Depending on how many times you wrote messages to the queue, the output will look something like this: