Specifying an Oracle host port and service name for your PowerShell scripts
You can specify the host, port and service name of your Oracle database in several ways, before or during installation.
Procedure
- If you have created a TNSNAMES.ora file in which you define a Net Service Name for this database, when PowerShell prompts you for a Net Service, type the name of the Net Service Name you configured.
- Alternatively, you can enter the string
%manual%as a value for Net Service. This results in three new prompts: Host name, Port and Service name. This is useful if you are installing manually but have no TNSNAMES.ora file. - Alternatively, you can enter the value of a Net Service directly on a single line, for example:
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = myhost)(PORT = 1521))(CONNECT_DATA = (SERVICE_NAME = ora)))This is useful if you are installing manually, have no TNSNAMES.ora file but do have more to configure than just a host, port and service.
- Alternatively, you can define a variable in PowerShell and give it a nicely formatted connection string as a value, for example:
$MyDatabaseServer ="(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = myhost)(PORT = 1521)) (LOAD_BALANCE = YES) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORA) ) )"You can then call your PowerShell script with a parameter called
DatabaseServer, set to this variable:& ‘.\somescript.ps1’ –DatabaseServer $MyDatabaseServerThis is useful is you want to perform one or more unattended installations and have no TNSNAMES.ora file. It also helps to make your connection string easier to read.
Related concepts