en-us/PSPostgres-Help.xml

<?xml version="1.0" encoding="utf-8"?>
<helpItems schema="maml">
  <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>Connect-Postgres</command:name>
      <command:noun>Postgres</command:noun>
      <command:verb>Connect</command:verb>
      <maml:description>
        <maml:para>Creates a connection to a Postgres server</maml:para>
      </maml:description>
      <dev:version>1.0.7</dev:version>
    </command:details>
    <maml:description>
      <maml:para>Creates a connection to a Postgres server that can be used with Invoke-PostgresQuery</maml:para>
    </maml:description>
    <command:syntax>
      <command:syntaxItem>
        <maml:name>Connect-Postgres</maml:name>
        <command:parameter required="false" position="0" pipelineInput="False" aliases="" variableLength="true" globbing="false">
          <maml:name>ConnectionString</maml:name>
          <maml:description>
            <maml:para>A ConnectionString to connect to a Postgres Server. If this parameter is used, all other parameters will be ignored.</maml:para>
          </maml:description>
          <command:parameterValue required="false" variableLength="true">String</command:parameterValue>
          <dev:type>
            <maml:name>String</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>
          </dev:defaultValue>
        </command:parameter>
        <command:parameter required="false" position="1" pipelineInput="False" aliases="" variableLength="true" globbing="false">
          <maml:name>Credential</maml:name>
          <maml:description>
            <maml:para>Use the credential parameter to securely provide a username and password.</maml:para>
          </maml:description>
          <command:parameterValue required="false" variableLength="true">Pscredential</command:parameterValue>
          <dev:type>
            <maml:name>Pscredential</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>
          </dev:defaultValue>
        </command:parameter>
        <command:parameter required="false" position="2" pipelineInput="False" aliases="" variableLength="true" globbing="false">
          <maml:name>Server</maml:name>
          <maml:description>
            <maml:para>The Postgres server hostname or IP address.</maml:para>
          </maml:description>
          <command:parameterValue required="false" variableLength="true">String</command:parameterValue>
          <dev:type>
            <maml:name>String</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>
          </dev:defaultValue>
        </command:parameter>
        <command:parameter required="false" position="3" pipelineInput="False" aliases="" variableLength="true" globbing="false">
          <maml:name>Port</maml:name>
          <maml:description>
            <maml:para>The Postgres server port.</maml:para>
          </maml:description>
          <command:parameterValue required="false" variableLength="true">Int</command:parameterValue>
          <dev:type>
            <maml:name>Int</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>
          </dev:defaultValue>
        </command:parameter>
        <command:parameter required="false" position="4" pipelineInput="False" aliases="" variableLength="true" globbing="false">
          <maml:name>Database</maml:name>
          <maml:description>
            <maml:para>The default database.</maml:para>
          </maml:description>
          <command:parameterValue required="false" variableLength="true">String</command:parameterValue>
          <dev:type>
            <maml:name>String</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>
          </dev:defaultValue>
        </command:parameter>
        <command:parameter required="false" position="5" pipelineInput="False" aliases="" variableLength="true" globbing="false">
          <maml:name>Query</maml:name>
          <maml:description>
          </maml:description>
          <command:parameterValue required="false" variableLength="true">String</command:parameterValue>
          <dev:type>
            <maml:name>String</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>
          </dev:defaultValue>
        </command:parameter>
        <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
          <maml:name>AsHashTable</maml:name>
          <maml:description>
          </maml:description>
          <command:parameterValue required="false" variableLength="true">Switch</command:parameterValue>
          <dev:type>
            <maml:name>Switch</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>
          </dev:defaultValue>
        </command:parameter>
        <command:parameter required="false" position="6" pipelineInput="False" aliases="" variableLength="true" globbing="false">
          <maml:name>Parameters</maml:name>
          <maml:description>
          </maml:description>
          <command:parameterValue required="false" variableLength="true">Hashtable</command:parameterValue>
          <dev:type>
            <maml:name>Hashtable</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>
          </dev:defaultValue>
        </command:parameter>
      </command:syntaxItem>
    </command:syntax>
    <command:parameters>
      <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
        <maml:name>AsHashTable</maml:name>
        <maml:description>
        </maml:description>
        <command:parameterValue required="false" variableLength="true">Switch</command:parameterValue>
        <dev:type>
          <maml:name>Switch</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>
        </dev:defaultValue>
      </command:parameter>
      <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
        <maml:name>ConnectionString</maml:name>
        <maml:description>
          <maml:para>A ConnectionString to connect to a Postgres Server. If this parameter is used, all other parameters will be ignored.</maml:para>
        </maml:description>
        <command:parameterValue required="false" variableLength="true">String</command:parameterValue>
        <dev:type>
          <maml:name>String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>
        </dev:defaultValue>
      </command:parameter>
      <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
        <maml:name>Credential</maml:name>
        <maml:description>
          <maml:para>Use the credential parameter to securely provide a username and password.</maml:para>
        </maml:description>
        <command:parameterValue required="false" variableLength="true">Pscredential</command:parameterValue>
        <dev:type>
          <maml:name>Pscredential</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>
        </dev:defaultValue>
      </command:parameter>
      <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
        <maml:name>Database</maml:name>
        <maml:description>
          <maml:para>The default database.</maml:para>
        </maml:description>
        <command:parameterValue required="false" variableLength="true">String</command:parameterValue>
        <dev:type>
          <maml:name>String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>
        </dev:defaultValue>
      </command:parameter>
      <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
        <maml:name>Parameters</maml:name>
        <maml:description>
        </maml:description>
        <command:parameterValue required="false" variableLength="true">Hashtable</command:parameterValue>
        <dev:type>
          <maml:name>Hashtable</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>
        </dev:defaultValue>
      </command:parameter>
      <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
        <maml:name>Port</maml:name>
        <maml:description>
          <maml:para>The Postgres server port.</maml:para>
        </maml:description>
        <command:parameterValue required="false" variableLength="true">Int</command:parameterValue>
        <dev:type>
          <maml:name>Int</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>
        </dev:defaultValue>
      </command:parameter>
      <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
        <maml:name>Query</maml:name>
        <maml:description>
        </maml:description>
        <command:parameterValue required="false" variableLength="true">String</command:parameterValue>
        <dev:type>
          <maml:name>String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>
        </dev:defaultValue>
      </command:parameter>
      <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
        <maml:name>Server</maml:name>
        <maml:description>
          <maml:para>The Postgres server hostname or IP address.</maml:para>
        </maml:description>
        <command:parameterValue required="false" variableLength="true">String</command:parameterValue>
        <dev:type>
          <maml:name>String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>
        </dev:defaultValue>
      </command:parameter>
    </command:parameters>
    <command:examples>
      <command:example>
        <maml:title> -------------------------- EXAMPLE 1 -------------------------- </maml:title>
        <maml:introduction>
          <maml:para> PS &gt; </maml:para>
        </maml:introduction>
        <dev:code> $conn = Connect-Postgres -ConnectionString "host = localhost; port = 5432; database = db; user id = dbuser; password = PSPostGr3z;
