How to add a comma in between two strings

  • 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.

    $SQLSYSADMINACCOUNTS

    O/P is coming as :

    "domain1\OracleDBATeam" , "domain1\SQLDBA, TEAM"

    Any suggestion, how to refine it?

    Thanks.

  • How about adding what the values retrieved are? Possibly in comments.

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply