Archive for April, 2012

Video: Brandon Shell – Module Design for IT Pro

Here’s another great recording from previous PowerShell Deep Dive – Brandon‘s session on module design. Brandon has experience designing PowerShell modules for Splunk and other companies – so there’s a lot to learn from him!

In this session we will deep dive into the thought process behind production module design. The presenter will explain the reason for choices made for the Splunk Module and his own BSonPosh module.

This is a live recording from European TEC 2011 PowerShell Deep Dive conference. See more PowerShell Deep Dive recordings here.

By the way, TEC US is just around the corner – April 29 – May 2, 2012 in San DiegoThe agenda has already been published and is absolutely fantastic.

Register now – this is the best PowerShell event you can find!

Advertisements

Parsing LinkedIn html pages with PowerShell

A couple of weeks ago we posted a job opening on LinkedIn (were looking for a person to be in charge of our Jelastic‘s professional services), and it turned out that while LinkedIn jobs attract a lot of applications, the site itself does not make it easy to process them afterwards. You get CVs in email, and they also post a list of applicants with email addresses, phone numbers, titles, etc. – but there is no way to export the list to, say, Excel. In our case, we really wanted to have the data exported, so we could jointly work on a shared spreadsheet and everyone involved could grade each applicant and add notes to the table.

Being a PowerShell guy, I wrote the script below that does the scraping for me. 🙂 Basically, I just saved the page with the list of applicants to my local disk and found that in their html, each applicant information is contained in vcard element, which has class name with LinkedIn URL and the actual name, and then elements with email and phone number:

So all my script has to do is: create an IE object and then use it to find the corresponding fields, then create custom objects from them, add them to the collection, and export it to CSV. Here’s the code – hope it helps you solve similar tasks when other sites do not provide good export capabilities:

$ie = new-object -com "InternetExplorer.Application"

# The easiest way to accomodate for slowness of IE
Start-Sleep -Seconds 1

$ie.Navigate("D:\Temp\LinkedIn.htm")

# The easiest way to accomodate for slowness of IE
Start-Sleep -Seconds 1

$doc = $ie.Document

# Get a collection of vcard elements
$cards = $doc.body.getElementsByClassName("vcard")

# This will be our collection of parsed objects
$processesCards = @()

# Iterate through the collection
for ($i=0; $i -lt $cards.length; $i++) {

 $itm = $cards.item($i)

 # Get the 'name' element that has the applicant name and URL
 $name = $itm.getElementsByClassName("name").item(0).
                       getElementsByTagName("a").item(0)

 # If you want you can output the name to the screen 
 # so you know where you are
 $name.outerText

 # Get the phone number and email address
 $phone = $itm.getElementsByClassName("phone").item(0)
 $email = `
   $itm.getElementsByClassName("trk-applicant-email").item(0)

 # Below is PowerShell v3 notation. 
 # In v2, replace '[pscustomobject]' with 
 # 'new-object psobject -Property' 
 $obj = [pscustomobject] @{"name"=$name.outerText; 
                           "url"=$name.href; 
                           "email"=$email.outerText; 
                           "phone"= $phone.outerText }

 $processesCards += $obj

}

# Export to CSV - which you can open in Excel
$processesCards | Export-Csv D:\Temp\linkedin.csv 

Video: Aleksandar Nikolic – Delegation with Remoting

Here’s recording of @alexandair – PowerShell MVP, constrained runspaces guru and editor of PowerShell Magazine – talking about delegation in PowerShell remoting. I bet not that many of you tried this feature before – so check out this talk that Aleksandar did at the last PowerShell Deep Dive in Frankfurt!

In this session you will learn how to set up a fan-in PowerShell endpoint, and then use it to assign specific administrative tasks to the appropriate users and groups without changing the membership of local Administrators group. By using just the IIS configuration files and PowerShell scripts we will enable dynamic creation of customized automation environments.

This is a live recording from European TEC 2011 PowerShell Deep Dive conference. See more PowerShell Deep Dive recordings here.

By the way, TEC US is just around the corner – April 29 – May 2, 2012 in San DiegoThe agenda has already been published and is absolutely fantastic.

Register now – this is the best PowerShell event you can find!

Video: Jeffery Hicks – Turn Command-Line Tools into PowerShell Tools

Here’s recording of @jeffhicks – PowerShell MVP, book author and trainer – Jeffery Hicks – talking at the previous PowerShell Deep Dive about how you can turn existing command-line utilities into PowerShell functions so they can become first-class (object emitting ;)) PowerShell citizens.

You can find Jeff’s slides and demo scripts here.

The abstract and video recording are below:

PowerShell is everywhere but there are still many command line tools in the IT Pro’s toolbox, In this session we’ll look at how to turn just about any command line based tool into a PowerShell tool so that you can incorporate it into your PowerShell scripts and daily management tasks. The power of objects in the pipeline is amazing and there’s no reason not to include tools like NETSTAT.EXE or NBTSTAT.EXE. 
1. The Challenge of CLI Tools 
2. Console Text to PowerShell Objects Techniques 
3. Putting It All Together

This is a live recording from European TEC 2011 PowerShell Deep Dive conference. See more PowerShell Deep Dive recordings here.

By the way, TEC US is just around the corner – April 29 – May 2, 2012 in San DiegoThe agenda has already been published and is absolutely fantastic.

Register now – this is the best PowerShell event you can find!

Video: Richard Siddaway – PowerShell Events

See @rsiddaway / Richard Siddaway (PowerShell MVP and the founder of UK PowerShell usergroup) giving a great overview of PowerShell eventing in this recording from last year’s PowerShell Deep Dive.

Windows is an event driven system. PowerShell is the automation engine for the Microsoft platform. Version 2.0 introduced the ability to work with system events. Many system events do not require action on our part. There are some events that we really need to be aware of and act upon. Gaining access to these events has not been an easy task for the administrator — up until now. 

PowerShell can work with events generated by: 
WMI 
.NET 
• The PowerShell engine 

Between them they give a handle into the inner workings of your system. A customizable, generic approach to handling events will be presented that enables you to perform actions based on the events detected. Events don’t just provide an insight into what’s happening. We can use them to trigger system actions for us — a self-healing system anyone 

The key take aways from this session will be: 
• The PowerShell event engine enables you to interact at a closer level with your system 
• The consumption and processing of events can be as simple or complicated as you require 
• You can use events to teach your system to react a fix things on its own 

This is a live recording from European TEC 2011 PowerShell Deep Dive conference. See more PowerShell Deep Dive recordings here.

By the way, TEC US is just around the corner – April 29 – May 2, 2012 in San DiegoThe agenda has already been published and is absolutely fantastic. :)

Register now – this is the best PowerShell event you can find!


My Recent Tweets

Legal

The posts on this blog are provided “as is” with no warranties and confer no rights. The opinions expressed on this site are mine and mine alone, and do not necessarily represent those of my employer - WSO2 or anyone else for that matter. All trademarks acknowledged.

© 2007-2014 Dmitry Sotnikov

April 2012
M T W T F S S
« Mar   Aug »
 1
2345678
9101112131415
16171819202122
23242526272829
30  

%d bloggers like this: