You're pretty much down to just parsing out the string (nothing real programmatic about it). So, taking the string jdbc:sqlserver://DBServer2;databaseName=db2;SelectMethod=cursor;SendStringParametersAsUnicode=false
Say it's assigned to a variable
More sophisticated regex could be utilized to try to parse/match the entire string into it's components, but that could be overkill for your needs.
Edit: I see oBdA posted while I was typing. My approach is pretty similar, but I'll leave the post just so you can examine differences. No need for any points.
oBdA
On a side note: why go through all the trouble invoking remote PS, instead of just pulling the file directly?
footech,
there's no specific order for the elements of a connection string, so relying on the order in this particular xml might break the script as soon as the configuration is changed.
That's why I chose the approach with the ConvertFrom-StringData (feeling too lazy for a regex ...).
footech
I'm glad you used the ConvertFrom-StringData method. I considered it, but didn't pursue it when I saw the first element in the string didn't fit the format (which you worked around by using the Where-Object filter). Not knowing how the elements could change is also the reason I didn't pursue a regex.
jdbc:sqlserver://DBServer2
Say it's assigned to a variable
Open in new window
More sophisticated regex could be utilized to try to parse/match the entire string into it's components, but that could be overkill for your needs.Edit: I see oBdA posted while I was typing. My approach is pretty similar, but I'll leave the post just so you can examine differences. No need for any points.