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

A straightforward interface to connect any .NET application with LinkedIn integration capabilities including People, Profiles, Companies, Groups, Jobs, and more!

Automate LinkedIn Integration Tasks from PowerShell



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 and the CData ADO.NET Provider for LinkedIn for tasks like connecting to LinkedIn data, automating operations, downloading data, and more.

The CData Cmdlets for LinkedIn are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to LinkedIn.

PowerShell Cmdlets or ADO.NET Driver?

The Cmdlets are not only a PowerShell interface to LinkedIn, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete LinkedIn data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for LinkedIn. To access LinkedIn data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for LinkedIn.

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. You will need to obtain the OAuthClientId and OAuthClientSecret by registering an app with LinkedIn. For more information refer to our authentication guide.

PowerShell

  1. Install the module:

    Install-Module LinkedInCmdlets
  2. Connect:

    $linkedin = Connect-LinkedIn -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret" -CallbackURL "$CallbackURL" -CompanyId "$CompanyId"
  3. Search for and retrieve data:

    $entityid = "238" $companystatusupdates = Select-LinkedIn -Connection $linkedin -Table "CompanyStatusUpdates" -Where "EntityId = `'$EntityId`'" $companystatusupdates

    You can also use the Invoke-LinkedIn cmdlet to execute SQL commands:

    $companystatusupdates = Invoke-LinkedIn -Connection $linkedin -Query 'SELECT * FROM CompanyStatusUpdates WHERE EntityId = @EntityId' -Params @{'@EntityId'='238'}

ADO.NET

  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=XXXXXXXInitiateOAuth=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

PowerShell

Update-LinkedIn -Connection $LinkedIn -Columns @('VisibilityCode','Comment') -Values @('MyVisibilityCode', 'MyComment') -Table CompanyStatusUpdates -Id "MyId"

ADO.NET

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

Insert LinkedIn Data

PowerShell

Add-LinkedIn -Connection $LinkedIn -Table CompanyStatusUpdates -Columns @("VisibilityCode", "Comment") -Values @("MyVisibilityCode", "MyComment")

ADO.NET

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

Delete LinkedIn Data

PowerShell

Remove-LinkedIn -Connection $LinkedIn -Table "CompanyStatusUpdates" -Id "MyId"

ADO.NET

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