Exporter vos favoris Firefox en PowerShell
Dans le cadre de ma préparation d’une formation que je vais donner bientôt, j’ai voulu tester la lecture de données issues de bases SQLite. Et pour ça, j’ai fait un test sur le fichier places.sqlite de mon profil Firefox.
Installer l’assembly SQLite
L’assembly SQLite pour le framework .Net est télécharcheagable en version 64 bit. J’ai trouvé l’installation particulièrement longue.
Le code PowerShell
Adaptez votre code selon l’emplacement de votre profil Firefox défini dans $con.ConnectionString. A partir de Windows PowerShell ISE, j’ai tapé le code suivant :
Add-Type -Path 'C:\Program Files\System.Data.SQLite\2015\bin\System.Data.SQLite.dll' $con = New-Object -TypeName System.Data.SQLite.SQLiteConnection $con.ConnectionString = 'Data Source=d:\firefox\profil\places.sqlite' $con.Open() $sql = $con.CreateCommand() $strSql=' SELECT p.url,b.title,ia.content FROM moz_bookmarks AS b INNER JOIN moz_places AS p ON b.fk=p.id INNER JOIN moz_items_annos AS ia ON b.fk=ia.id; ' $sql.CommandText = $strSql $adapter = New-Object -TypeName System.Data.SQLite.SQLiteDataAdapter $sql $data = New-Object System.Data.DataSet [void]$adapter.Fill($data) $data.tables.rows|Export-Csv d:\bookmarks.csv -NoTypeInformation $data.tables.rows|Out-GridView -Title Bookmarks $sql.Dispose() $con.Close()