Ready to get started?

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

 Download Now

Learn more:

Snapchat Ads Icon Snapchat Ads ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Snapchat Ads.

Automate Snapchat Ads Integration Tasks from PowerShell

Are you in search of a quick and easy way to access Snapchat Ads data from PowerShell? This article demonstrates how to utilize the Snapchat Ads Cmdlets and the CData ADO.NET Provider for Snapchat Ads for tasks like connecting to Snapchat Ads data, automating operations, downloading data, and more.

The CData Cmdlets for Snapchat Ads 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 Snapchat Ads.

PowerShell Cmdlets or ADO.NET Provider?

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

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

You will need to create an OAuth application to connect to Snapchat Ads. See the online Help documentation for an authentication guide.

Additionally, you can optionally set AccountId to provide a default Account ID (meaning it won't need to be manually provided in the WHERE clause). If the AccountId is not specified, the first account in the Accounts view is used.


  1. Install the module:

    Install-Module SnapchatAdsCmdlets
  2. Connect:

    $snapchatads = Connect-SnapchatAds
  3. Search for and retrieve data:

    $id = "123" $campaigns = Select-SnapchatAds -Connection $snapchatads -Table "Campaigns" -Where "Id = `'$Id`'" $campaigns

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

    $campaigns = Invoke-SnapchatAds -Connection $snapchatads -Query 'SELECT * FROM Campaigns WHERE Id = @Id' -Params @{'@Id'='123'}


  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.SnapchatAds.SnapchatAdsConnection("InitiateOAuth=GETANDREFRESH") $conn.Open()
  3. Instantiate the SnapchatAdsDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT AccountId, Name from Campaigns" $da= New-Object System.Data.CData.SnapchatAds.SnapchatAdsDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.accountid $ }

Update Snapchat Ads Data


Update-SnapchatAds -Connection $SnapchatAds -Columns @('AccountId','Name') -Values @('MyAccountId', 'MyName') -Table Campaigns -Id "MyId"


$cmd = New-Object System.Data.CData.SnapchatAds.SnapchatAdsCommand("UPDATE Campaigns SET Id='123' WHERE Id = @myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.SnapchatAds.SnapchatAdsParameter("@myId","10456255-0015501366"))) $cmd.ExecuteNonQuery()

Insert Snapchat Ads Data


Add-SnapchatAds -Connection $SnapchatAds -Table Campaigns -Columns @("AccountId", "Name") -Values @("MyAccountId", "MyName")


$cmd = New-Object System.Data.CData.SnapchatAds.SnapchatAdsCommand("INSERT INTO Campaigns (Id) VALUES (@myId)", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.SnapchatAds.SnapchatAdsParameter("@myId","123"))) $cmd.ExecuteNonQuery()

Delete Snapchat Ads Data


Remove-SnapchatAds -Connection $SnapchatAds -Table "Campaigns" -Id "MyId"


$cmd = New-Object System.Data.CData.SnapchatAds.SnapchatAdsCommand("DELETE FROM Campaigns WHERE Id=@myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.SnapchatAds.SnapchatAdsParameter("@myId","001d000000YBRseAAH"))) $cmd.ExecuteNonQuery()