0

this is my Powershell code :

[void][System.Reflection.Assembly]::LoadFile("C:\oracle_script\DLL\Oracle.ManagedDataAccess.dll")

$OracleConnexion = New-Object Oracle.ManagedDataAccess.Client.OracleConnection("User Id=test;Password=v79;aw;Data Source=192.30.1.5/PROD")

I have an issue because my password contain a semicolon : v79;aw

I already tried this :

 New-Object Oracle.ManagedDataAccess.Client.OracleConnection("User Id=test;Password='v79;aw';Data Source=192.30.1.5/PROD")

But it didn't work, because it takes simple quotes in password..

How can I resolve it?

Thanks

Adeel ASIF
  • 3,354
  • 9
  • 27
  • 44

1 Answers1

2

Oracle password can be enclosed between double quotes (oracle password must not contain double quotes). The back ticks allow to escape double quotes in a string enclosed by double quotes in Powershell.

New-Object Oracle.ManagedDataAccess.Client.OracleConnection("User Id=test;Password=`"v79;aw`";Data Source=192.30.1.5/PROD")

see also Escaping quotes and double quotes

Community
  • 1
  • 1
Nahuel Fouilleul
  • 18,726
  • 2
  • 31
  • 36