I am trying to export a SharePoint (365 online) list using PowerShell. Export result should go to CSV. From there I want to grab the infromation and merge it into a XML for directory listing.
Directly Listing output should be.
<YeastarIPPhoneDirectory>
<DirectoryEntry>
<Name>Reception</Name>
<Telephone>200</Telephone>
</DirectoryEntry>
<DirectoryEntry>
<Name>User1</Name>
<Telephone>201</Telephone>
</DirectoryEntry>
<DirectoryEntry>
<Name>User2</Name>
<Telephone>202</Telephone>
</DirectoryEntry>
My SharePoint list contains all the relevant info Name and ext number. The verbals are "user" and the extension number.
This then needs to be automated to run daily.
The code I have so far:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$LiveCred = Get-Credential
$web = Get-SPWeb -identity "https://*.sharepoint.com/IT/Lists/VOIP%20Extentions/"
$list = $web.Lists["Voip%20Extentions"]
$ListItemCollection = @()
$list.Items | Where-Object { $_["Status"] -eq "In Progress" } | foreach {
$ExportItem = New-Object PSObject
$ExportItem | Add-Member -MemberType NoteProperty -Name "Wxt" -Value $_["Ext"]
$ExportItem | Add-Member -MemberType NoteProperty -Name "Name" -Value $_["Name"]
$ListItemCollection += $ExportItem
}
$ListItemCollection | Export-Csv "c:\Phonelist.txt" -NoTypeInformation