I have created a .bat file to export csv file regulary through windows task scheduling which works fine. But not working when I switch to Powershell. It returns (both in ISE and right click .ps1 "Run with Powershell") with:
SQL*Plus: Release 19.0.0.0.0 - Production on Sun May 2 14:05:52 2021
Version 19.10.0.0.0
Copyright (c) 1982, 2020, Oracle. All rights reserved.
ERROR: ORA-12154: TNS:could not resolve the connect identifier specified
So.I'm not sure what I'm doing wrong. The variable input are dummies.
In my .bat contains:
SET NLS_LANG=.AL32UTF8
SET hostIp="123.123.1.12"
SET username="user1"
SET password="pass1"
SET port="1521"
SET service="myDBname"
SET sqlPath="C:\My script\TEST_EXPORT.sql"
sqlplus %username%/%password%@%hostIp%:%port%/%service% @"%sqlPath%"
In my .ps1 contains:
cls
$hostIp="123.123.1.12"
$username="user1"
$password="pass1"
$port="1521"
$service="myDBname"
$sqlPath="C:\My script\TEST_EXPORT.sql"
echo "$username/$password@$hostIp`:$port/$service @$sqlPath"
sqlplus "$username/$password@$hostIp`:$port/$service @$sqlPath"
$sqlPath
, which the Cmd version has. – vonPryz$database
in the sqlplus line is not defined anywhere, at least in the code you've given. Line above it shows$service
instead of$database
– Daniel