Hello I am trying to extract the servername and database name from a file that contains a connection string. The code I am using is below. The first line can extract the servername fine but the second line cannot, it only shows a blank. What I am missing please help.
Select-String -Path C:\Tmp\movie*.properties -Pattern '(?<=sqlserver://).*?(?=;)' -AllMatches | % { $_.Matches } | % { $_.Value } #- simplematchSelect-String -Path C:\Tmp\movie*.properties -Pattern '(?<=databaseName).*?(?=username)' -AllMatches #| % { $_.Matches } | % { $_.Value } #- simplematch
the .properties files has contents similar to the one below.
driver=net.sourceforge.jtds.jdbc.Driverurl=jdbc:jtds:sqlserver://netflix;appName=Migrate;databaseName=movie_hitsusername=adminpassword=moviecritic#