![]() |
VOOZH | about |
The CData Cmdlets for LinkedIn Ads are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to LinkedIn Ads.
The Cmdlets are not only a PowerShell interface to LinkedIn Ads, but also an SQL interface; this tutorial shows how to use both to retrieve LinkedIn Ads data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for LinkedIn Ads. To access LinkedIn Ads data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for LinkedIn Ads.
Once you have acquired the necessary connection properties, accessing LinkedIn Ads data in PowerShell can be enabled in three steps.
LinkedIn Ads uses the OAuth authentication standard. OAuth requires the authenticating user to interact with LinkedIn using the browser. See the OAuth section in the Help documentation for a guide.
Install the module:
Install-Module LinkedInAdsCmdlets
Connect:
$linkedinads = Connect-LinkedInAds -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret" -CallbackURL "$CallbackURL" -InitiateOAuth "$InitiateOAuth"
Search for and retrieve data:
$entityid = "238" $analytics = Select-LinkedInAds -Connection $linkedinads -Table "Analytics" -Where "EntityId = `'$EntityId`'" $analytics
You can also use the Invoke-LinkedInAds cmdlet to execute SQL commands:
$analytics = Invoke-LinkedInAds -Connection $linkedinads -Query 'SELECT * FROM Analytics WHERE EntityId = @EntityId' -Params @{'@EntityId'='238'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for LinkedIn Ads\lib\System.Data.CData.LinkedInAds.dll")
Connect to LinkedIn Ads:
$conn= New-Object System.Data.CData.LinkedInAds.LinkedInAdsConnection("OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;CallbackURL=http://localhost:portNumber;InitiateOAuth=GETANDREFRESH;")
$conn.Open()
Instantiate the LinkedInAdsDataAdapter, execute an SQL query, and output the results:
$sql="SELECT VisibilityCode, Comment from Analytics"
$da= New-Object System.Data.CData.LinkedInAds.LinkedInAdsDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.visibilitycode $_.comment
}
Download a free trial of the LinkedIn Ads Data Provider to get started:
Download NowLearn more:
👁 LinkedIn Ads IconRapidly create and deploy powerful .NET applications that integrate with LinkedIn Ads.