Automate LinkedIn Integration Tasks from PowerShell

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Are you in search of a quick and easy way to access LinkedIn data from PowerShell? This article demonstrates how to utilize the LinkedIn Cmdlets for tasks like connecting to LinkedIn data, automating operations, downloading data, and more.

The CData ADO.NET Provider for LinkedIn is a standard ADO.NET Provider that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to LinkedIn.

ADO.NET Provider

The ADO.NET Provider provides a SQL interface for LinkedIn; this tutorial shows how to use the Provider to create, retrieve, update, and delete LinkedIn data.

Once you have acquired the necessary connection properties, accessing LinkedIn data in PowerShell can be enabled in three steps.

LinkedIn uses the OAuth 2 authentication standard. Obtain the OAuthClientId and OAuthClientSecret by registering an app with LinkedIn. For more information refer to our authentication guide.

  1. Load the provider's assembly:

    
    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for LinkedIn\lib\System.Data.CData.LinkedIn.dll")
        
  2. Connect to LinkedIn:

     
    $conn= New-Object System.Data.CData.LinkedIn.LinkedInConnection("OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;CallbackURL=http://localhost:portNumber;CompanyId=XXXXXXX;InitiateOAuth=GETANDREFRESH;")
    $conn.Open()
    
  3. Instantiate the LinkedInDataAdapter, execute an SQL query, and output the results:

    
    $sql="SELECT VisibilityCode, Comment from CompanyStatusUpdates"
    
    $da= New-Object System.Data.CData.LinkedIn.LinkedInDataAdapter($sql, $conn)
    $dt= New-Object System.Data.DataTable
    $da.Fill($dt)
    
    $dt.Rows | foreach {
    	Write-Host $_.visibilitycode $_.comment
    }
      

Update LinkedIn Data


$cmd =  New-Object System.Data.CData.LinkedIn.LinkedInCommand("UPDATE CompanyStatusUpdates SET EntityId='238' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.LinkedIn.LinkedInParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()

Insert LinkedIn Data


$cmd =  New-Object System.Data.CData.LinkedIn.LinkedInCommand("INSERT INTO CompanyStatusUpdates (EntityId) VALUES (@myEntityId)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.LinkedIn.LinkedInParameter("@myEntityId","238")))
$cmd.ExecuteNonQuery()

Delete LinkedIn Data


$cmd =  New-Object System.Data.CData.LinkedIn.LinkedInCommand("DELETE FROM CompanyStatusUpdates WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.LinkedIn.LinkedInParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()

Ready to get started?

Download a free trial of the LinkedIn Data Provider to get started:

 Download Now

Learn more:

LinkedIn Icon LinkedIn ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with LinkedIn data including People, Profile, Companies, Groups, Jobs, and more!