"
Creates a Postgres connection to localhost on the default port and assigns the object to the $conn variable. </dev:code>
        <dev:remarks>
        </dev:remarks>
      </command:example>
    </command:examples>
  </command:command>
  <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-PostgresQuery</command:name>
      <command:noun>PostgresQuery</command:noun>
      <command:verb>Invoke</command:verb>
      <maml:description>
        <maml:para>Executes a query against a Postgres database</maml:para>
      </maml:description>
      <dev:version>1.0.7</dev:version>
    </command:details>
    <maml:description>
      <maml:para>Executes a query against a Postgres database</maml:para>
    </maml:description>
    <command:syntax>
      <command:syntaxItem>
        <maml:name>Invoke-PostgresQuery</maml:name>
        <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
          <maml:name>Connection</maml:name>
          <maml:description>
            <maml:para>A connected Postgres object from Connect-Postgres</maml:para>
          </maml:description>
          <command:parameterValue required="false" variableLength="true">Npgsql.NpgsqlConnection</command:parameterValue>
          <dev:type>
            <maml:name>Npgsql.NpgsqlConnection</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>
          </dev:defaultValue>
        </command:parameter>
        <command:parameter required="true" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
          <maml:name>Query</maml:name>
          <maml:description>
            <maml:para>The query. Can be an INSERT, SELECT, etc.</maml:para>
          </maml:description>
          <command:parameterValue required="true" variableLength="true">String</command:parameterValue>
          <dev:type>
            <maml:name>String</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>
          </dev:defaultValue>
        </command:parameter>
        <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
          <maml:name>AsDatatable</maml:name>
          <maml:description>
            <maml:para>By default, a PowerShell object is returned. This parameter returns results as a datatable.</maml:para>
          </maml:description>
          <command:parameterValue required="false" variableLength="true">Switch</command:parameterValue>
          <dev:type>
            <maml:name>Switch</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>
          </dev:defaultValue>
        </command:parameter>
        <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
          <maml:name>AsHashTable</maml:name>
          <maml:description>
            <maml:para>By default, a PowerShell object is returned. This parameter returns results as a hashtable.</maml:para>
          </maml:description>
          <command:parameterValue required="false" variableLength="true">Switch</command:parameterValue>
          <dev:type>
            <maml:name>Switch</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>
          </dev:defaultValue>
        </command:parameter>
        <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
          <maml:name>Parameters</maml:name>
          <maml:description>
            <maml:para>Hashtable for parameterized queries.</maml:para>
          </maml:description>
          <command:parameterValue required="false" variableLength="true">Hashtable</command:parameterValue>
          <dev:type>
            <maml:name>Hashtable</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>
          </dev:defaultValue>
        </command:parameter>
      </command:syntaxItem>
      <command:syntaxItem>
        <maml:name>Invoke-PostgresQuery</maml:name>
        <command:parameter required="true" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
          <maml:name>Credential</maml:name>
          <maml:description>
          </maml:description>
          <command:parameterValue required="true" variableLength="true">Pscredential</command:parameterValue>
          <dev:type>
            <maml:name>Pscredential</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>
          </dev:defaultValue>
        </command:parameter>
        <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
          <maml:name>Server</maml:name>
          <maml:description>
          </maml:description>
          <command:parameterValue required="false" variableLength="true">String</command:parameterValue>
          <dev:type>
            <maml:name>String</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>
          </dev:defaultValue>
        </command:parameter>
        <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
          <maml:name>Port</maml:name>
          <maml:description>
          </maml:description>
          <command:parameterValue required="false" variableLength="true">Int</command:parameterValue>
          <dev:type>
            <maml:name>Int</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>
          </dev:defaultValue>
        </command:parameter>
        <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
          <maml:name>Database</maml:name>
          <maml:description>
          </maml:description>
          <command:parameterValue required="false" variableLength="true">String</command:parameterValue>
          <dev:type>
            <maml:name>String</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>
          </dev:defaultValue>
        </command:parameter>
        <command:parameter required="true" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
          <maml:name>Query</maml:name>
          <maml:description>
            <maml:para>The query. Can be an INSERT, SELECT, etc.</maml:para>
          </maml:description>
          <command:parameterValue required="true" variableLength="true">String</command:parameterValue>
          <dev:type>
            <maml:name>String</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>
          </dev:defaultValue>
        </command:parameter>
        <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
          <maml:name>AsDatatable</maml:name>
          <maml:description>
            <maml:para>By default, a PowerShell object is returned. This parameter returns results as a datatable.</maml:para>
          </maml:description>
          <command:parameterValue required="false" variableLength="true">Switch</command:parameterValue>
          <dev:type>
            <maml:name>Switch</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>
          </dev:defaultValue>
        </command:parameter>
        <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
          <maml:name>AsHashTable</maml:name>
          <maml:description>
            <maml:para>By default, a PowerShell object is returned. This parameter returns results as a hashtable.</maml:para>
          </maml:description>
          <command:parameterValue required="false" variableLength="true">Switch</command:parameterValue>
          <dev:type>
            <maml:name>Switch</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>
          </dev:defaultValue>
        </command:parameter>
        <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
          <maml:name>Parameters</maml:name>
          <maml:description>
            <maml:para>Hashtable for parameterized queries.</maml:para>
          </maml:description>
          <command:parameterValue required="false" variableLength="true">Hashtable</command:parameterValue>
          <dev:type>
            <maml:name>Hashtable</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>
          </dev:defaultValue>
        </command:parameter>
      </command:syntaxItem>
    </command:syntax>
    <command:parameters>
      <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
        <maml:name>AsDatatable</maml:name>
        <maml:description>
          <maml:para>By default, a PowerShell object is returned. This parameter returns results as a datatable.</maml:para>
        </maml:description>
        <command:parameterValue required="false" variableLength="true">Switch</command:parameterValue>
        <dev:type>
          <maml:name>Switch</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>
        </dev:defaultValue>
      </command:parameter>
      <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
        <maml:name>AsHashTable</maml:name>
        <maml:description>
          <maml:para>By default, a PowerShell object is returned. This parameter returns results as a hashtable.</maml:para>
        </maml:description>
        <command:parameterValue required="false" variableLength="true">Switch</command:parameterValue>
        <dev:type>
          <maml:name>Switch</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>
        </dev:defaultValue>
      </command:parameter>
      <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
        <maml:name>Connection</maml:name>
        <maml:description>
          <maml:para>A connected Postgres object from Connect-Postgres</maml:para>
        </maml:description>
        <command:parameterValue required="false" variableLength="true">Npgsql.NpgsqlConnection</command:parameterValue>
        <dev:type>
          <maml:name>Npgsql.NpgsqlConnection</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>
        </dev:defaultValue>
      </command:parameter>
      <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
        <maml:name>Credential</maml:name>
        <maml:description>
        </maml:description>
        <command:parameterValue required="false" variableLength="true">Pscredential</command:parameterValue>
        <dev:type>
          <maml:name>Pscredential</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>
        </dev:defaultValue>
      </command:parameter>
      <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
        <maml:name>Database</maml:name>
        <maml:description>
        </maml:description>
        <command:parameterValue required="false" variableLength="true">String</command:parameterValue>
        <dev:type>
          <maml:name>String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>
        </dev:defaultValue>
      </command:parameter>
      <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
        <maml:name>Parameters</maml:name>
        <maml:description>
          <maml:para>Hashtable for parameterized queries.</maml:para>
        </maml:description>
        <command:parameterValue required="false" variableLength="true">Hashtable</command:parameterValue>
        <dev:type>
          <maml:name>Hashtable</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>
        </dev:defaultValue>
      </command:parameter>
      <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
        <maml:name>Port</maml:name>
        <maml:description>
        </maml:description>
        <command:parameterValue required="false" variableLength="true">Int</command:parameterValue>
        <dev:type>
          <maml:name>Int</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>
        </dev:defaultValue>
      </command:parameter>
      <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
        <maml:name>Query</maml:name>
        <maml:description>
          <maml:para>The query. Can be an INSERT, SELECT, etc.</maml:para>
        </maml:description>
        <command:parameterValue required="false" variableLength="true">String</command:parameterValue>
        <dev:type>
          <maml:name>String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>
        </dev:defaultValue>
      </command:parameter>
      <command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false">
        <maml:name>Server</maml:name>
        <maml:description>
        </maml:description>
        <command:parameterValue required="false" variableLength="true">String</command:parameterValue>
        <dev:type>
          <maml:name>String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>
        </dev:defaultValue>
      </command:parameter>
    </command:parameters>
    <command:examples>
      <command:example>
        <maml:title> -------------------------- EXAMPLE 1 -------------------------- </maml:title>
        <maml:introduction>
          <maml:para> PS &gt; </maml:para>
        </maml:introduction>
        <dev:code> $conn = Connect-Postgres -ConnectionString $env:PGSQLConn
Invoke-PostgresQuery -Connection $conn -Query @"
CREATE TABLE test(
    id int,
    guid uuid,
    date timestamp with time zone,
    smallint integer,
    bigint bigint,
    double double precision
)
"@ </dev:code>
        <dev:remarks>
          <maml:para> Connects to a Postgres database and executes a statement that creates a table. </maml:para>
        </dev:remarks>
      </command:example>
      <command:example>
        <maml:title> -------------------------- EXAMPLE 2 -------------------------- </maml:title>
        <maml:introduction>
          <maml:para> PS &gt; </maml:para>
        </maml:introduction>
        <dev:code> $conn = Connect-Postgres -ConnectionString $env:PGSQLConn
Invoke-PostgresQuery -Connection $conn -Query @"
INSERT INTO test(id, guid, date, smallint, bigint, double)
VALUES(@id, @guid, @date, @smallint, @bigint, @double)
"@ -Parameters @{
    "@id" = 1
    "@guid" = [Guid]::NewGuid()
    "@date" = [DateTime]::Now
    "@smallint" = 42
    "@bigint" = [Int64]::MaxValue
    "@double" = 0.23
} </dev:code>
        <dev:remarks>
          <maml:para> Connects to a Postgres database and executes a statement that safely inserts a row using a parameterized query. </maml:para>
        </dev:remarks>
      </command:example>
      <command:example>
        <maml:title> -------------------------- EXAMPLE 3 -------------------------- </maml:title>
        <maml:introduction>
          <maml:para> PS &gt; </maml:para>
        </maml:introduction>
        <dev:code> $conn = Connect-Postgres -ConnectionString $env:PGSQLConn
Invoke-PostgresQuery -Connection $conn -Query "SELECT * FROM test" </dev:code>
        <dev:remarks>
          <maml:para> Connects to a Postgres database and executes a simple query. </maml:para>
        </dev:remarks>
      </command:example>
    </command:examples>
  </command:command>
</helpItems>