Sunday, February 22, 2015

Updating the SharePoint Online site logo with power shell code

In order to update the site logo for a Office 365 SharePoint site below code snippet can be used. I had used a SharePoint office 365 developer site to change the site logo.

$credential=Get-Credential
$username=$credential.UserName
$password=$credential.GetNetworkCredential().Password
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$url = "https://spk0365.sharepoint.com/sites/PradeepLearning"

 ### References # Specify the path where the dll's are located.
 Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
 Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

 $clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($url)
 $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePassword)
 $clientContext.Credentials = $credentials
 #Get the SharePoint Web
 $web=$clientContext.Web;
 $web.SiteLogoUrl="https://spk0365.sharepoint.com/sites/PradeepLearning/SiteAssets/team-india-630-new-odi-kit.jpg";
 $web.Update();
 $clientContext.Load($web);
 $clientContext.ExecuteQuery();

No comments:

Post a Comment