Well, in the previous post,

We learned how to install, configure and enable Boldon James Classifier for SharePoint.

In that Post, we had a section, which was about how to activate the Boldon James SharePoint Classifier feature for the site collection and apply endpoint. If we have a few sites, we can do it manually. However, think about a big farm, which has multiple Web Applications and each Web Application has thousands of site collections, the task becomes very tedious and challenging.

Therefore, we need some sort of script or code, which can do this for us without having us put in more effort. For that, the first thing came to my mind is PowerShell script. Well, I went ahead and prepared the script, which makes our task much easier. All we need to do is, just place the script in SharePoint Server and provide a few inputs at run time. That’s it, the script will take over from there and do our task.

Script

Save the script given below to SharePoint Server.

  1. <#
  2. .SYNOPSIS
  3. Sets the SharePoint Classifier Service EndPoint URL for a Site Collection
  4. .DESCRIPTION
  5. Sets the SharePoint Classifier Service EndPoint URL for a Site Collection
  6. #>
  7. Function PromptForServiceEndPointURL
  8. {
  9. $ServiceEndPointAccpeted = $false
  10. While($ServiceEndPointAccpeted -ne $true)
  11. {
  12. $EndPointInput = Read-Host -Prompt "Please provide Boldon James Classifier Service Endpoint URL"
  13. if($EndPointInput -ne $null -and $EndPointInput -ne "")
  14. {
  15. try
  16. {
  17. $xHTTP = new-object -com msxml2.xmlhttp;
  18. $xHTTP.open("GET",$EndPointInput,$false);
  19. $xHTTP.send();
  20. $xHTTP.status # returns the status code
  21. if ($xHTTP.status -eq "200")
  22. {
  23. Write-Host -ForegroundColor Green "Endpoint URL has been accepted..."
  24. $ServiceEndPointAccpeted = $true
  25. }
  26. else
  27. {
  28. Write-Host -ForegroundColor Red "Endpoint URL is not valid, please provide valid input..."
  29. }
  30. }
  31. catch
  32. {
  33. Write-Host -ForegroundColor Red "Endpoint URL validation failed..."
  34. }
  35. }
  36. else
  37. {
  38. Write-Host -ForegroundColor Red "Invalid URL, please enter correct URL..."
  39. }
  40. }
  41. Return $EndPointInput
  42. }
  43. Function ApplyBoldonJamesServiceEndPoint($SiteCollectionUrl, $SCServiceEndpointUrl)
  44. {
  45. try
  46. {
  47. $FeatureActivated = $false
  48. $ActivationResults = @()
  49. $ValueAccepted = $false
  50. $site = New-Object Microsoft.SharePoint.SPSite($SiteCollectionUrl)
  51. if((Get-SPFeature "SharePointClassifier_Classifier" -Site $Site -ErrorAction SilentlyContinue) -eq $null)
  52. {
  53. Write-Host "Feature is not enabled, enabling it now..."
  54. $Feature = Enable-SPFeature "SharePointClassifier_Classifier" -Url $Site.URL -ErrorAction SilentlyContinue
  55. Write-Host "Enabled Feature"
  56. if((Get-SPFeature "SharePointClassifier_Classifier" -Site $Site -ErrorAction SilentlyContinue) -eq $null)
  57. {
  58. $FeatureActivated = $False
  59. $ActivationResults += $false
  60. }
  61. }
  62. else
  63. {
  64. $FeatureActivated = $true
  65. $ActivationResults += $true
  66. }
  67. if($FeatureActivated -eq $true)
  68. {
  69. Write-Host Now adding the property
  70. $rootWeb = $site.RootWeb
  71. Write-Host -foregroundcolor Green "The Site Collection Root Site is" $rootWeb
  72. $EndPointProperty = "bjEndpointAddress"
  73. $rootWeb.AllowUnsafeUpdates = $true;
  74. $Currentvalue = $rootWeb.AllProperties[$EndPointProperty]
  75. Write-Host -foregroundcolor Green "The current value is "$Currentvalue
  76. if (!$rootWeb.AllProperties.ContainsKey($EndPointProperty))
  77. {
  78. $rootWeb.AllProperties.Add($EndPointProperty, $SCServiceEndpointurl);
  79. }
  80. else
  81. {
  82. $rootWeb.AllProperties[$EndPointProperty] = $SCServiceEndpointurl;
  83. }
  84. $rootWeb.Update();
  85. $rootWeb.AllowUnsafeUpdates = $false;
  86. $UpdatedValue = $rootWeb.AllProperties[$EndPointProperty]
  87. Write-Host -foregroundcolor Green "Value is updated with " $UpdatedValue
  88. if($UpdatedValue -eq $SCServiceEndpointUrl)
  89. {
  90. $ValueAccepted = $true
  91. }
  92. else
  93. {
  94. $ValueAccepted = $false
  95. }
  96. if ($rootWeb -ne $null)
  97. {
  98. $rootWeb.Dispose()
  99. }
  100. If ($site -ne $null)
  101. {
  102. $site.Dispose();
  103. }
  104. $ActivationResults += $ValueAccepted
  105. }
  106. else
  107. {
  108. $ActivationResults += $false
  109. }
  110. Return $ActivationResults
  111. }
  112. catch
  113. {
  114. $ActivationResults += $FeatureActivated
  115. $ActivationResults += $ValueAccepted
  116. Return $ActivationResults
  117. }
  118. }
  119. Function ApplyEndPointUsingIE($EPURL, $SCURL)
  120. {
  121. Try
  122. {
  123. $addedToLocalIntranetZone = $false
  124. $SiteName = "*"
  125. $myDomain = "yourdomain.com"
  126. #Write-Host -F Yellow "Verifying existence of "$SiteName"."$myDomain" in Local Intranet Zone"
  127. $RegItem_Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\" + $myDomain + "\" + $SiteName
  128. If((Test-Path $RegItem_Path -ErrorAction SilentlyContinue) -eq $True)
  129. {
  130. #Write-Host -F Cyan $SiteName"."$myDomain already exists in Local Intranet Zone
  131. $addedToLocalIntranetZone = $true
  132. #Exit 1001
  133. }
  134. Else
  135. {
  136. #Write-Host -F Blue $SiteName"."$myDomain not found in Local Intranet Zone, adding it now
  137. New-Item $RegItem_Path -Force | Out-Null
  138. New-ItemProperty -Path $RegItem_Path -Name https -Value 1 -PropertyType DWord | Out-Null
  139. New-ItemProperty -Path $RegItem_Path -Name http -Value 1 -PropertyType DWord | Out-Null
  140. If((Test-Path $RegItem_Path -ErrorAction SilentlyContinue) -eq $True)
  141. {
  142. #Write-Host -F Green $SiteName"."$mydomain has been added to Local Intranet Zone
  143. $addedToLocalIntranetZone = $true
  144. }
  145. else
  146. {
  147. #Write-Host -F Red $SiteName"."$mydomain could not be added to Local Intranet Zone
  148. }
  149. }
  150. }
  151. Catch
  152. {
  153. #Write-Host -F Red "An error occurred while verifying "$SiteName"."$myDomain" in Local Intranet Zone"
  154. #Exit 1001
  155. }
  156. if($addedToLocalIntranetZone -ne $false)
  157. {
  158. $SiteCollectionURL = $SCURL
  159. $ActivationResults = @()
  160. $FeatureActivated = $false
  161. if((Get-SPFeature "SharePointClassifier_Classifier" -Site $SiteCollectionURL -ErrorAction SilentlyContinue) -eq $null)
  162. {
  163. #Write-Host "Feature is not enabled, enabling it now..."
  164. $Feature = Enable-SPFeature "SharePointClassifier_Classifier" -Url $SiteCollectionURL -ErrorAction SilentlyContinue
  165. #Write-Host "Enabled Feature"
  166. if((Get-SPFeature "SharePointClassifier_Classifier" -Site $SiteCollectionURL -ErrorAction SilentlyContinue) -eq $null)
  167. {
  168. #Write-Host -F Red "Feature could not be activated on the site"
  169. $ActivationResults += $False
  170. }
  171. else
  172. {
  173. #Write-Host -F Green "Feature has been activated on the site"
  174. $ActivationResults += $true
  175. $FeatureActivated = $true
  176. }
  177. }
  178. else
  179. {
  180. #Write-Host -F Cyan "Feature is already activated on the site"
  181. $ActivationResults += $true
  182. $FeatureActivated = $true
  183. }
  184. if($FeatureActivated -eq $true)
  185. {
  186. $URI = $SiteCollectionURL + "/_layouts/15/SharePointClassifier/SharePointClassifierSiteSettings.aspx"
  187. $ieObject = new-object -com "InternetExplorer.Application"
  188. $ieObject.navigate($URI)
  189. for($i = 10; $i -gt 0; $i--)
  190. {
  191. #Write-Host -F Yellow "Authenticating, please wait for $i second(s)...`r" -NoNewLine
  192. Sleep -s 1
  193. }
  194. #Write-Host -F Green "Internet Explorer has been opened successfully..."
  195. $ieObject.visible = $true
  196. #Retrieve the HTML document returned by search page to an object
  197. $doc = $ieObject.Document
  198. #Write-Host -F Yellow "Please wait while the service endpoint is being applied..."
  199. #Enter value to be searched in the search text box
  200. $doc.getElementByID("ctl00_PlaceHolderMain_TextBoxServiceEndPointAddress").Value = $EPURL
  201. #Click on Search button
  202. $doc.GetElementByID("ctl00_PlaceHolderMain_LinkButtonServiceSettings").Click()
  203. do
  204. {
  205. sleep 1
  206. #Write-Host "Please wait while the operation is being processed...`r" -NoNewLine
  207. }
  208. until(-not ($ieObject.Busy))
  209. #Write-Host
  210. #Write-Host -F Green "Operation has been processed by the browser..."
  211. $EndPointResultErrorElementFound = $False
  212. $EndPointResultSuccessElementFound = $False
  213. $EndPointResultErrorText = "NA"
  214. $EndPointResultSuccessText = "NA"
  215. While($EndPointResultErrorElementFound -ne $True -or $EndPointResultErrorElementFound -ne $True)
  216. {
  217. #Write-Host -F Yellow "Loading page contents, please wait... `r" -NoNewLine
  218. $EndPointResultDoc = $ieObject.Document
  219. $EndPointResultErrorElement = $EndPointResultDoc.GetElementByID("ctl00_PlaceHolderMain_ServiceSettingsError")
  220. if($EndPointResultErrorElement -ne $null)
  221. {
  222. $EndPointResultErrorElementFound = $true
  223. $EndPointResultErrorText = $EndPointResultErrorElement.OuterText
  224. #Write-Host -F Red Error Element Found, Error Is: $EndPointResultErrorText
  225. }
  226. $EndPointResultSuccessElement = $EndPointResultDoc.GetElementByID("ctl00_PlaceHolderMain_ServiceSettingsSuccess")
  227. if($EndPointResultSuccessElement -ne $null)
  228. {
  229. $EndPointResultSuccessElementFound = $true
  230. $EndPointResultSuccessText = $EndPointResultSuccessElement.OuterText
  231. #Write-Host -F Green Success Element Found, Message: $EndPointResultSuccessText
  232. }
  233. Sleep -s 1
  234. }
  235. #Write-Host
  236. #Write-Host -F Green "Boldon James Classifier service page has been loaded..."
  237. #Check whether the search operation succeeded or not
  238. if($EndPointResultSuccessText -ne "" -and $EndPointResultSuccessText -ne $null)
  239. {
  240. #Write-Host -F Green "Operation successful..."
  241. #Write-Host -F Magenta Result: $EndPointResultSuccessText
  242. $ErrorOccurred = "No"
  243. }
  244. elseif($EndPointResultErrorText -ne "" -and $EndPointResultErrorText -ne $null)
  245. {
  246. #Write-Host -F Red "Operation failed..."
  247. #Write-Host -F Magenta Result: $EndPointResultErrorText
  248. $ErrorOccurred = "Yes"
  249. }
  250. $ieObject.Quit()
  251. if($ErrorOccurred -eq "No")
  252. {
  253. $ActivationResults += $true
  254. }
  255. elseif($ErrorOccurred -eq "Yes")
  256. {
  257. $ActivationResults += $false
  258. }
  259. }
  260. else
  261. {
  262. $ActivationResults += $false
  263. }
  264. Return $ActivationResults
  265. }
  266. else
  267. {
  268. #Write-Host "Terminating the execution as the domain could not be added to Local Intranet Zone..."
  269. $ActivationResults += $false
  270. $ActivationResults += $false
  271. Return $ActivationResults
  272. }
  273. }
  274. Clear-Host
  275. Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue
  276. if((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -ne $null)
  277. {
  278. Write-Host -ForegroundColor Cyan "============================================================="
  279. Write-Host -ForegroundColor Magenta " Boldon James Service Activation "
  280. Write-Host -ForegroundColor Cyan "============================================================="
  281. Function PromptForScopeSelections
  282. {
  283. $promptTitle = "Scope selection"
  284. $promptMessage = "Please select the option to set scope for applying Boldon James Classifier EndPoint"
  285. $optionSite = New-Object System.Management.Automation.Host.ChoiceDescription "&Site Collection", `
  286. "Apply for one site collection"
  287. $optionSite.HelpMessage = "This option will apply Boldon James Classifier Service EndPoint for one site collection"
  288. $optionWebApp = New-Object System.Management.Automation.Host.ChoiceDescription "&Web Application", `
  289. "Apply for all site collections in a web application"
  290. $optionWebApp.HelpMessage = "This option will apply Boldon James Classifier Service EndPoint for all site collections in one web application"
  291. $optionFarm = New-Object System.Management.Automation.Host.ChoiceDescription "&Farm", `
  292. "Apply for all site collections in all web applications"
  293. $optionFarm.HelpMessage = "This option will apply Boldon James Classifier Service EndPoint for all site collections in all web applications"
  294. $promptOptions = [System.Management.Automation.Host.ChoiceDescription[]]($optionSite, $optionWebApp, $optionFarm)
  295. $promptResult = $host.ui.PromptForChoice($promptTitle, $promptMessage, $promptOptions, 0)
  296. Return $promptResult
  297. }
  298. Write-Host -ForegroundColor Green "SharePoint snap-in has been loaded successfully..."
  299. #Call the function to prompt for scope selection.
  300. $UserOption = 3
  301. $UserOptionAccepted = $false
  302. While($UserOptionAccepted -ne $true)
  303. {
  304. $UserOption = PromptForScopeSelections
  305. if($UserOption -ge 0 -and $UserOption -le 3)
  306. {
  307. Write-Host -ForegroundColor Green "Input has been accepted."
  308. switch ($UserOption)
  309. {
  310. 2 {Write-Host -ForegroundColor DarkCyan "You selected farm."}
  311. 1 {Write-Host -ForegroundColor DarkCyan "You selected web application."}
  312. 0 {Write-Host -ForegroundColor DarkCyan "You selected site collection."}
  313. }
  314. $UserOptionAccepted = $true
  315. }
  316. elseif($UserOption -lt 0 -or $UserOption -ge 3 -or $UserOption -eq "" -or $UserOption -eq $null)
  317. {
  318. Write-Host -ForegroundColor Red "Invalid input..."
  319. }
  320. }
  321. if($UserOptionAccepted -eq $true)
  322. {
  323. $ScriptPath = Split-Path $MyInvocation.MyCommand.Path
  324. $ScriptDate = Get-Date -Format "dd-MMM-yyyy"
  325. $ScriptTime = Get-Date -Format "hh-mm-ss"
  326. $SiteCounter = 0
  327. $SuccessCount = 0
  328. $FailedCount = 0
  329. $WebAppCounter = 0
  330. [string]$EndPointURLDummy = PromptForServiceEndpointURL
  331. $EndPointURLTemp = $EndPointURLDummy + "/soap/"
  332. $EndPointURL = $EndPointURLTemp.ToString().Replace("200 ","")
  333. if($EndPointURL -eq $null -or $EndPointURL -eq "")
  334. {
  335. Write-Host -ForegroundColor Red "EndPoint URL is not valid, terminating the execution..."
  336. Return
  337. }
  338. if($UserOption -eq 2)
  339. {
  340. $BJReportPath = $ScriptPath + "\" + "SharePointFarm_BoldonJamesActivation_" + $ScriptDate + "_" + $ScriptTime + ".csv"
  341. "Site URL`tBJ EndPoint Applied?" | Out-File $BJReportPath
  342. $WebApplications = Get-SPWebAppllication -ErrorAction SilentlyContinue
  343. if($WebApplications.Count -ge 1)
  344. {
  345. $WebAppsCount = $WebApplications.Count
  346. ForEach($WebApplication in $WebApplications)
  347. {
  348. $WebAppCounter++
  349. $SiteCollections = Get-SPSite -Limit All -WebApplication $WebApplication -ErrorAction SilentlyContinue
  350. $SiteCollectionsCount = ($SiteCollections | Measure).Count
  351. if($SiteCollectionsCount -ge 1)
  352. {
  353. ForEach($RootSite in $SiteCollections)
  354. {
  355. $SiteCounter++
  356. Write-Host -ForegroundColor DarkMagenta "Processing site no. " -NoNewline
  357. Write-Host -ForegroundColor Cyan "$siteCounter out of $SiteCollectionsCount " -NoNewline
  358. Write-Host -ForegroundColor Magenta " in Web App $WebAppCounter out of $WebAppsCount `r"
  359. #$ApplyResult = ApplyBoldonJamesServiceEndPoint $RootSite.URL $EndPointURL
  360. $ApplyResult = ApplyEndPointUsingIE $EndPointURL $RootSite.URL
  361. if($ApplyResult[0] -eq $true -and $ApplyResult[1] -eq $True)
  362. {
  363. $SuccessCount++
  364. $RootSite.URL + "`tTrue`tTrue" | Out-File $BJReportPath -Append
  365. }
  366. elseif($ApplyResult[0] -eq $true -and $ApplyResult[1] -eq $false)
  367. {
  368. $FailedCount++
  369. $RootSite.URL + "`tTrue`tFalse" | Out-File $BJReportPath -Append
  370. }
  371. elseif($ApplyResult[0] -eq $false -and $ApplyResult[1] -eq $true)
  372. {
  373. $FailedCount++
  374. $RootSite.URL + "`tFalse`tTrue" | Out-File $BJReportPath -Append
  375. }
  376. elseif($ApplyResult[0] -eq $false -and $ApplyResult[1] -eq $false)
  377. {
  378. $FailedCount++
  379. $RootSite.URL + "`tFalse`tFalse" | Out-File $BJReportPath -Append
  380. }
  381. }
  382. }
  383. else
  384. {
  385. Write-Host -ForegroundColor Red "No site collection found in the web application...."
  386. }
  387. }
  388. }
  389. else
  390. {
  391. Write-Host -ForegroundColor Red "No web application found in the farm, terminating the execution.."
  392. }
  393. }
  394. elseif($UserOption -eq 1)
  395. {
  396. $WebAppAccepted = $false
  397. while($WebAppAccepted -ne $true)
  398. {
  399. $WebAppURL = Read-Host -Prompt "Please Enter Web Application URL"
  400. if(($WebApplication = Get-SPWebApplication $WebAppURL -ErrorAction SilentlyContinue) -ne $null)
  401. {
  402. Write-Host -ForegroundColor Green "Web Application URL has been accepted..."
  403. $WebAppTitle = $WebApplication.Name.ToString().Replace(" ","_")
  404. $WebAppAccepted = $true
  405. }
  406. else
  407. {
  408. Write-Host -ForegroundColor Red "Invalid input, please provide valid Web Application URL"
  409. }
  410. }
  411. if($WebAppAccepted -eq $true)
  412. {
  413. $BJReportPath = $ScriptPath + "\" + "WebApplication_" + $WebAppTitle + "_BoldonJamesActivation_" + $ScriptDate + "_" + $ScriptTime + ".csv"
  414. "Site URL`tFeature Activated?`tEndPoint Applied?" | Out-File $BJReportPath
  415. $SiteCollections = Get-SPSite -Limit All -WebApplication $WebApplication -ErrorAction SilentlyContinue
  416. $SiteCollectionsCount = ($SiteCollections | Measure).Count
  417. if($SiteCollectionsCount -ge 1)
  418. {
  419. ForEach($RootSite in $SiteCollections)
  420. {
  421. $SiteCounter++
  422. Write-Host -ForegroundColor DarkMagenta "Processing site no. " -NoNewline
  423. Write-Host -ForegroundColor Cyan "$siteCounter out of $SiteCollectionsCount "
  424. #$ApplyResult = ApplyBoldonJamesServiceEndPoint $RootSite.URL $EndPointURL
  425. $ApplyResult = ApplyEndPointUsingIE $EndPointURL $RootSite.URL
  426. if($ApplyResult[0] -eq $true -and $ApplyResult[1] -eq $True)
  427. {
  428. $SuccessCount++
  429. $RootSite.URL + "`tTrue`tTrue" | Out-File $BJReportPath -Append
  430. }
  431. elseif($ApplyResult[0] -eq $true -and $ApplyResult[1] -eq $false)
  432. {
  433. $FailedCount++
  434. $RootSite.URL + "`tTrue`tFalse" | Out-File $BJReportPath -Append
  435. }
  436. elseif($ApplyResult[0] -eq $false -and $ApplyResult[1] -eq $true)
  437. {
  438. $FailedCount++
  439. $RootSite.URL + "`tFalse`tTrue" | Out-File $BJReportPath -Append
  440. }
  441. elseif($ApplyResult[0] -eq $false -and $ApplyResult[1] -eq $false)
  442. {
  443. $FailedCount++
  444. $RootSite.URL + "`tFalse`tFalse" | Out-File $BJReportPath -Append
  445. }
  446. }
  447. }
  448. else
  449. {
  450. Write-Host -ForegroundColor Red "No site collection found in the web application...."
  451. }
  452. }
  453. }
  454. elseif($UserOption -eq 0)
  455. {
  456. $SiteAccepted = $false
  457. while($SiteAccepted -ne $true)
  458. {
  459. $SiteCollURL = Read-Host -Prompt "Please Enter Site Collection URL"
  460. if(($SiteCollection = Get-SPSite $SiteCollURL -ErrorAction SilentlyContinue) -ne $null)
  461. {
  462. Write-Host -ForegroundColor Green "Site Collection URL has been accepted..."
  463. $SiteTitle = $SiteCollection.RootWeb.Name.ToString().Replace(" ","_")
  464. $SiteAccepted = $true
  465. }
  466. else
  467. {
  468. Write-Host -ForegroundColor Red "Invalid input, please provide valid Site Collection URL"
  469. }
  470. }
  471. if($SiteAccepted -eq $true)
  472. {
  473. $SiteCounter++
  474. #Write-Host "Calling function to activate Boldon James"
  475. #$ApplyResult = ApplyBoldonJamesServiceEndPoint $SiteCollURL $EndPointURL
  476. $ApplyResult = ApplyEndPointUsingIE $EndPointURL $SiteCollection.URL
  477. if($ApplyResult[0] -eq $true -and $ApplyResult[1] -eq $True)
  478. {
  479. $SuccessCount++
  480. Write-Host -ForegroundColor Magenta "Feature Activation: " -NoNewline
  481. Write-Host -ForegroundColor Green "Passed"
  482. Write-Host -ForegroundColor Magenta "Applying EndPoint: " -NoNewline
  483. Write-Host -ForegroundColor Green "Passed"
  484. }
  485. elseif($ApplyResult[0] -eq $true -and $ApplyResult[1] -eq $false)
  486. {
  487. $FailedCount++
  488. Write-Host -ForegroundColor Magenta "Feature Activation: " -NoNewline
  489. Write-Host -ForegroundColor Green "Passed"
  490. Write-Host -ForegroundColor Magenta "Applying EndPoint: " -NoNewline
  491. Write-Host -ForegroundColor Red "Failed"
  492. }
  493. elseif($ApplyResult[0] -eq $false -and $ApplyResult[1] -eq $true)
  494. {
  495. $FailedCount++
  496. Write-Host -ForegroundColor Magenta "Feature Activation: " -NoNewline
  497. Write-Host -ForegroundColor Red "Failed"
  498. Write-Host -ForegroundColor Magenta "Applying EndPoint: " -NoNewline
  499. Write-Host -ForegroundColor Green "Passed"
  500. }
  501. elseif($ApplyResult[0] -eq $false -and $ApplyResult[1] -eq $false)
  502. {
  503. $FailedCount++
  504. Write-Host -ForegroundColor Magenta "Feature Activation: " -NoNewline
  505. Write-Host -ForegroundColor Red "Failed"
  506. Write-Host -ForegroundColor Magenta "Applying EndPoint: " -NoNewline
  507. Write-Host -ForegroundColor Red "Failed"
  508. }
  509. }
  510. #$BJReportPath = $ScriptPath + "\" + "SiteCollection_" + $SiteTitle + "_BoldonJamesActivation_" + $ScriptDate + "_" + $ScriptTime + ".csv"
  511. }
  512. Write-Host -ForegroundColor Green "Script execution completed..."
  513. Write-Host -ForegroundColor Magenta "Please find below summary:"
  514. Write-Host -ForegroundColor Cyan "Total no. of sites processed: $siteCounter"
  515. Write-Host -ForegroundColor Green "No. of sites successful: $successCount"
  516. Write-Host -ForegroundColor Yellow "No of sites failed: $failedCount"
  517. if($UserOption -eq 1 -or $UserOption -eq 2)
  518. {
  519. Write-Host -ForegroundColor DarkCyan "Find the detailed report at $BJReportPath ..."
  520. }
  521. Write-Host -ForegroundColor Cyan "=================================================="
  522. }
  523. else
  524. {
  525. Write-Host -ForegroundColor Red "Scope selection was not valid, terminating the exectuion..."
  526. Return
  527. }
  528. }
  529. else
  530. {
  531. Write-Host -ForegroundColor Red "SharePoint Snapin could not be loaded, terminating the execution..."
  532. }
  533. #$url= Read-Host 'Enter the Site Collection URL'
  534. #$SCServiceEndpointurl= Read-Host 'Enter the SharePoint Classifier Service Endpoint URL'

Note

Before running the script, change the domain at line 136 in the script [shown below].

$myDomain = “yourdomain.com”

Inputs

  1. The script prompts for the first input, which is selecting scope. It provides us 3 options, namely Site, Web Application and Farm. Based on the need, we can select the appropriate option.

  2. Next input required is Boldon James Classifier Web Service URL. We need to provide URL till .svc. For example - http://bj-classifier.domain.com:8080/ClassifierWCFService/ClassifierWCFService.svc

  3. Third input will be asked, if we select an option “Site” or “Web Application” for the first input. If the option selected was “Site”, it will ask for the site collection URL and if “Web Application” was selected, it will ask for Web Application URL.

If we provide any invalid input, the script will prompt again, until it receives a valid input. Once it receives all the valid inputs, it will take care of remaining task and upon the completion of execution, it will show us the summary. For more detailed reports [if we selected “Site” or “Web Application” option], it will generate a CSV file in the same directory, where the script is placed and display the path of the output CSV in PowerShell Window.

That’s it. We can just go to site collection and verify whether it did the job or not.

I’m currently working on preparing the script for applying the endpoint on the document libraries and shall be posting, once it’s ready.

Thanks for reading and using the script.