Articles about European Sharepoint Hosting Service
SharePoint 2013 Hosting – HostForLIFE.eu :: [SharePoint] Get Social Comments From SharePoint 2013 OnPrem Using PowerShell CSOM
Note
All the Page URL’s are stored under “PageUrl” column in excel sheet.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
#Path to the CSV output path file. $CSVOutputfilepath = "D:\Madhu\GetSocialComments.csv" #Path to the log file. $outputfilepath = "D:\Madhu\GetMySocialCommentsLogs.txt" #Excel File path. $FilePath = "D:\Madhu\pagelist.xls" #Create an Object Excel.Application using Com interface $objExcel = New-Object -ComObject Excel.Application # Disable the 'visible' property so the document won't open in excel $objExcel.Visible = $False # Open the Excel file and save it in $WorkBook $WorkBook = $objExcel.Workbooks.Open($FilePath) # Load First sheet $sheet = $WorkBook.Worksheets.Item(1) #Find PageUrl and get the column position $pageurlcolumns = $sheet.UsedRange.Columns.Find('PageUrl').Column #Get all the Rows within Excel $rows = $sheet.UsedRange.Rows.Count ## Get number of user in excel $rowCount = $rows - 1 "-"*80 | Write-Host Write-Host -ForegroundColor Green "Total number of the pages initiated : " $rowCount Write-Host -ForegroundColor Green "Started at : $((Get-Date).ToString())" "-"*80 | Write-Host "-"*80 | Out-File -Encoding Ascii -append $outputfilepath "Total number of the pages initiated : " + $rowCount | Out-File -Encoding Ascii -append $outputfilepath "Started at :" + $((Get-Date).ToString()) | Out-File -Encoding Ascii -append $outputfilepath "-"*80 | Out-File -Encoding Ascii -append $outputfilepath ## Get Page Number Count $count = 1; # loop for each row of the excel file for ($i=2; $i -le $rows; $i++) { try{ #Get PageUrl column values $filePath = $sheet.Cells.Item($i, $pageurlcolumns).text #Log the result to log file Write-Host -ForegroundColor Green "$count : " $filePath "$count : " + $filePath | Out-File -Encoding Ascii -append $outputfilepath ## $url is a string that contains the URL from where we need to count the social comments ## list contains the pages from pages library and hence we got a substring by spliting the url. $url=$filePath.Substring(0,$filePath.IndexOf('/Pages')) ## Get path of socail comments webservice file $uri = $url + "/_vti_bin/SocialDataService.asmx" ## Web Service Reference - http://Site/_vti_bin/SocialDataService.asmx $socialDataServiceWebServiceReference = New-WebServiceProxy -Uri $uri -UseDefaultCredential ##Retrieve number of comments for a specific page. [int]$CountCommentsOnUrl=$socialDataServiceWebServiceReference.CountCommentsOnUrl($filePath) Write-Host -ForegroundColor yellow "Number of comments for the specified URL : " $CountCommentsOnUrl "Number of comments for the specified URL : " + $CountCommentsOnUrl | Out-File -Encoding Ascii -append $outputfilepath ##Retrieve comments for a specific page. $CommentsOnUrl = $socialDataServiceWebServiceReference.GetCommentsOnUrl($filePath,$null,$null,$null) foreach($item in $CommentsOnUrl) { $PageNoteBoardComments += New-Object PsObject -property @{ 'Comments' = $item.Comment 'URL' = [string]$item.Url 'Last Modified Time' = $item.LastModifiedTime 'Owner' = [string]$item.Owner } ##Add comments for a specific page. #$WriteCommentsOnUrl = $socialDataServiceWebServiceReference.AddComment($url,$item.Comment,0,"TestMultiline") } $count++ } catch{ Write-Host -ForegroundColor Green "$accountID : " $_.Exception.Message "$accountID : " + $_.Exception.Message | Out-File -Encoding Ascii -append $outputfilepath } } #Finally, use Export-Csv to export the data to a csv file $PageNoteBoardComments | Export-Csv -NoTypeInformation -Path $$CSVOutputfilepath "-"*80 | Write-Host "-"*80 | Out-File -Encoding Ascii -append $outputfilepath Write-Host -ForegroundColor Green "Completed at : $((Get-Date).ToString())" "Completed at : " + $((Get-Date).ToString()) | Out-File -Encoding Ascii -append $outputfilepath Write-Host -ForegroundColor Green "Total Comments Found : " $PageNoteBoardComments.Count "Total Comments Found : " + $PageNoteBoardComments.Count | Out-File -Encoding Ascii -append $outputfilepath "-"*80 | Write-Host "-"*80 | Out-File -Encoding Ascii -append $outputfilepath #Close the workbook object $WorkBook.close() #close the excel object $objexcel.quit() |
SharePoint 2013 Hosting Recommendation
HostForLIFE.eu’s SharePoint 2013 Hosting solution offers a comprehensive feature set that is easy-to-use for new users, yet powerful enough for the most demanding web developer expert. Hosted SharePoint Foundation 2013 is the premiere web-based collaboration and productivity enhancement tool on the market today. With SharePoint 2013 Foundation, you can quickly access and manage documents and information anytime, anywhere though a Web browser in a secure and user friendly way. SharePoint hosting services start at only at €9.99/mo, allowing you to take advantage of the robust feature set for a small business price. HostForLIFE.eu offers a variety of hosted SharePoint Foundation 2013 plans as well as dedicated SharePoint 2013 Foundation options.
Print article | This entry was posted by Peter on October 10, 2019 at 8:48 am, and is filed under European SharePoint 2013 Hosting. Follow any responses to this post through RSS 2.0. Both comments and pings are currently closed. |