Automate Instagram Integration Tasks from PowerShell

Ready to get started?

Download for a free trial:

Download Now

Learn more:

Instagram ADO.NET Provider

A straightforward interface to connect any .NET application with Instagram integration capabilities including Users, Relationships, Media, Tags and more!

Are you looking for a quick and easy way to access Instagram data from PowerShell? We show how to use the Cmdlets for Instagram and the CData ADO.NET Provider for Instagram to connect to Instagram data and synchronize, automate, download, and more.

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

Cmdlets or ADO.NET?

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

After obtaining the needed connection properties, accessing Instagram data in PowerShell consists of three basic steps.

Instagram uses the OAuth 2 authentication standard. You will need to obtain the OAuthClientId, OAuthClientSecret, and CallbackURL by registering an app with Instagram. See the help documentation for a guide.


  1. Install the module:

    Install-Module InstagramCmdlets
  2. Connect:

    $instagram = Connect-Instagram -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret" -CallbackURL "$CallbackURL"
  3. Search for and retrieve data:

    $tagname = "goldfish" $media = Select-Instagram -Connection $instagram -Table "Media" -Where "TagName = `'$TagName`'" $media

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

    $media = Invoke-Instagram -Connection $instagram -Query 'SELECT * FROM Media WHERE TagName = @TagName' -Params @{'@TagName'='goldfish'}


  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.Instagram.InstagramConnection("OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;CallbackURL=http://localhost:portNumber;InitiateOAuth=GETANDREFRESH") $conn.Open()
  3. Instantiate the InstagramDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Link, LikesCount from Media" $da= New-Object System.Data.CData.Instagram.InstagramDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $ $_.likescount }

Update Instagram Data


Update-Instagram -Connection $Instagram -Columns @('Link','LikesCount') -Values @('MyLink', 'MyLikesCount') -Table Media -Id "MyId"


$cmd = New-Object System.Data.CData.Instagram.InstagramCommand("UPDATE Media SET TagName='goldfish' WHERE Id = @myId", $conn) $cmd.Parameters.Add(new System.Data.CData.Instagram.InstagramParameter("@myId","10456255-0015501366")) $cmd.ExecuteNonQuery()

Insert Instagram Data


Add-Instagram -Connection $Instagram -Table Media -Columns @("Link", "LikesCount") -Values @("MyLink", "MyLikesCount")


$cmd = New-Object System.Data.CData.Instagram.InstagramCommand("INSERT INTO Media (TagName) VALUES (@myTagName)", $conn) $cmd.Parameters.Add(new System.Data.CData.Instagram.InstagramParameter("@myTagName","goldfish")) $cmd.ExecuteNonQuery()

Delete Instagram Data


Remove-Instagram -Connection $Instagram -Table "Media" -Id "MyId"


$cmd = New-Object System.Data.CData.Instagram.InstagramCommand("DELETE FROM Media WHERE Id=@myId", $conn) $cmd.Parameters.Add(new System.Data.CData.Instagram.InstagramParameter("@myId","001d000000YBRseAAH")) $cmd.ExecuteNonQuery()