Ready to get started?

Learn more about the CData ADO.NET Provider for LinkedIn or download a free trial:

Download Now

Automate LinkedIn Integration Tasks from PowerShell

Are you looking for a quick and easy way to access LinkedIn data from PowerShell? We show how to use the Cmdlets for LinkedIn and the CData ADO.NET Provider for LinkedIn to connect to LinkedIn data and synchronize, automate, download, 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.

Cmdlets or ADO.NET?

The cmdlets are not only a PowerShell interface to the LinkedIn API, 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.

After obtaining the needed connection properties, accessing LinkedIn data in PowerShell consists of three basic 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()