Quantcast
Channel: SQLServerCentral » Programming » Powershell » Latest topics
Viewing all articles
Browse latest Browse all 467

How to add a comma in between two strings

$
0
0
Hi,I want to add a comma in between these two strings. "domain1\OracleDBATeam" "domain1\SQLDBA TEAM"I tried with the below approach:$SQLSYSADMINACCOUNTS = Get-Content "C:\test\Install_ConfigurationFile_2012.ini" | Where-Object {$_ -match 'SQLSYSADMINACCOUNTS='} $pos = $SQLSYSADMINACCOUNTS.IndexOf("=")#$leftPart = $SQLSVCACCOUNT.Substring(0, $pos)$rightPart = $SQLSYSADMINACCOUNTS.Substring($pos+1)$SQLSYSADMINACCOUNTS = $rightPart -replace '"', "" $SQLSYSADMINACCOUNTS = """$SQLSYSADMINACCOUNTS""" -replace '\s+', ', ' # I think I need to append, instead of replace.$SQLSYSADMINACCOUNTSO/P is coming as :"domain1\OracleDBATeam" , "domain1\SQLDBA, TEAM"Any suggestion, how to refine it?

Viewing all articles
Browse latest Browse all 467

Trending Articles