![]() |
VOOZH | about |
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.
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. Obtain the OAuthClientId and OAuthClientSecret by registering an app with LinkedIn. For more information refer to our authentication guide.
Install the module:
Install-Module LinkedInCmdlets
Connect:
$linkedin = Connect-LinkedIn -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret" -CallbackURL "$CallbackURL" -CompanyId "$CompanyId" -InitiateOAuth "$InitiateOAuth"
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'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for LinkedIn\lib\System.Data.CData.LinkedIn.dll")
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()
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 -Connection $LinkedIn -Columns @('VisibilityCode','Comment') -Values @('MyVisibilityCode', 'MyComment') -Table CompanyStatusUpdates -Id "MyId"
$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()
Add-LinkedIn -Connection $LinkedIn -Table CompanyStatusUpdates -Columns @("VisibilityCode", "Comment") -Values @("MyVisibilityCode", "MyComment")
$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()
Remove-LinkedIn -Connection $LinkedIn -Table "CompanyStatusUpdates" -Id "MyId"
$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()
CodeProject
Download a free trial of the LinkedIn Data Provider to get started:
Download NowLearn more:
👁 LinkedIn IconA straightforward interface to connect any .NET application with LinkedIn integration capabilities including People, Profiles, Companies, Groups, Jobs, and more!