Automate Snapchat Ads Integration Tasks from PowerShell

Ready to get started?

Download for a free trial:

Download Now

Learn more:

Snapchat Ads ADO.NET Provider

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

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

Cmdlets or ADO.NET?

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

After obtaining the needed connection properties, accessing Snapchat Ads data in PowerShell consists of three basic 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 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 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 System.Data.CData.SnapchatAds.SnapchatAdsParameter("@myId","001d000000YBRseAAH")) $cmd.ExecuteNonQuery()