(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = myhost)(PORT = 1521))(CONNECT_DATA = (SERVICE_NAME = ora)))
I want to replace the HOST name with a new value using powershell, Thank you
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = myhost)(PORT = 1521))(CONNECT_DATA = (SERVICE_NAME = ora)))
I want to replace the HOST name with a new value using powershell, Thank you
this uses the same -replace
operator as used by mklement0
, but uses a simpler pattern for those like myself who are regex-challenged. [grin]
$OldHost = 'myhost'
$NewHost = 'NewHostName'
$InStuff = '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = myhost)(PORT = 1521))(CONNECT_DATA = (SERVICE_NAME = ora)))'
$OutStuff = $InStuff -replace "HOST = $OldHost", "HOST = $NewHost"
$InStuff
$OutStuff
output ...
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = myhost)(PORT = 1521))(CONNECT_DATA = (SERVICE_NAME = ora)))
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = NewHostName)(PORT = 1521))(CONNECT_DATA = (SERVICE_NAME = ora)))