Created
February 17, 2025 23:39
-
-
Save milnak/02bd5a7356a29ed37dabab9137215908 to your computer and use it in GitHub Desktop.
Dump Sqlite Table using PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$SqliteAssembly = Resolve-Path -LiteralPath '~\scoop\apps\scoop\current\supporting\sqlite\System.Data.SQLite.dll' | |
$DbPath = Resolve-Path -LiteralPath '~\AppData\Roaming\Code\User\globalStorage\state.vscdb' | |
if (!('System.Data.SQLite.SQLiteConnection' -as [Type])) { | |
Add-Type -Path $SqliteAssembly | |
} | |
$connection = New-Object -TypeName 'Data.SQLite.SQLiteConnection' | |
$connection.ConnectionString = "Data Source=$DbPath" | |
$connection.Open() | |
$command = $connection.CreateCommand() | |
$command.CommandText = @" | |
SELECT json_extract(value, '$.entries') | |
AS entries | |
FROM ItemTable | |
WHERE key = 'history.recentlyOpenedPathsList' | |
"@ | |
$command.CommandType = [Data.CommandType]::Text | |
$reader = $command.ExecuteReader() | |
# Colnames: $reader.GetValues() | |
while ($reader.HasRows) { | |
if ($reader.Read()) { | |
$reader['entries'] | |
} | |
} | |
$reader.Close() | |
$command.Dispose() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment