< Back

Open-OracleDB

Thu Jan 16, 2020 8:38 am

NAME Open-OracleDB



SYNOPSIS

This will run a SQL script or command on one or more Oracle databases by leveraging SQL*Plus





SYNTAX

Open-OracleDB [-TargetDB] <String[]> [-DBUser <String>] [-PasswordPrompt] [-SecurePass <SecureString>] [-SQLQuery]

<String> [-DumpFile <String>] [-HTML] [-PlainText] [-Silent] [-Scratch] [-ErrorLog] [-ErrorLogFile <String>]

[-WhatIf] [-Confirm] [<CommonParameters>]



Open-OracleDB [-TargetDB] <String[]> [-DBUser <String>] [-PasswordPrompt] [-SecurePass <SecureString>]

[-SQLScript] <String> [-DumpFile <String>] [-HTML] [-PlainText] [-Silent] [-Scratch] [-ErrorLog] [-ErrorLogFile

<String>] [-WhatIf] [-Confirm] [<CommonParameters>]





DESCRIPTION

This function runs a SQL script on a Oracle Database and returns the output from the script





PARAMETERS

-TargetDB <String[]>

It can run the script on several databases at once



Required? true

Position? 1

Default value

Accept pipeline input? true (ByValue, ByPropertyName)

Accept wildcard characters? false



-DBUser <String>

Username if required



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-PasswordPrompt [<SwitchParameter>]

Flag to ask for a password



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-SecurePass <SecureString>

Secure String Password



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-SQLScript <String>

It can run several scripts at once



Required? true

Position? 2

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-SQLQuery <String>



Required? true

Position? 2

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-DumpFile <String>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-HTML [<SwitchParameter>]

Switch to force get HTML output



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-PlainText [<SwitchParameter>]



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-Silent [<SwitchParameter>]



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-Scratch [<SwitchParameter>]



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-ErrorLog [<SwitchParameter>]

Switch to turn on the error logging



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-ErrorLogFile <String>



Required? false

Position? named

Default value "$env:TEMP\\OracleUtils_Errors_$PID.log"

Accept pipeline input? false

Accept wildcard characters? false



-WhatIf [<SwitchParameter>]



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Confirm [<SwitchParameter>]



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Use-OracleDB -TargetDB orcl -SQLQuery "SELECT * FROM dba_tables WHERE owner = 'SYSMAN';" | Format-Table













-------------------------- EXAMPLE 2 --------------------------



Use-OracleDB -TargetDB orcl -SQLScript 'C:\\path\\to\\file.sql' -Dump -DumpFile C:\\path\\to\\dump\\file.out>-ErrorLog













-------------------------- EXAMPLE 3 --------------------------



Use-OracleDB -TargetDB <DB NAME>-SQLQuery "SELECT 1 FROM DUAL;" -Dump -DumpFile C:\\path\\to\\dump\\file.out> -ErrorLog















RELATED LINKS