Advertisement
Guest User

Untitled

a guest
Apr 26th, 2016
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. function Set-SPOTheme{
  2. Param(
  3. [Parameter(Mandatory=$true)]$ctx,
  4. [Parameter(Mandatory=$true)]$spColorUrl,
  5. [Parameter(Mandatory=$true)]$shareGenerated,
  6. [string]$spFontUrl,
  7. [string]$backGroudUrl
  8. )
  9. try{
  10. write-host "Applying the theme to the site. " -NoNewline
  11.  
  12. $spFontUrlAux = Out-Null #Needs to be set to Out-Null is empty
  13. If(![string]::IsNullOrEmpty($spFontUrl)){
  14. $spFontUrlAux = $spFontUrl
  15. } else {
  16.  
  17. }
  18.  
  19. $backGroudUrlAux = Out-Null #Needs to be set to Out-Null is empty
  20. If(![string]::IsNullOrEmpty($backGroudUrl)) {
  21. $backGroudUrlAux = $backGroudUrl
  22. }
  23.  
  24. $web = $ctx.Web
  25. $web.ApplyTheme($spColorUrl, $spFontUrlAux, $backGroudUrlAux, $shareGenerated)
  26. $ctx.Load($web)
  27. $ctx.executeQuery()
  28. write-host " done." -ForegroundColor Green
  29. }
  30. catch{
  31. write-host "Error While applying the theme $($_.Exception.Message)" -foregroundcolor red
  32. }
  33.  
  34. }
  35.  
  36. Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
  37. Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
  38.  
  39. $siteUrl = Read-Host -Prompt "Provide the URL"
  40. $adminUsername = Read-Host -Prompt ("Provide user for {0}" -f $siteUrl)
  41. $secureAdminPassword = Read-Host -Prompt ("Provide password for {0}" -f $adminUsername) -AsSecureString
  42.  
  43. $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($adminUsername, $secureAdminPassword)
  44. $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
  45. $ctx.Credentials = $credentials
  46.  
  47. #Sets only the Theme Colours
  48. Set-SPOTheme $ctx "/_catalogs/theme/15/palette010.spcolor"
  49.  
  50. #Sets the Theme Colours and the fonts
  51. Set-SPOTheme $ctx "/_catalogs/theme/15/palette015.spcolor" $true "/_catalogs/theme/15/fontscheme001.spfont"
  52.  
  53. #Sets the Theme Colours and the Image Background
  54. Set-SPOTheme $ctx "/_catalogs/theme/15/palette010.spcolor" $true $null "/_layouts/15/images/image_bg006.jpg"
  55.  
  56. #Sets the Theme Colours, the fonts and the Image Background
  57. Set-SPOTheme $ctx "/_catalogs/theme/15/palette015.spcolor" $true "/_catalogs/theme/15/fontscheme003.spfont" "/_layouts/15/images/image_bg005.jpg"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement