bin/SnsSqlitePsModule.dll-Help.xml
<?xml version="1.0" encoding="utf-8"?>
<helpItems schema="maml" xmlns="http://msh"> <!-- Cmdlet: New-SnsSqliteConnection --> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name>New-SnsSqliteConnection</command:name> <command:verb>New</command:verb> <command:noun>SnsSqliteConnection</command:noun> <maml:description> <maml:para>Initializes And Reverts A SQLiteConnection Object.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>Initializes And Reverts A SQLiteConnection Object.</maml:para> <maml:para>If The Specified DataBase Doesn't Exist, The CmdLet Throw A Warning And Creates The DataBase. When This Happen And ReadOnly Mode Is Requested, The CmdLet Will Ignore Users Input And Will Establish The Connection To The Newly Created DataBase In Read Write Mode. If Read Only Connections To Multiple DataBases Are Needed And Only One Of Those DataBases Doesn't Exist, Only That Connection Will Be In Read Write Mode And The Remaining Will Be In Read Only Mode.</maml:para> <maml:para>By Default The CmdLet Establish The Connection To The Specified DataBase With Opening Of A Session, However Using Open Parameter It Can Create The SQLiteConnection Object Without Opening Of Session.</maml:para> </maml:description> <command:syntax> <!-- Parameter set: __AllParameterSets --> <command:syntaxItem> <maml:name>New-SnsSqliteConnection</maml:name> <!-- Parameter: DataBase --> <command:parameter required="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="named" aliases="DataBaseFile,Path,DataSource"> <maml:name>DataBase</maml:name> <maml:description> <maml:para>Specifies SQLite DataBase File To Connect To.</maml:para> <maml:para>In Case DataBase Doesn't Exist The CmdLet Creates It And Generates Warning.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Paths.</maml:para> </maml:description> <command:parameterValue required="true">string[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> </command:parameter> <!-- Parameter: Open --> <command:parameter required="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named"> <maml:name>Open</maml:name> <maml:description> <maml:para>Specifies To Open The SQL Connection.</maml:para> <maml:para>Connection Is Opened By Default. Used To Create A Connection Without Opening It.</maml:para> </maml:description> <command:parameterValue required="true">SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>True</dev:defaultValue> </command:parameter> <!-- Parameter: ReadOnly --> <command:parameter required="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named"> <maml:name>ReadOnly</maml:name> <maml:description> <maml:para>Specifies To Open The DataBase In ReadOnly Mode.</maml:para> </maml:description> <command:parameterValue required="true">SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <!-- Parameter: DataBase --> <command:parameter required="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="named" aliases="DataBaseFile,Path,DataSource"> <maml:name>DataBase</maml:name> <maml:description> <maml:para>Specifies SQLite DataBase File To Connect To.</maml:para> <maml:para>In Case DataBase Doesn't Exist The CmdLet Creates It And Generates Warning.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Paths.</maml:para> </maml:description> <command:parameterValue required="true">string[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> </command:parameter> <command:parameter required="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="named" aliases="DataBaseFile,Path,DataSource"> <maml:name>DataBaseFile</maml:name> <maml:description> <maml:para>Specifies SQLite DataBase File To Connect To.</maml:para> <maml:para>In Case DataBase Doesn't Exist The CmdLet Creates It And Generates Warning.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Paths.</maml:para> <maml:para>This is an alias of the DataBase parameter.</maml:para> </maml:description> <command:parameterValue required="true">string[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> </command:parameter> <command:parameter required="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="named" aliases="DataBaseFile,Path,DataSource"> <maml:name>Path</maml:name> <maml:description> <maml:para>Specifies SQLite DataBase File To Connect To.</maml:para> <maml:para>In Case DataBase Doesn't Exist The CmdLet Creates It And Generates Warning.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Paths.</maml:para> <maml:para>This is an alias of the DataBase parameter.</maml:para> </maml:description> <command:parameterValue required="true">string[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> </command:parameter> <command:parameter required="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="named" aliases="DataBaseFile,Path,DataSource"> <maml:name>DataSource</maml:name> <maml:description> <maml:para>Specifies SQLite DataBase File To Connect To.</maml:para> <maml:para>In Case DataBase Doesn't Exist The CmdLet Creates It And Generates Warning.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Paths.</maml:para> <maml:para>This is an alias of the DataBase parameter.</maml:para> </maml:description> <command:parameterValue required="true">string[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> </command:parameter> <!-- Parameter: ReadOnly --> <command:parameter required="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named"> <maml:name>ReadOnly</maml:name> <maml:description> <maml:para>Specifies To Open The DataBase In ReadOnly Mode.</maml:para> </maml:description> <command:parameterValue required="true">SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <!-- Parameter: Open --> <command:parameter required="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named"> <maml:name>Open</maml:name> <maml:description> <maml:para>Specifies To Open The SQL Connection.</maml:para> <maml:para>Connection Is Opened By Default. Used To Create A Connection Without Opening It.</maml:para> </maml:description> <command:parameterValue required="true">SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>True</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <maml:description> <maml:para>Specifies SQLite DataBase File To Connect To.</maml:para> <maml:para>In Case DataBase Doesn't Exist The CmdLet Creates It And Generates Warning.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Paths.</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <maml:description> <maml:para>Specifies To Open The DataBase In ReadOnly Mode.</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <maml:description> <maml:para>Specifies To Open The SQL Connection.</maml:para> <maml:para>Connection Is Opened By Default. Used To Create A Connection Without Opening It.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <!-- OutputType: SQLiteConnection --> <command:returnValue> <dev:type> <maml:name>System.Data.SQLite.SQLiteConnection</maml:name> <maml:uri /> </dev:type> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:title></maml:title> <maml:alert> <maml:para>AUTHOR: Svetoslav Nedyalkov Savov</maml:para> <maml:para>THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK</maml:para> <maml:para>OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>---------- EXAMPLE 1 ----------</maml:title> <dev:code>[System.Data.SQLite.SQLiteConnection]$objConn = New-SnsSqliteConnection -DataBase "C:\TempDB\temp.sqlite" ` -Open:$false;</dev:code> <dev:remarks> <maml:para></maml:para> <maml:para>Creates Connection To A DataBase Located In The Specified Folder Without Opening Of The Session.</maml:para> <maml:para>If The DataBase File Doesn't Exist In The Specified Folder, Creates The DataBase. Then Creates Connection To The DataBase Without Opening Of The Session.</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- EXAMPLE 2 ----------</maml:title> <dev:code>[System.Data.SQLite.SQLiteConnection]$objConn = New-SnsSqliteConnection -DataBase "temp.sqlite";</dev:code> <dev:remarks> <maml:para></maml:para> <maml:para>Creates And Opens A Connection To A DataBase Located In The Working Folder.</maml:para> <maml:para>If The DataBase File Doesn't Exist In The Current Working Folder, Creates It. Then Creates And Opens A Connection To The DataBase.</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- EXAMPLE 3 ----------</maml:title> <dev:code>$objProdConn, $objBackupConn = New-SnsSqliteConnection -DataBase "temp.sqlite", "Backup.sqlite" -ReadOnly;</dev:code> <dev:remarks> <maml:para></maml:para> <maml:para>Creates And Opens A Connection To "temp.sqlite" DataBase Located In The Working Folder In ReadOnly Mode. For The Purpose Of The Example It Needs To Be Existing DataBase File With Data Inside.</maml:para> <maml:para>For The Purpose Of The Example DataBase "Backup.sqlite" Is Not Existing DataBase. In That Case DataBase "Backup.sqlite" Is Created, And Because It Is New DataBase The Output Connection Object Is In "Modify" Mode.</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para>$objProdConn.BackupDatabase($objBackupConn, "main", "main", -1, $null, 0);</maml:para> <maml:para></maml:para> <maml:para>Backups All The Data From Production DataBase To The Backup One. This Way With Two Lines Of Code We Can Create New DataBase And Copy/Backup All The Data From An Existing To The New DataBase.</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <maml:relatedLinks> <maml:navigationLink> <maml:linkText> svesavov / SnsSqlitePsModule - </maml:linkText> <maml:uri>https://github.com/svesavov/SnsSqlitePsModule</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> PowerShell Gallery - </maml:linkText> <maml:uri>https://www.powershellgallery.com/packages/SnsSqlitePsModule/</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> Svetoslav Savov on LinkedIn - </maml:linkText> <maml:uri>https://www.linkedin.com/in/svetoslavsavov</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> RamblingCookieMonster / PSSQLite - </maml:linkText> <maml:uri>https://github.com/RamblingCookieMonster/PSSQLite</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite V3 - </maml:linkText> <maml:uri>https://sqlite.org/index.html</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite V3 Data Types - </maml:linkText> <maml:uri>https://www.sqlite.org/datatype3.html</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite V3 Supported SQL Syntax - </maml:linkText> <maml:uri>https://www.sqlite.org/lang.html</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite V3 Pragma Statements - </maml:linkText> <maml:uri>http://www.sqlite.org/pragma.html</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite V3 Tutorials - </maml:linkText> <maml:uri>https://www.sqlitetutorial.net/</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite Studio - </maml:linkText> <maml:uri>https://github.com/pawelsalawa/sqlitestudio/releases</maml:uri> </maml:navigationLink> </maml:relatedLinks> </command:command> <!-- Cmdlet: Backup-SnsSqliteDataBase --> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name>Backup-SnsSqliteDataBase</command:name> <command:verb>Backup</command:verb> <command:noun>SnsSqliteDataBase</command:noun> <maml:description> <maml:para>Connects To A Specified SQLite DataBase Called Source DataBase Or Source For Short, Creates Another SQLite DataBase Called Destination Or Backup For Short, Connects To Destination DataBase And Copy The Whole Content From The Source Into The Destination DataBase.</maml:para> </maml:description> </command:details> <maml:description> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para>Connects To A Specified SQLite DataBase Called Source DataBase Or Source For Short, Creates Another SQLite DataBase Called Destination Or Backup For Short, Connects To Destination DataBase And Copy The Whole Content From The Source Into The Destination DataBase.</maml:para> <maml:para>Since The DataBase Backup Is Relatively Simple Process Initially I Had No Intention To Create Such CmdLet At All. However It Turned Out That It Requires Handling Of Multiple Exceptions. So This CmdLet Was Developed To Prevent The Exceptions Managing Over And Over Again.</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para>Before The Actual Backup The CmdLet Verifies The Source DataBase Existence And Whether Successful Writable (Not Read Only) Connection Can Be Established. Afterward The CmdLet Verifies The Backup File Existence, In Case It Exists Is Thrown Termination Error. In Case Force Switch Parameter Is Used The CmdLet Will Try To Delete The Destination DataBase File. Then New Blank Destination DataBase Is Created And It Is Verified Whether Writable Connection Can Be Established. In Case Both Connections Are Opened Successfully The CmdLet Performs Backup.</maml:para> <maml:para>Whenever The Destination DataBase Is Not Specified, The CmdLet Will Create The Backup DataBase In The Same Folder As The Source DataBase With Name The Same As The Source Prefixed With Digits Representing The Current UTC Date And Time.</maml:para> <maml:para>Whenever For Destination Is Specified A Folder, And That Folder Is Not The Folder Where The Source DataBase Is Located, The CmdLet Will Place The Backup DataBase Into The Specified Folder With Name Matching The Source DataBase Name.</maml:para> <maml:para>Whenever For Destination Is Specified Filename, The CmdLet Will Create The Backup DataBase With The Specified Name And Will Place It In The Current Working Folder.</maml:para> <maml:para>Whenever For Destination Is Specified Full Absolute File Path The Destination DataBase Will Be Created With The Specified Name In The Specified Location.</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </maml:description> <command:syntax> <!-- Parameter set: __AllParameterSets --> <command:syntaxItem> <maml:name>Backup-SnsSqliteDataBase</maml:name> <!-- Parameter: DataBase --> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="DataBaseFile,Path,DataSource"> <maml:name>DataBase</maml:name> <maml:description> <maml:para>Specifies SQLite DataBase File To Be Backed Up.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Path.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <!-- Parameter: Destination --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named"> <maml:name>Destination</maml:name> <maml:description> <maml:para>Specifies The Backup File Or The Backup Folder.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Path.</maml:para> <maml:para>If Not Provided The CmdLet Will Generate One Based On UTC Time And Source DataBase.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <!-- Parameter: Force --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named"> <maml:name>Force</maml:name> <maml:description> <maml:para>Specifies To Delete The Destination File Upfront If It Already Exists.</maml:para> </maml:description> <command:parameterValue required="true">SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <!-- Parameter: PassThru --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named"> <maml:name>PassThru</maml:name> <maml:description> <maml:para>Specifies To Revert Output.</maml:para> <maml:para>If Backup DataBase Size In Bytes Equals Source DataBase Will Revert The Backup FilePath.</maml:para> <maml:para>If Backup DataBase Size In Bytes Not Equals Source DataBase Will String "Backup Failed".</maml:para> </maml:description> <command:parameterValue required="true">SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <!-- Parameter: DataBase --> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="DataBaseFile,Path,DataSource"> <maml:name>DataBase</maml:name> <maml:description> <maml:para>Specifies SQLite DataBase File To Be Backed Up.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Path.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="DataBaseFile,Path,DataSource"> <maml:name>DataBaseFile</maml:name> <maml:description> <maml:para>Specifies SQLite DataBase File To Be Backed Up.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Path.</maml:para> <maml:para>This is an alias of the DataBase parameter.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="DataBaseFile,Path,DataSource"> <maml:name>Path</maml:name> <maml:description> <maml:para>Specifies SQLite DataBase File To Be Backed Up.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Path.</maml:para> <maml:para>This is an alias of the DataBase parameter.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="DataBaseFile,Path,DataSource"> <maml:name>DataSource</maml:name> <maml:description> <maml:para>Specifies SQLite DataBase File To Be Backed Up.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Path.</maml:para> <maml:para>This is an alias of the DataBase parameter.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <!-- Parameter: Destination --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named"> <maml:name>Destination</maml:name> <maml:description> <maml:para>Specifies The Backup File Or The Backup Folder.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Path.</maml:para> <maml:para>If Not Provided The CmdLet Will Generate One Based On UTC Time And Source DataBase.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <!-- Parameter: Force --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named"> <maml:name>Force</maml:name> <maml:description> <maml:para>Specifies To Delete The Destination File Upfront If It Already Exists.</maml:para> </maml:description> <command:parameterValue required="true">SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <!-- Parameter: PassThru --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named"> <maml:name>PassThru</maml:name> <maml:description> <maml:para>Specifies To Revert Output.</maml:para> <maml:para>If Backup DataBase Size In Bytes Equals Source DataBase Will Revert The Backup FilePath.</maml:para> <maml:para>If Backup DataBase Size In Bytes Not Equals Source DataBase Will String "Backup Failed".</maml:para> </maml:description> <command:parameterValue required="true">SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes /> <command:returnValues> <!-- OutputType: String --> <command:returnValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:title></maml:title> <maml:alert> <maml:para>AUTHOR: Svetoslav Nedyalkov Savov</maml:para> <maml:para>THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK</maml:para> <maml:para>OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>---------- EXAMPLE 1 ----------</maml:title> <dev:code>Backup-SnsSqliteDataBase -DataBase "temp.db";</dev:code> <dev:remarks> <maml:para></maml:para> <maml:para>Backups DataBase "temp.db" Into A New DataBase Located In The Current Folder With The Same Name Prefixed With Digits Representing Current UTC Date And Time.</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- EXAMPLE 2 ----------</maml:title> <dev:code>Backup-SnsSqliteDataBase -DataBase "temp.db" -Destination "C:\Backups";</dev:code> <dev:remarks> <maml:para></maml:para> <maml:para>Backups DataBase "temp.db" Into "C:\Backup\temp.db".</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- EXAMPLE 3 ----------</maml:title> <dev:code>Backup-SnsSqliteDataBase -DataBase "temp.db" -Destination "backup.db";</dev:code> <dev:remarks> <maml:para></maml:para> <maml:para>Backups DataBase "temp.db" Into "backup.db" Both Located In The Current Working Folder.</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- EXAMPLE 4 ----------</maml:title> <dev:code>Backup-SnsSqliteDataBase -DataBase "temp.db" -Destination "C:\Backups\backup.db";</dev:code> <dev:remarks> <maml:para></maml:para> <maml:para>Backups DataBase "temp.db" Into "C:\Backups\backup.db".</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <maml:relatedLinks> <maml:navigationLink> <maml:linkText> svesavov / SnsSqlitePsModule - </maml:linkText> <maml:uri>https://github.com/svesavov/SnsSqlitePsModule</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> PowerShell Gallery - </maml:linkText> <maml:uri>https://www.powershellgallery.com/packages/SnsSqlitePsModule/</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> Svetoslav Savov on LinkedIn - </maml:linkText> <maml:uri>https://www.linkedin.com/in/svetoslavsavov</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> RamblingCookieMonster / PSSQLite - </maml:linkText> <maml:uri>https://github.com/RamblingCookieMonster/PSSQLite</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite V3 - </maml:linkText> <maml:uri>https://sqlite.org/index.html</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite V3 Data Types - </maml:linkText> <maml:uri>https://www.sqlite.org/datatype3.html</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite V3 Supported SQL Syntax - </maml:linkText> <maml:uri>https://www.sqlite.org/lang.html</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite V3 Pragma Statements - </maml:linkText> <maml:uri>http://www.sqlite.org/pragma.html</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite V3 Tutorials - </maml:linkText> <maml:uri>https://www.sqlitetutorial.net/</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite Studio - </maml:linkText> <maml:uri>https://github.com/pawelsalawa/sqlitestudio/releases</maml:uri> </maml:navigationLink> </maml:relatedLinks> </command:command> <!-- Cmdlet: Invoke-SnsSqliteObjectInsert --> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name>Invoke-SnsSqliteObjectInsert</command:name> <command:verb>Invoke</command:verb> <command:noun>SnsSqliteObjectInsert</command:noun> <maml:description> <maml:para>Imports Collection Of Object Into Specified Table Within Specified SQLite DataBase.</maml:para> </maml:description> </command:details> <maml:description> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para>Imports Collection Of Object Into Specified Table Within Specified SQLite DataBase.</maml:para> <maml:para>This CmdLet Does Allow Users Without Or With Limited Knowledge About SQL Query Language To Work With DataBases. The CmdLet Creates The SQL Query And The SQL Parameters On Its Own. The User Has No Need Even To Know What SQL Injection Is And How To Avoid It.</maml:para> <maml:para>There Are Cases When We Have Large Collections Of Similar Objects That Corresponds Exactly To Specific Table In A DataBase And We Need To Insert Them At Once Taking The Advantage Of The SQL Transactions. This CmdLet Is Made Exactly For Those Cases. Like For Example We Need To Insert The Information About All Users In The Environment Into A DataBase Table Named Users. Then We Simply Query The Active Directory About All Users And Pipeline The Output To This CmdLet.</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para>The CmdLet Have Two ParameterSets Which Represent The Allowed Combination Of Input Parameters.</maml:para> <maml:para>Those ParameterSets Allows Either DataBase File To Be Specified Along With Parameters Used To Establish A Connection To It, Or To Be Specified SQLiteConnection Object Associated With An Existing Connection. The CmdLet Performs SQL INSERT Queries Therefore ReadOnly SQLConnection Is Not Allowed.</maml:para> <maml:para>The Specified Input Is Verified Either At The Parameters Section Or Within The Begin Method. Some Of The Input Is Verified Several Times With Various Verifications, As For Example The Table Name Is Verified Once Whether It Contains Non Alphanumeric Characters And Second Time Whether It Exists Inside The Specified DataBase. The CmdLet Can Handle INSERT Queries Only In Existing Data Sources With Existing Tables, Unlike The Rest Of The CmdLets Within This PowerShell Module Which Normally Would Create The Missing DataBase.</maml:para> <maml:para>The CmdLet Establishes SQL Connection At The Beginning Method And Query The DataBase About A List With The Existing Tables. In Case The Specified Table Exists It Query The DataBase Second Time About Tables Schema. The Retrieved Table Schema Is Used For The SQL Query Auto Initialization And The Enumeration Of The SQL Parameter Names.</maml:para> <maml:para>Because There Are Lot Faster Built Into SQLite Ways For Bulk Insert Data Within A Table, This CmdLet Most Likely Will Be Used In Automations Running On A Schedule.</maml:para> <maml:para>Whenever Initial Or One Time Data INSERT Is Required I Recommend The Manual Approach Using The Official SQLite Tools CLI https://www.sqlite.org/download.html Or SQLite Studio https://github.com/pawelsalawa/sqlitestudio/releases. Manual Approach Allows Greater Visibility. Using Graphical Interface For One Time Actions Is Always Better.</maml:para> <maml:para>To Avoid SQL Injection Issues The CmdLet Converts Each Of The Provided InputObjects To SQL Parameters And Auto Enumerates The SQL Query And Its SQL Variables From The Enumerated Table Columns. This Introduces Additional Requirements:</maml:para> <maml:para>- The Column Names In The Destination Table Must Contain Only Lower And Capital English Letters, Digits And Underscore (_) Character.</maml:para> <maml:para>- The Input Objects Property Names Must Match Exactly The Destination Table Column Names.</maml:para> <maml:para>- The Types Of The Values Inside The Input Objects Properties Must Match Exactly The Corresponding Destination Table Column Data Types.</maml:para> <maml:para>- The Values Inside The Input Objects Properties Must Be Normalized In Advance.</maml:para> <maml:para></maml:para> <maml:para>- Whenever The Input Objects Have Properties Not Present In The Destination Table Schema, Their Values Will Be Ignored.</maml:para> <maml:para>- Whenever The Input Objects Have No Properties Present In The Destination Table Schema, The CmdLet Will Insert NULL In The Corresponding Columns. This Might Lead To SQL Errors Whenever Those Columns Have NOT NULL Constraint.</maml:para> <maml:para>Whenever Those Requirements Cannot Be Met The User Still Can Use Invoke-SnsSqliteQuery For Bulk Operations Which Does Provide More Control Over The Process But Requires More In-Depth SQL Query Language Knowledge.</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para>To Simplify The Dates Managing The Module Offers Predefined Formatting Strings To Convert DateTime Object To Understandable For SQLite Format. Although The CmdLet Will Process SQL Parameters Date Values Without Being Converted Upfront To Strings.</maml:para> <maml:para>Leaving The DateTime Objects To Be Automatically Managed Might Lead To Unexpected Results Related With The DateTime Syntax Coming From The Regional Settings On The Machine, Daylight Saving Related And TimeZone Related Issues. From That Perspective I Would Recommend The Dates To Be Normalized To Long Integer And To Be Stored In Numeric Columns.</maml:para> <maml:para>[System.DateTime]::Now.ToFileTime() - Gets The System DateTime And Converts It To Long Integer.</maml:para> <maml:para>[System.DateTime]::FromFileTime(108666144000000000) - Converts The Long Integer To Local DateTime With Time Zone And Daylight Saving Taken Into Consideration.</maml:para> <maml:para>[System.DateTime]::FromFileTimeUtc(108666144000000000) - Converts The Long Integer To Universal DateTime. (Guess What Is The Date From The Example).</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </maml:description> <command:syntax> <!-- Parameter set: Db --> <command:syntaxItem> <maml:name>Invoke-SnsSqliteObjectInsert</maml:name> <!-- Parameter: DataBase --> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="DataBaseFile,Path,DataSource"> <maml:name>DataBase</maml:name> <maml:description> <maml:para>Specifies SQLite DataBase File To Connect To.</maml:para> <maml:para>The DataBase Must Exists, The CmdLet Won't Create It.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Paths.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <!-- Parameter: InputObject --> <command:parameter required="true" globbing="false" pipelineInput="true (ByValue)" position="named"> <maml:name>InputObject</maml:name> <maml:description> <maml:para>Specifies A Collection Of Input Objects To Be Inserted Into The DataBase Table.</maml:para> <maml:para>Input Object Properties Must Be Struct Or String.</maml:para> <maml:para>Input Object Properties Must Not Be Collections Or Other Classes.</maml:para> </maml:description> <command:parameterValue required="true">PSObject[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject[]</maml:name> <maml:uri /> </dev:type> </command:parameter> <!-- Parameter: Table --> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="DataBaseTable"> <maml:name>Table</maml:name> <maml:description> <maml:para>Specifies A Table Where The Data Will Be Inserted.</maml:para> <maml:para>The Table Must Exist Inside The Specified DataBase, The CmdLet Won't Create It.</maml:para> <maml:para>Allowed Characters In The Table Name Are: From a To z, From A To Z And _</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <!-- Parameter: ConflictClause --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named"> <maml:name>ConflictClause</maml:name> <maml:description> <maml:para>Specifies A Conflict Clause To Use In Case A Conflict Occurs During Insert.</maml:para> <maml:para>See https://www.sqlite.org/lang_conflict.html for more details.</maml:para> <maml:para>Accepted Values: "Rollback", "Abort", "Fail", "Ignore" And "Replace"</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <!-- Parameter: QueryTimeout --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named" aliases="TimeOut"> <maml:name>QueryTimeout</maml:name> <maml:description> <maml:para>Specifies The Number Of Seconds Before The Query Times Out.</maml:para> </maml:description> <command:parameterValue required="true">int</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>0</dev:defaultValue> </command:parameter> </command:syntaxItem> <!-- Parameter set: Conn --> <command:syntaxItem> <maml:name>Invoke-SnsSqliteObjectInsert</maml:name> <!-- Parameter: Connection --> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="SQLiteConnection"> <maml:name>Connection</maml:name> <maml:description> <maml:para>Specifies Existing SQLite Connection.</maml:para> <maml:para>In Case The Connection Is Not Open Or Expired The CmdLet Opens It.</maml:para> </maml:description> <command:parameterValue required="true">SQLiteConnection</command:parameterValue> <dev:type> <maml:name>System.Data.SQLite.SQLiteConnection</maml:name> <maml:uri /> </dev:type> </command:parameter> <!-- Parameter: InputObject --> <command:parameter required="true" globbing="false" pipelineInput="true (ByValue)" position="named"> <maml:name>InputObject</maml:name> <maml:description> <maml:para>Specifies A Collection Of Input Objects To Be Inserted Into The DataBase Table.</maml:para> <maml:para>Input Object Properties Must Be Struct Or String.</maml:para> <maml:para>Input Object Properties Must Not Be Collections Or Other Classes.</maml:para> </maml:description> <command:parameterValue required="true">PSObject[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject[]</maml:name> <maml:uri /> </dev:type> </command:parameter> <!-- Parameter: Table --> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="DataBaseTable"> <maml:name>Table</maml:name> <maml:description> <maml:para>Specifies A Table Where The Data Will Be Inserted.</maml:para> <maml:para>The Table Must Exist Inside The Specified DataBase, The CmdLet Won't Create It.</maml:para> <maml:para>Allowed Characters In The Table Name Are: From a To z, From A To Z And _</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <!-- Parameter: ConflictClause --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named"> <maml:name>ConflictClause</maml:name> <maml:description> <maml:para>Specifies A Conflict Clause To Use In Case A Conflict Occurs During Insert.</maml:para> <maml:para>See https://www.sqlite.org/lang_conflict.html for more details.</maml:para> <maml:para>Accepted Values: "Rollback", "Abort", "Fail", "Ignore" And "Replace"</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <!-- Parameter: QueryTimeout --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named" aliases="TimeOut"> <maml:name>QueryTimeout</maml:name> <maml:description> <maml:para>Specifies The Number Of Seconds Before The Query Times Out.</maml:para> </maml:description> <command:parameterValue required="true">int</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>0</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <!-- Parameter: DataBase --> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="DataBaseFile,Path,DataSource"> <maml:name>DataBase</maml:name> <maml:description> <maml:para>Specifies SQLite DataBase File To Connect To.</maml:para> <maml:para>The DataBase Must Exists, The CmdLet Won't Create It.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Paths.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="DataBaseFile,Path,DataSource"> <maml:name>DataBaseFile</maml:name> <maml:description> <maml:para>Specifies SQLite DataBase File To Connect To.</maml:para> <maml:para>The DataBase Must Exists, The CmdLet Won't Create It.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Paths.</maml:para> <maml:para>This is an alias of the DataBase parameter.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="DataBaseFile,Path,DataSource"> <maml:name>Path</maml:name> <maml:description> <maml:para>Specifies SQLite DataBase File To Connect To.</maml:para> <maml:para>The DataBase Must Exists, The CmdLet Won't Create It.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Paths.</maml:para> <maml:para>This is an alias of the DataBase parameter.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="DataBaseFile,Path,DataSource"> <maml:name>DataSource</maml:name> <maml:description> <maml:para>Specifies SQLite DataBase File To Connect To.</maml:para> <maml:para>The DataBase Must Exists, The CmdLet Won't Create It.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Paths.</maml:para> <maml:para>This is an alias of the DataBase parameter.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <!-- Parameter: Connection --> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="SQLiteConnection"> <maml:name>Connection</maml:name> <maml:description> <maml:para>Specifies Existing SQLite Connection.</maml:para> <maml:para>In Case The Connection Is Not Open Or Expired The CmdLet Opens It.</maml:para> </maml:description> <command:parameterValue required="true">SQLiteConnection</command:parameterValue> <dev:type> <maml:name>System.Data.SQLite.SQLiteConnection</maml:name> <maml:uri /> </dev:type> </command:parameter> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="SQLiteConnection"> <maml:name>SQLiteConnection</maml:name> <maml:description> <maml:para>Specifies Existing SQLite Connection.</maml:para> <maml:para>In Case The Connection Is Not Open Or Expired The CmdLet Opens It.</maml:para> <maml:para>This is an alias of the Connection parameter.</maml:para> </maml:description> <command:parameterValue required="true">SQLiteConnection</command:parameterValue> <dev:type> <maml:name>System.Data.SQLite.SQLiteConnection</maml:name> <maml:uri /> </dev:type> </command:parameter> <!-- Parameter: Table --> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="DataBaseTable"> <maml:name>Table</maml:name> <maml:description> <maml:para>Specifies A Table Where The Data Will Be Inserted.</maml:para> <maml:para>The Table Must Exist Inside The Specified DataBase, The CmdLet Won't Create It.</maml:para> <maml:para>Allowed Characters In The Table Name Are: From a To z, From A To Z And _</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="DataBaseTable"> <maml:name>DataBaseTable</maml:name> <maml:description> <maml:para>Specifies A Table Where The Data Will Be Inserted.</maml:para> <maml:para>The Table Must Exist Inside The Specified DataBase, The CmdLet Won't Create It.</maml:para> <maml:para>Allowed Characters In The Table Name Are: From a To z, From A To Z And _</maml:para> <maml:para>This is an alias of the Table parameter.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <!-- Parameter: InputObject --> <command:parameter required="true" globbing="false" pipelineInput="true (ByValue)" position="named"> <maml:name>InputObject</maml:name> <maml:description> <maml:para>Specifies A Collection Of Input Objects To Be Inserted Into The DataBase Table.</maml:para> <maml:para>Input Object Properties Must Be Struct Or String.</maml:para> <maml:para>Input Object Properties Must Not Be Collections Or Other Classes.</maml:para> </maml:description> <command:parameterValue required="true">PSObject[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject[]</maml:name> <maml:uri /> </dev:type> </command:parameter> <!-- Parameter: ConflictClause --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named"> <maml:name>ConflictClause</maml:name> <maml:description> <maml:para>Specifies A Conflict Clause To Use In Case A Conflict Occurs During Insert.</maml:para> <maml:para>See https://www.sqlite.org/lang_conflict.html for more details.</maml:para> <maml:para>Accepted Values: "Rollback", "Abort", "Fail", "Ignore" And "Replace"</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <!-- Parameter: QueryTimeout --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named" aliases="TimeOut"> <maml:name>QueryTimeout</maml:name> <maml:description> <maml:para>Specifies The Number Of Seconds Before The Query Times Out.</maml:para> </maml:description> <command:parameterValue required="true">int</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>0</dev:defaultValue> </command:parameter> <command:parameter required="false" globbing="false" pipelineInput="false" position="named" aliases="TimeOut"> <maml:name>TimeOut</maml:name> <maml:description> <maml:para>Specifies The Number Of Seconds Before The Query Times Out.</maml:para> <maml:para>This is an alias of the QueryTimeout parameter.</maml:para> </maml:description> <command:parameterValue required="true">int</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>0</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject[]</maml:name> <maml:uri /> </dev:type> <maml:description> <maml:para>Specifies A Collection Of Input Objects To Be Inserted Into The DataBase Table.</maml:para> <maml:para>Input Object Properties Must Be Struct Or String.</maml:para> <maml:para>Input Object Properties Must Not Be Collections Or Other Classes.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues /> <maml:alertSet> <maml:title></maml:title> <maml:alert> <maml:para>AUTHOR: Svetoslav Nedyalkov Savov</maml:para> <maml:para>THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK</maml:para> <maml:para>OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>---------- EXAMPLE 1 ----------</maml:title> <dev:code>Invoke-SnsSqliteObjectInsert -DataBase "C:\temp.sqlite" -Table "MyTable" -InputObject $arrInputy;</dev:code> <dev:remarks> <maml:para></maml:para> <maml:para>Converts The Specified InputObjects Collection To SQL Parameters And Insert The Data Into MyTable.</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- EXAMPLE 2 ----------</maml:title> <dev:code>$arrInput | Invoke-SnsSqliteObjectInsert -DataBase "C:\temp.sqlite" -Table "MyTable" -ConflictClause Replace;</dev:code> <dev:remarks> <maml:para></maml:para> <maml:para>Converts The Pipelined InputObjects Collection To SQL Parameters And Insert The Data Into MyTable.</maml:para> <maml:para></maml:para> <maml:para>In Case An Input Object Conflicts With Existing Entry, The Old One Will Be Replaced With The Data From The Input Object.</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <maml:relatedLinks> <maml:navigationLink> <maml:linkText> svesavov / SnsSqlitePsModule - </maml:linkText> <maml:uri>https://github.com/svesavov/SnsSqlitePsModule</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> PowerShell Gallery - </maml:linkText> <maml:uri>https://www.powershellgallery.com/packages/SnsSqlitePsModule/</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> Svetoslav Savov on LinkedIn - </maml:linkText> <maml:uri>https://www.linkedin.com/in/svetoslavsavov</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> RamblingCookieMonster / PSSQLite - </maml:linkText> <maml:uri>https://github.com/RamblingCookieMonster/PSSQLite</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite V3 - </maml:linkText> <maml:uri>https://sqlite.org/index.html</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite V3 Data Types - </maml:linkText> <maml:uri>https://www.sqlite.org/datatype3.html</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite V3 Supported SQL Syntax - </maml:linkText> <maml:uri>https://www.sqlite.org/lang.html</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite V3 Pragma Statements - </maml:linkText> <maml:uri>http://www.sqlite.org/pragma.html</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite V3 Tutorials - </maml:linkText> <maml:uri>https://www.sqlitetutorial.net/</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite Studio - </maml:linkText> <maml:uri>https://github.com/pawelsalawa/sqlitestudio/releases</maml:uri> </maml:navigationLink> </maml:relatedLinks> </command:command> <!-- Cmdlet: Invoke-SnsSqliteQuery --> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name>Invoke-SnsSqliteQuery</command:name> <command:verb>Invoke</command:verb> <command:noun>SnsSqliteQuery</command:noun> <maml:description> <maml:para>Connects To A Specified SQLite DataBase, Executes SQL Query / Queries Against The DataBase, Reverts The Output In A Collection Of Specified DataType And Closes The SQL Session.</maml:para> </maml:description> </command:details> <maml:description> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para>Connects To A Specified SQLite DataBase, Executes SQL Query / Queries Against The DataBase, Reverts The Output In A Collection Of Specified DataType And Closes The SQL Session.</maml:para> <maml:para>The CmdLet Is Based On Warren Frame's (RamblingCookieMonster) And His Contributors Project Named "PSSQLite". More Details Can Be Found In The Links In The Link Section Below.</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para>Like The Original CmdLet The Input Is Validated At The Beginning Within The Parameter Definitions. For That Purpose Custom Validation Attributes Were Developed, Since "[ValidateScript({})]" Validation Attribute Is Not Supported In C#.</maml:para> <maml:para>The CmdLet Is Capable To Connect To The Specified SQLite DataBase / DataSource By Itself. There Is No Requirement SQLiteConnection To Be Established In Advance. In The Begin Method The CmdLet Evaluate The Provided Input And In Case DataBase Is Provided, The CmdLet Verifies The DataBase File Existence And If Needed Creates The DataBase File. For Some Reason Automatic DataBase File Creation Does Not Work In C#. Whenever A New DataBase Is Created, The User Is Notified With A Warning Message.</maml:para> <maml:para>The Connection Is Established Once In The Begin Method. All The Specified Queries Are Sent In The Process Method. Therefore All The Queries Are Sent Over A Single Already Created And Verified Connection.</maml:para> <maml:para>The CmdLet Will Execute All The Specified SQL Queries Or Single Query With Multiple Parameters Using A SQL Transaction. Because The Transaction Have To Be Started Before The First Query And The Queries Can Be Provided Via The Pipeline, The CmdLet Will Evaluate Only The First Provided Query. This Might Lead To Unexpected Behavior Whenever The First Provided Query Allows Transactions Usage And The Consequent Once Do Not. Then The SQLite Will Throw Errors And The Whole Transaction Will Be Reverted Even Though The First Queries Are Successful. The CmdLet Will Auto Create A Transaction When:</maml:para> <maml:para>-- The Specified SQL Connection Is Not ReadOnly.</maml:para> <maml:para>-- ReadOnly Parameter Of The CmdLet Is Not Specified Or It Is Explicitly Specified FALSE.</maml:para> <maml:para>-- The First SQL Query Contains Neither "VACUUM" Nor "PRAGMA" Nor "COMMIT". "VACUUM" And "PRAGMA" Cannot Be Used In Transactions. Attempting To Do So Will Throw SQLite Error. "COMMIT" Keyword Is Used In The SQL Language To Commit Previously Created Transaction. In That Case It Is Assumed That The User Manages The Transactions By Himself Within The SQL Query And New Transaction Is Not Auto Created.</maml:para> <maml:para>-- The First Query Contains Either "INSERT" Or "UPDATE" Statements. If We Nod Modify The Data Within The DataBase We In Fact Do Not Need DataBase Locks And Transaction Will Provide No Benefits, Rather Downsides Because It Prevents Other Clients To Modify That Data At That Time.</maml:para> <maml:para>Whenever The Specified DataBase Doesn't Exist And ReadOnly Parameter Value Is TRUE, The CmdLet Will Override The Users Input And The DataBase Will Be Created And Opened In Write Mode.</maml:para> <maml:para>Whenever The SQL Query Which Needs To Be Run Against The DataBase Is Too Complex Can Be Used SQL Query Input File. The CmdLet Does Allow Usage Of SQL Query File With Standard ".SQL" Extension With Specifying Of SQL Parameters As HashTable, However It Does Not Support Usage Of Multiple ".SQL" Files At Once. It Still Can Be Used To Import Single SQL Query And Using Of Collection Of SQL Parameter Dictionaries To Insert Multiple Rows At Once. The ".SQL" File Read Happens In Begin Method, Which Exclude The Possibility To Execute Multiple SQL Queries At Once. I Don't Want File Operations In Process Method Because Of Performance Considerations.</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para>The CmdLet Have Four ParameterSets Which Represent The Allowed Combination Of Input Parameters.</maml:para> <maml:para>The CmdLet Parameters And Pipeline Were Redesigned, Because For Me Makes More Sense To Use The Pipeline For Sending SQL Queries And SQL Parameters Rather Than Sending DataBase Sources. In My Automation Scripts I Mostly Use Multiple Queries And Parameters Run Against Single DataBase Rather Than Simultaneously Run The Same Query With The Same Parameters Against Multiple DataBases. If I Ever Need High Availability On My Automations Would Prefer To Schedule Them To Run On A Virtual Machine Which Is A Resource On ESX Or Other Virtualization Platform Which Allows The Virtual Machine To Be Replicated And Powered On Different Host Machines Rather Than Writing Of A Script Capable To Jump From One Machine To Another. With The New Parameters And Pipeline Design The CmdLet Can:</maml:para> <maml:para>- Runs Single SQL Query Without Any SQL Parameters HashTable. Provided Directly To The Parameters Or As Object Property Of An Object Coming From The Pipeline. Using This Option Is Not Desirable Whenever Within The Query We Have Users Input Because Of SQL Injection Risk.</maml:para> <maml:para>- Single SQL Query And Single SQL Parameters HashTable, Provided Directly To The Parameters Or Via The Pipeline. Here Are Possible Two Combinations: The Query And The Parameter As Properties Of An Object Coming From The Pipeline Or The SQL Parameters HashTable Coming From The Pipeline And Query Specified As A Parameter.</maml:para> <maml:para>- Single SQL Query And Collection Of SQL Parameters HashTables. In This Case The Parameters Represents Multiple Rows Which Have To Be Inserted Within Single Table. The User Have To Keep In Mind That The SQL Query Must Have SQL Variables For Each Of The Columns And Each HashTable In The Collections Have To Have Keys Corresponding To Each Of The SQL Variables. The SQL Query And Its Corresponding HashTables Collection Can Be Specified Either Directly To The Parameters, Or Via As Properties Of An Object Coming From Pipeline Or Specifying The Query To The CmdLet Query Parameter And The HashTables Collection Coming From The Pipeline.</maml:para> <maml:para>The CmdLet Is Still Capable To Work With Collection Of SQL Queries, However The Queries And Their Corresponding SQL Parameters HashTable / HashTables If Any, Can Be Provided Only Within Properties Of Objects Collection Coming From The Pipeline. Single Object Coming From The Pipeline Cannot Have Multiple SQL Queries.</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para>To Simplify The Dates Managing The Module Offers Predefined Formatting Strings To Convert DateTime Object To Understandable For SQLite Format. Although The CmdLet Will Process SQL Parameters Date Values Without Being Converted Upfront To Strings.</maml:para> <maml:para>Leaving The DateTime Objects To Be Automatically Managed Might Lead To Unexpected Results Related With The DateTime Syntax Coming From The Regional Settings On The Machine, Daylight Saving Related And TimeZone Related Issues. From That Perspective I Would Recommend The Dates To Be Normalized To Long Integer And To Be Stored In Numeric Columns.</maml:para> <maml:para>[System.DateTime]::Now.ToFileTime() - Gets The System DateTime And Converts It To Long Integer.</maml:para> <maml:para>[System.DateTime]::FromFileTime(108666144000000000) - Converts The Long Integer To Local DateTime With Time Zone And Daylight Saving Taken Into Consideration.</maml:para> <maml:para>[System.DateTime]::FromFileTimeUtc(108666144000000000) - Converts The Long Integer To Universal DateTime. (Guess What Is The Date From The Example).</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </maml:description> <command:syntax> <!-- Parameter set: Qry~Db --> <command:syntaxItem> <maml:name>Invoke-SnsSqliteQuery</maml:name> <!-- Parameter: DataBase --> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="DataBaseFile,Path,DataSource"> <maml:name>DataBase</maml:name> <maml:description> <maml:para>Specifies SQLite DataBase File To Connect To.</maml:para> <maml:para>In Case DataBase Doesn't Exist The CmdLet Creates It And Throw Warning.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Paths.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <!-- Parameter: Query --> <command:parameter required="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named" aliases="SqlQuery,DbQuery"> <maml:name>Query</maml:name> <maml:description> <maml:para>Specifies The SQL Query To Be Run.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <!-- Parameter: AppendDataSource --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named"> <maml:name>AppendDataSource</maml:name> <maml:description> <maml:para>Specifies To Append The SQLite DataBase Path To The Output.</maml:para> </maml:description> <command:parameterValue required="true">SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <!-- Parameter: As --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named"> <maml:name>As</maml:name> <maml:description> <maml:para>Specifies To The CmdLet To Revert The Output In One Of The Following Types:</maml:para> <maml:para>[System.Data.DataSet]</maml:para> <maml:para>[System.Data.DataTable[]]</maml:para> <maml:para>[System.Data.DataRow[]]</maml:para> <maml:para>[System.Management.Automation.PSCustomObject[]]</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>PSObject</dev:defaultValue> </command:parameter> <!-- Parameter: QueryTimeout --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named" aliases="TimeOut"> <maml:name>QueryTimeout</maml:name> <maml:description> <maml:para>Specifies The Number Of Seconds Before The Query Times Out.</maml:para> </maml:description> <command:parameterValue required="true">int</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>0</dev:defaultValue> </command:parameter> <!-- Parameter: ReadOnly --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named"> <maml:name>ReadOnly</maml:name> <maml:description> <maml:para>Specifies To Open The DataBase In ReadOnly Mode.</maml:para> </maml:description> <command:parameterValue required="true">SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <!-- Parameter: SqlParameters --> <command:parameter required="false" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="named"> <maml:name>SqlParameters</maml:name> <maml:description> <maml:para>HashTable Of Parameters For Parameterized SQL Queries.</maml:para> <maml:para>The HashTable Keys Must Match The SQL Query Variable Names.</maml:para> <maml:para>The Keys Might Be Specified Either With Or Without At (@) Character In Front.</maml:para> <maml:para>The CmdLet Will Take Care To Add Them If Missing.</maml:para> <maml:para>Example:</maml:para> <maml:para>-Query "SELECT * FROM tblServers WHERE ServerFqdn LIKE @Server"</maml:para> <maml:para>-SqlParameters @{"@Server" = "Server01.contoso.com"}</maml:para> </maml:description> <command:parameterValue required="true">IDictionary[]</command:parameterValue> <dev:type> <maml:name>System.Collections.IDictionary[]</maml:name> <maml:uri /> </dev:type> </command:parameter> </command:syntaxItem> <!-- Parameter set: File~Db --> <command:syntaxItem> <maml:name>Invoke-SnsSqliteQuery</maml:name> <!-- Parameter: DataBase --> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="DataBaseFile,Path,DataSource"> <maml:name>DataBase</maml:name> <maml:description> <maml:para>Specifies SQLite DataBase File To Connect To.</maml:para> <maml:para>In Case DataBase Doesn't Exist The CmdLet Creates It And Throw Warning.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Paths.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <!-- Parameter: InputFile --> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="SqlFile,QueryFile"> <maml:name>InputFile</maml:name> <maml:description> <maml:para>Specifies A ".SQL" File To Be Used As Query Input.</maml:para> <maml:para>Works Only With Full Absolute UNC Path To The File.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <!-- Parameter: AppendDataSource --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named"> <maml:name>AppendDataSource</maml:name> <maml:description> <maml:para>Specifies To Append The SQLite DataBase Path To The Output.</maml:para> </maml:description> <command:parameterValue required="true">SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <!-- Parameter: As --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named"> <maml:name>As</maml:name> <maml:description> <maml:para>Specifies To The CmdLet To Revert The Output In One Of The Following Types:</maml:para> <maml:para>[System.Data.DataSet]</maml:para> <maml:para>[System.Data.DataTable[]]</maml:para> <maml:para>[System.Data.DataRow[]]</maml:para> <maml:para>[System.Management.Automation.PSCustomObject[]]</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>PSObject</dev:defaultValue> </command:parameter> <!-- Parameter: QueryTimeout --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named" aliases="TimeOut"> <maml:name>QueryTimeout</maml:name> <maml:description> <maml:para>Specifies The Number Of Seconds Before The Query Times Out.</maml:para> </maml:description> <command:parameterValue required="true">int</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>0</dev:defaultValue> </command:parameter> <!-- Parameter: ReadOnly --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named"> <maml:name>ReadOnly</maml:name> <maml:description> <maml:para>Specifies To Open The DataBase In ReadOnly Mode.</maml:para> </maml:description> <command:parameterValue required="true">SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <!-- Parameter: SqlParameters --> <command:parameter required="false" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="named"> <maml:name>SqlParameters</maml:name> <maml:description> <maml:para>HashTable Of Parameters For Parameterized SQL Queries.</maml:para> <maml:para>The HashTable Keys Must Match The SQL Query Variable Names.</maml:para> <maml:para>The Keys Might Be Specified Either With Or Without At (@) Character In Front.</maml:para> <maml:para>The CmdLet Will Take Care To Add Them If Missing.</maml:para> <maml:para>Example:</maml:para> <maml:para>-Query "SELECT * FROM tblServers WHERE ServerFqdn LIKE @Server"</maml:para> <maml:para>-SqlParameters @{"@Server" = "Server01.contoso.com"}</maml:para> </maml:description> <command:parameterValue required="true">IDictionary[]</command:parameterValue> <dev:type> <maml:name>System.Collections.IDictionary[]</maml:name> <maml:uri /> </dev:type> </command:parameter> </command:syntaxItem> <!-- Parameter set: Qry~Conn --> <command:syntaxItem> <maml:name>Invoke-SnsSqliteQuery</maml:name> <!-- Parameter: Connection --> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="SQLiteConnection"> <maml:name>Connection</maml:name> <maml:description> <maml:para>Specifies Existing SQLite Connection.</maml:para> <maml:para>In Case The Connection Is Not Open Or Expired The CmdLet Opens It.</maml:para> </maml:description> <command:parameterValue required="true">SQLiteConnection</command:parameterValue> <dev:type> <maml:name>System.Data.SQLite.SQLiteConnection</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>System.Data.SQLite.SQLiteConnection</dev:defaultValue> </command:parameter> <!-- Parameter: Query --> <command:parameter required="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named" aliases="SqlQuery,DbQuery"> <maml:name>Query</maml:name> <maml:description> <maml:para>Specifies The SQL Query To Be Run.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <!-- Parameter: AppendDataSource --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named"> <maml:name>AppendDataSource</maml:name> <maml:description> <maml:para>Specifies To Append The SQLite DataBase Path To The Output.</maml:para> </maml:description> <command:parameterValue required="true">SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <!-- Parameter: As --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named"> <maml:name>As</maml:name> <maml:description> <maml:para>Specifies To The CmdLet To Revert The Output In One Of The Following Types:</maml:para> <maml:para>[System.Data.DataSet]</maml:para> <maml:para>[System.Data.DataTable[]]</maml:para> <maml:para>[System.Data.DataRow[]]</maml:para> <maml:para>[System.Management.Automation.PSCustomObject[]]</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>PSObject</dev:defaultValue> </command:parameter> <!-- Parameter: QueryTimeout --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named" aliases="TimeOut"> <maml:name>QueryTimeout</maml:name> <maml:description> <maml:para>Specifies The Number Of Seconds Before The Query Times Out.</maml:para> </maml:description> <command:parameterValue required="true">int</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>0</dev:defaultValue> </command:parameter> <!-- Parameter: SqlParameters --> <command:parameter required="false" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="named"> <maml:name>SqlParameters</maml:name> <maml:description> <maml:para>HashTable Of Parameters For Parameterized SQL Queries.</maml:para> <maml:para>The HashTable Keys Must Match The SQL Query Variable Names.</maml:para> <maml:para>The Keys Might Be Specified Either With Or Without At (@) Character In Front.</maml:para> <maml:para>The CmdLet Will Take Care To Add Them If Missing.</maml:para> <maml:para>Example:</maml:para> <maml:para>-Query "SELECT * FROM tblServers WHERE ServerFqdn LIKE @Server"</maml:para> <maml:para>-SqlParameters @{"@Server" = "Server01.contoso.com"}</maml:para> </maml:description> <command:parameterValue required="true">IDictionary[]</command:parameterValue> <dev:type> <maml:name>System.Collections.IDictionary[]</maml:name> <maml:uri /> </dev:type> </command:parameter> </command:syntaxItem> <!-- Parameter set: File~Conn --> <command:syntaxItem> <maml:name>Invoke-SnsSqliteQuery</maml:name> <!-- Parameter: Connection --> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="SQLiteConnection"> <maml:name>Connection</maml:name> <maml:description> <maml:para>Specifies Existing SQLite Connection.</maml:para> <maml:para>In Case The Connection Is Not Open Or Expired The CmdLet Opens It.</maml:para> </maml:description> <command:parameterValue required="true">SQLiteConnection</command:parameterValue> <dev:type> <maml:name>System.Data.SQLite.SQLiteConnection</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>System.Data.SQLite.SQLiteConnection</dev:defaultValue> </command:parameter> <!-- Parameter: InputFile --> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="SqlFile,QueryFile"> <maml:name>InputFile</maml:name> <maml:description> <maml:para>Specifies A ".SQL" File To Be Used As Query Input.</maml:para> <maml:para>Works Only With Full Absolute UNC Path To The File.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <!-- Parameter: AppendDataSource --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named"> <maml:name>AppendDataSource</maml:name> <maml:description> <maml:para>Specifies To Append The SQLite DataBase Path To The Output.</maml:para> </maml:description> <command:parameterValue required="true">SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <!-- Parameter: As --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named"> <maml:name>As</maml:name> <maml:description> <maml:para>Specifies To The CmdLet To Revert The Output In One Of The Following Types:</maml:para> <maml:para>[System.Data.DataSet]</maml:para> <maml:para>[System.Data.DataTable[]]</maml:para> <maml:para>[System.Data.DataRow[]]</maml:para> <maml:para>[System.Management.Automation.PSCustomObject[]]</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>PSObject</dev:defaultValue> </command:parameter> <!-- Parameter: QueryTimeout --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named" aliases="TimeOut"> <maml:name>QueryTimeout</maml:name> <maml:description> <maml:para>Specifies The Number Of Seconds Before The Query Times Out.</maml:para> </maml:description> <command:parameterValue required="true">int</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>0</dev:defaultValue> </command:parameter> <!-- Parameter: SqlParameters --> <command:parameter required="false" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="named"> <maml:name>SqlParameters</maml:name> <maml:description> <maml:para>HashTable Of Parameters For Parameterized SQL Queries.</maml:para> <maml:para>The HashTable Keys Must Match The SQL Query Variable Names.</maml:para> <maml:para>The Keys Might Be Specified Either With Or Without At (@) Character In Front.</maml:para> <maml:para>The CmdLet Will Take Care To Add Them If Missing.</maml:para> <maml:para>Example:</maml:para> <maml:para>-Query "SELECT * FROM tblServers WHERE ServerFqdn LIKE @Server"</maml:para> <maml:para>-SqlParameters @{"@Server" = "Server01.contoso.com"}</maml:para> </maml:description> <command:parameterValue required="true">IDictionary[]</command:parameterValue> <dev:type> <maml:name>System.Collections.IDictionary[]</maml:name> <maml:uri /> </dev:type> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <!-- Parameter: DataBase --> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="DataBaseFile,Path,DataSource"> <maml:name>DataBase</maml:name> <maml:description> <maml:para>Specifies SQLite DataBase File To Connect To.</maml:para> <maml:para>In Case DataBase Doesn't Exist The CmdLet Creates It And Throw Warning.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Paths.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="DataBaseFile,Path,DataSource"> <maml:name>DataBaseFile</maml:name> <maml:description> <maml:para>Specifies SQLite DataBase File To Connect To.</maml:para> <maml:para>In Case DataBase Doesn't Exist The CmdLet Creates It And Throw Warning.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Paths.</maml:para> <maml:para>This is an alias of the DataBase parameter.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="DataBaseFile,Path,DataSource"> <maml:name>Path</maml:name> <maml:description> <maml:para>Specifies SQLite DataBase File To Connect To.</maml:para> <maml:para>In Case DataBase Doesn't Exist The CmdLet Creates It And Throw Warning.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Paths.</maml:para> <maml:para>This is an alias of the DataBase parameter.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="DataBaseFile,Path,DataSource"> <maml:name>DataSource</maml:name> <maml:description> <maml:para>Specifies SQLite DataBase File To Connect To.</maml:para> <maml:para>In Case DataBase Doesn't Exist The CmdLet Creates It And Throw Warning.</maml:para> <maml:para>Accepts Either File Name Or Full Absolute UNC Paths.</maml:para> <maml:para>This is an alias of the DataBase parameter.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <!-- Parameter: ReadOnly --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named"> <maml:name>ReadOnly</maml:name> <maml:description> <maml:para>Specifies To Open The DataBase In ReadOnly Mode.</maml:para> </maml:description> <command:parameterValue required="true">SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <!-- Parameter: Connection --> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="SQLiteConnection"> <maml:name>Connection</maml:name> <maml:description> <maml:para>Specifies Existing SQLite Connection.</maml:para> <maml:para>In Case The Connection Is Not Open Or Expired The CmdLet Opens It.</maml:para> </maml:description> <command:parameterValue required="true">SQLiteConnection</command:parameterValue> <dev:type> <maml:name>System.Data.SQLite.SQLiteConnection</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>System.Data.SQLite.SQLiteConnection</dev:defaultValue> </command:parameter> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="SQLiteConnection"> <maml:name>SQLiteConnection</maml:name> <maml:description> <maml:para>Specifies Existing SQLite Connection.</maml:para> <maml:para>In Case The Connection Is Not Open Or Expired The CmdLet Opens It.</maml:para> <maml:para>This is an alias of the Connection parameter.</maml:para> </maml:description> <command:parameterValue required="true">SQLiteConnection</command:parameterValue> <dev:type> <maml:name>System.Data.SQLite.SQLiteConnection</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>System.Data.SQLite.SQLiteConnection</dev:defaultValue> </command:parameter> <!-- Parameter: Query --> <command:parameter required="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named" aliases="SqlQuery,DbQuery"> <maml:name>Query</maml:name> <maml:description> <maml:para>Specifies The SQL Query To Be Run.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named" aliases="SqlQuery,DbQuery"> <maml:name>SqlQuery</maml:name> <maml:description> <maml:para>Specifies The SQL Query To Be Run.</maml:para> <maml:para>This is an alias of the Query parameter.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named" aliases="SqlQuery,DbQuery"> <maml:name>DbQuery</maml:name> <maml:description> <maml:para>Specifies The SQL Query To Be Run.</maml:para> <maml:para>This is an alias of the Query parameter.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <!-- Parameter: InputFile --> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="SqlFile,QueryFile"> <maml:name>InputFile</maml:name> <maml:description> <maml:para>Specifies A ".SQL" File To Be Used As Query Input.</maml:para> <maml:para>Works Only With Full Absolute UNC Path To The File.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="SqlFile,QueryFile"> <maml:name>SqlFile</maml:name> <maml:description> <maml:para>Specifies A ".SQL" File To Be Used As Query Input.</maml:para> <maml:para>Works Only With Full Absolute UNC Path To The File.</maml:para> <maml:para>This is an alias of the InputFile parameter.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="SqlFile,QueryFile"> <maml:name>QueryFile</maml:name> <maml:description> <maml:para>Specifies A ".SQL" File To Be Used As Query Input.</maml:para> <maml:para>Works Only With Full Absolute UNC Path To The File.</maml:para> <maml:para>This is an alias of the InputFile parameter.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <!-- Parameter: SqlParameters --> <command:parameter required="false" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="named"> <maml:name>SqlParameters</maml:name> <maml:description> <maml:para>HashTable Of Parameters For Parameterized SQL Queries.</maml:para> <maml:para>The HashTable Keys Must Match The SQL Query Variable Names.</maml:para> <maml:para>The Keys Might Be Specified Either With Or Without At (@) Character In Front.</maml:para> <maml:para>The CmdLet Will Take Care To Add Them If Missing.</maml:para> <maml:para>Example:</maml:para> <maml:para>-Query "SELECT * FROM tblServers WHERE ServerFqdn LIKE @Server"</maml:para> <maml:para>-SqlParameters @{"@Server" = "Server01.contoso.com"}</maml:para> </maml:description> <command:parameterValue required="true">IDictionary[]</command:parameterValue> <dev:type> <maml:name>System.Collections.IDictionary[]</maml:name> <maml:uri /> </dev:type> </command:parameter> <!-- Parameter: QueryTimeout --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named" aliases="TimeOut"> <maml:name>QueryTimeout</maml:name> <maml:description> <maml:para>Specifies The Number Of Seconds Before The Query Times Out.</maml:para> </maml:description> <command:parameterValue required="true">int</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>0</dev:defaultValue> </command:parameter> <command:parameter required="false" globbing="false" pipelineInput="false" position="named" aliases="TimeOut"> <maml:name>TimeOut</maml:name> <maml:description> <maml:para>Specifies The Number Of Seconds Before The Query Times Out.</maml:para> <maml:para>This is an alias of the QueryTimeout parameter.</maml:para> </maml:description> <command:parameterValue required="true">int</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>0</dev:defaultValue> </command:parameter> <!-- Parameter: As --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named"> <maml:name>As</maml:name> <maml:description> <maml:para>Specifies To The CmdLet To Revert The Output In One Of The Following Types:</maml:para> <maml:para>[System.Data.DataSet]</maml:para> <maml:para>[System.Data.DataTable[]]</maml:para> <maml:para>[System.Data.DataRow[]]</maml:para> <maml:para>[System.Management.Automation.PSCustomObject[]]</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>PSObject</dev:defaultValue> </command:parameter> <!-- Parameter: AppendDataSource --> <command:parameter required="false" globbing="false" pipelineInput="false" position="named"> <maml:name>AppendDataSource</maml:name> <maml:description> <maml:para>Specifies To Append The SQLite DataBase Path To The Output.</maml:para> </maml:description> <command:parameterValue required="true">SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <maml:description> <maml:para>Specifies The SQL Query To Be Run.</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>System.Collections.IDictionary[]</maml:name> <maml:uri /> </dev:type> <maml:description> <maml:para>HashTable Of Parameters For Parameterized SQL Queries.</maml:para> <maml:para>The HashTable Keys Must Match The SQL Query Variable Names.</maml:para> <maml:para>The Keys Might Be Specified Either With Or Without At (@) Character In Front.</maml:para> <maml:para>The CmdLet Will Take Care To Add Them If Missing.</maml:para> <maml:para>Example:</maml:para> <maml:para>-Query "SELECT * FROM tblServers WHERE ServerFqdn LIKE @Server"</maml:para> <maml:para>-SqlParameters @{"@Server" = "Server01.contoso.com"}</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <!-- OutputType: DataRow --> <command:returnValue> <dev:type> <maml:name>System.Data.DataRow</maml:name> <maml:uri /> </dev:type> </command:returnValue> <!-- OutputType: DataSet --> <command:returnValue> <dev:type> <maml:name>System.Data.DataSet</maml:name> <maml:uri /> </dev:type> </command:returnValue> <!-- OutputType: DataTable --> <command:returnValue> <dev:type> <maml:name>System.Data.DataTable</maml:name> <maml:uri /> </dev:type> </command:returnValue> <!-- OutputType: PSCustomObject --> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.PSCustomObject</maml:name> <maml:uri /> </dev:type> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:title></maml:title> <maml:alert> <maml:para>AUTHOR: Svetoslav Nedyalkov Savov</maml:para> <maml:para>THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK</maml:para> <maml:para>OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>---------- EXAMPLE 1 ----------</maml:title> <dev:code>Invoke-SnsSqliteQuery -DataBase "temp.sqlite" ` -Query "CREATE TABLE Events (ID INTEGER, ComputerID INTEGER, Event VARCHAR(20), Date DATETIME)";</dev:code> <dev:remarks> <maml:para></maml:para> <maml:para>Creates A Table "Events" And "temp.sqlite" DataBase If It Does Not Exists.</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- EXAMPLE 2 ----------</maml:title> <dev:code>Invoke-SnsSqliteQuery -DataBase "temp.sqlite" ` -Query "INSERT INTO Events (ID, ComputerID, Event, Date) VALUES (@ID, @ComputerID, @Event, @Date);" ` -SqlParameters ` @{ "@ID" = 1; "@ComputerID" = 5 "Event" = "Error"; "Date" = [System.DateTime]::Now); };</dev:code> <dev:remarks> <maml:para></maml:para> <maml:para>Runs Single Query With Single SQL Parameters HashTable Against "temp.sqlite" DataBase.</maml:para> <maml:para>In The SQL Parameters Keys Are Used Both Strings With And Without At (@) Character.</maml:para> <maml:para></maml:para> <maml:para>The Keys Match Exactly The SQL Query Variables. Please Note That There Are SQL Variables For Each Of The Columns.</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- EXAMPLE 3 ----------</maml:title> <dev:code>Invoke-SnsSqliteQuery -DataBase "temp.sqlite" ` -Query "INSERT INTO Computers (ID, HostName) VALUES (@ID, @HostName);" ` -SqlParameters ` @( @{"@ID" = 1; "HostName" = "Computer1.contoso.com"; }; @{"@ID" = 2; "HostName" = "Computer2.contoso.com"; }; );</dev:code> <dev:remarks> <maml:para></maml:para> <maml:para>Runs Single Query With Multiple SQL Parameters HashTables Against "temp.sqlite" DataBase.</maml:para> <maml:para>In The SQL Parameters Keys Are Used Both Strings With And Without At (@) Character.</maml:para> <maml:para></maml:para> <maml:para>The Keys Match Exactly The SQL Query Variables. Please Note That There Are SQL Variables For Each Of The Columns.</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <maml:relatedLinks> <maml:navigationLink> <maml:linkText> svesavov / SnsSqlitePsModule - </maml:linkText> <maml:uri>https://github.com/svesavov/SnsSqlitePsModule</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> PowerShell Gallery - </maml:linkText> <maml:uri>https://www.powershellgallery.com/packages/SnsSqlitePsModule/</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> Svetoslav Savov on LinkedIn - </maml:linkText> <maml:uri>https://www.linkedin.com/in/svetoslavsavov</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> RamblingCookieMonster / PSSQLite - </maml:linkText> <maml:uri>https://github.com/RamblingCookieMonster/PSSQLite</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite V3 - </maml:linkText> <maml:uri>https://sqlite.org/index.html</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite V3 Data Types - </maml:linkText> <maml:uri>https://www.sqlite.org/datatype3.html</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite V3 Supported SQL Syntax - </maml:linkText> <maml:uri>https://www.sqlite.org/lang.html</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite V3 Pragma Statements - </maml:linkText> <maml:uri>http://www.sqlite.org/pragma.html</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite V3 Tutorials - </maml:linkText> <maml:uri>https://www.sqlitetutorial.net/</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText> SQLite Studio - </maml:linkText> <maml:uri>https://github.com/pawelsalawa/sqlitestudio/releases</maml:uri> </maml:navigationLink> </maml:relatedLinks> </command:command> </helpItems> |