Ready to get started?

Learn more about the CData ADO.NET Provider for Bugzilla or download a free trial:

Download Now

Automate Bugzilla Integration Tasks from PowerShell

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

The CData Cmdlets for Bugzilla are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to Bugzilla.

Cmdlets or ADO.NET?

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

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

You can authenticate to your Bugzilla account using two parameters:

  • URL: The URL of your Bugzilla developer's page (the Home page).
  • ApiKey: API Keys can be generated from the Preferences -> API Keys section of your Bugzilla developer's page.

PowerShell

  1. Install the module:

    Install-Module BugzillaCmdlets
  2. Connect:

    $bugzilla = Connect-Bugzilla -Url "$Url" -APIKey "$APIKey"
  3. Search for and retrieve data:

    $creator = "user@domain.com" $bugs = Select-Bugzilla -Connection $bugzilla -Table "Bugs" -Where "Creator = `'$Creator`'" $bugs

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

    $bugs = Invoke-Bugzilla -Connection $bugzilla -Query 'SELECT * FROM Bugs WHERE Creator = @Creator' -Params @{'@Creator'='user@domain.com'}

ADO.NET

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.Bugzilla.BugzillaConnection("Url=http://yourdomain/Bugzilla;APIKey=abc123;") $conn.Open()
  3. Instantiate the BugzillaDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Id, Summary from Bugs" $da= New-Object System.Data.CData.Bugzilla.BugzillaDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.id $_.summary }