Powershell と CSOM を使用して、SharePoint Online サイトにサイト ロゴを設定できた人はいますか? ありがとう
ナイジェル
Powershell と CSOM を使用して、SharePoint Online サイトにサイト ロゴを設定できた人はいますか? ありがとう
ナイジェル
これは、sharepoint 2016でpowershellを使用してデフォルトのsharepointロゴを変更するスクリプトです
$logoLocation= "http://sharepoint2016/SiteAssets/MyCompanyLogo.png"
$oSite=new-object Microsoft.SharePoint.SPSite("http://sharepoint2016/")
foreach($oWeb in $oSite.Allwebs) {
$oWeb.SiteLogoUrl=$logoLocation
$oWeb.Update()
}
UserVoice の要求に従って SiteLogoUrl プロパティを CSOM で使用できるようにし、SharePoint API の改善を促進する UserVoiceを投稿すると、新しいバージョンのSharePoint Online クライアント コンポーネント SDK Web
クラスがSiteLogoUrl
プロパティをサポートします。
Web.SiteLogoUrl property
PowerShell で CSOM を使用して設定する方法:
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
Function Get-SPOCredentials([string]$UserName,[string]$Password)
{
$SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
return New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword)
}
Function Web-SetLogo([Microsoft.SharePoint.Client.ClientContext]$Content,[string]$SiteLogoUrl)
{
$Context.Web.SiteLogoUrl = $SiteLogoUrl
$Context.Web.Update()
$Context.ExecuteQuery()
}
$UserName = "username@contoso.onmicrosoft.com"
$Password = Read-Host -Prompt "Enter the password"
$Url = "https://contoso.sharepoint.com/"
$context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$context.Credentials = Get-SPOCredentials -UserName $UserName -Password $Password
Web-SetLogo -Content $context -SiteLogoUrl "/SiteAssets/ContosoLogo.jpg"
$context.Dispose()