Link to home
Start Free TrialLog in
Avatar of Jaeden Cook
Jaeden Cook

asked on

Separating output values with comma

We have a Powershell script which retrieves contents of a Sharepoint list and generates an output, I need to separate multiple values with a Comma.

$aClient = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
$aClientRuntime = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
$aClientPub = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Publishing.dll")

$username = "xxxxx" 
$password = ConvertTo-SecureString -String 'xxxxx' -AsPlainText -Force
$Url = "https://xxxxxx/sites/"

# SharePoint Online
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext $Url
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials $UserName,$Password 

$clientweb = $ctx.Web  
$ctx.Load($clientweb) 
$ctx.ExecuteQuery() 

#Retrieve List
$List = $ctx.Web.Lists.GetByTitle("On Call List")

$qry = [Microsoft.SharePoint.Client.CamlQuery]::CreateAllItemsQuery()
$items = $List.GetItems($qry)
$ctx.Load($items)
$ctx.ExecuteQuery()

foreach ($item in $items)
{
    $item["Title"]
}

Open in new window

It produces a result formated like this:
emailaddress1@email.com
emailaddress2@email.com


I need help formatting it as:
emailaddress1@email.com , emailaddress2@email.com
SOLUTION
Avatar of Aard Vark
Aard Vark
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial