Last active
January 23, 2025 23:40
-
-
Save TiloGit/eed089c56aa1aa07d060d46294b0cbdc to your computer and use it in GitHub Desktop.
Read IBM FileNet GCD from Database as XML script
This file contains hidden or 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
$SQLServer = "mysqlserver1232.westus2.cloudapp.azure.com" | |
$SQLDBName = "ABC_FNGCD" | |
$uid ="sa" | |
$pwd = "my-db-pass123" | |
##modify below query if you want specific GCD version | |
$SqlQuery = "select gcd_blob FROM FNGCD WHERE epoch_id = (select last_epoch_id from FNGCD where epoch_id = 0);" | |
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection | |
$SqlConnection.ConnectionString = "Server = $SQLServer; Database = $SQLDBName; User ID = $uid; Password = $pwd;" | |
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand | |
$SqlCmd.CommandText = $SqlQuery | |
$SqlCmd.Connection = $SqlConnection | |
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter | |
$SqlAdapter.SelectCommand = $SqlCmd | |
$DataSet = New-Object System.Data.DataSet | |
$SqlAdapter.Fill($DataSet) | |
$DataSet.Tables | |
$instream = [System.IO.MemoryStream]::new($DataSet.Tables.gcd_blob) | |
$zlib = [System.IO.Compression.ZLibStream]::new( | |
$instream, | |
[System.IO.Compression.CompressionMode]::Decompress) | |
$outstream = [System.IO.MemoryStream]::new() | |
$zlib.CopyTo($outstream) | |
$zlib.Dispose() | |
# Choose encoding here | |
$enc = [System.Text.Encoding]::UTF8 | |
##out to console | |
$enc.GetString($outstream.ToArray()) | |
##out to XML file | |
$enc.GetString($outstream.ToArray()) | out-file my-gcd.xml -encoding utf8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pretty print output XML file, see here: https://gist.github.com/TiloGit/3c2d49d09696c7054d3f76c78c341b1b