Discover how a bimodal integration strategy can address the major data management challenges facing your organization today.
Get the Report →Automate Bugzilla Integration Tasks from PowerShell
Are you in search of a quick and easy way to access Bugzilla data from PowerShell? This article demonstrates how to utilize the Bugzilla Cmdlets for tasks like connecting to Bugzilla data, automating operations, downloading data, 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.
PowerShell Cmdlets or ADO.NET Provider?
The Cmdlets are not only a PowerShell interface to Bugzilla, 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.
Once you have acquired the necessary connection properties, accessing Bugzilla data in PowerShell can be enabled in three 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
-
Install the module:
Install-Module BugzillaCmdlets
-
Connect:
$bugzilla = Connect-Bugzilla -Url "$Url" -APIKey "$APIKey"
-
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
-
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Bugzilla\lib\System.Data.CData.Bugzilla.dll")
-
Connect to Bugzilla:
$conn= New-Object System.Data.CData.Bugzilla.BugzillaConnection("Url=http://yourdomain/Bugzilla;APIKey=abc123;") $conn.Open()
-
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 }