Category Archives: PowerShell

Powershell scripts, snippets and nuggets of knowledge.

Automic Introspective REST Agent + Small life update

Hi folks,

Long time no post! I believe the last thing I posted was some sort of Craigslist apartment-scanning script I was using to sort through flats in NYC. Though I was offered the job, I ended up turning it down for a couple of reasons:

1. Though it would have paid well more than enough to cover the COLA difference, NYC is wicked pricey and honestly I think I’m a bit scared of big city living.

2. I had a more interesting competing offer.

Late last year I accepted an offer to be an automation consultant through a consultancy that services Automic, Chef, and Cloudbees technologies. I’ve been sent around the USA and Europe so far and have had the opportunity to work on great things for great companies, with great people! I am proud to say I’ve had a direct hand in creating the CAOS framework used by Nordea (Danish Bank)  and have automated the software build/deployment pipeline for a number of other companies.

Anyhoo, something I have realized is that Automic’s ARA product, while quite feature rich, is missing something… a REST API! So I prototyped one in PowerShell. Here’s a demo:

4,064 total views, 1 views today

PowerShell + Craigslist for advanced apartment hunting

I was very, very tired of copying/pasting a template saying “Hi I’m Rex and I’m thinking about moving to NYC because of a job offer.. no pets, no kids, no wife, etc” to each place I found appealing. I decided to scrape craigslist and build PowerShell objects that I could sort and use to automagically spam my potential new roommates! 🙂

Here’s the script that’ll do the scraping and build an array of objects:

And here’s what a sample object looks like, though you could probably guess by the object declaration:
Sample object

Playing with data is fun, right?
Sample list of objects

There’s a ton that COULD be done with this, I’m only scratching the surface! 🙂

———————————- UPDATE ———————————-

I’ve semi-wrapped it in a function for ease of use:

Using Find-Apartment

14,007 total views, 1 views today

OCR with Powershell

I wrote a little function that utilizes Microsoft Office Document Imaging (MODI) to retrieve text from images with OCR.

I have put a few notes in-line in the script and have dummy-proofed it somewhat, but ymmv! Below the snippet I’ll show an example where I compare 12pt font recognition with this technique.

Here’s an example:

Image Get-TextFromImage Output
OCR Test Image Windows Powershell NODI OCR Test Image
l2pt COURIER NEW ABCDEFGHIJKLMNOPORSTUVLJXYZ
abcdefghijklmnopqrstuvwxyz
01234567890 

12 pt TAHOMA
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
0123456789

12 pt TERMINAL
ABCDEFCH I JICLMNOPQRSTUUIIXYZ
abc de f gh ii Ic inn o pqrs t tw wxyz
0123456789

12 pt VERDANA
ABCD EFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
0123456789

12 pt CONSOLAS
ABCDE FCHIJ KL KNOPQRSTUVHXYZ
abcdefghij kirnnopqrst uvwxyz
0123456789

12 pt Times New Roman
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklnmopqrstuvwxyz
0123456739

] pt OCR?A Extended ABCDEFGHI JKL1NOPQRSTUVLdXYZ
abcde fghij kimnopqrstuvwxy z
O]3456789

The OCR-specific font failed miserably. Funny huh?

It appears that at 12pt in a jpg, Times New Roman is the best candidate for OCR using MODI via Powershell if you intend on having accurate results!

Relevant links:
http://stackoverflow.com/questions/316068/what-is-the-ideal-font-for-ocr
http://cerealnumber.livejournal.com/47638.html
http://stackoverflow.com/questions/9277571/how-can-i-retrieve-modi-reference-from-com-in-my-application

15,645 total views, 4 views today

Get-OpenfileIDs

Something I’m twiddling with… you could also use the “openfiles.exe” command, which supports wildcarding IDs. Dunno where this snippet would be totally useful.

1,803 total views, no views today