51CTOBlog链接:https://blog.51cto.com/13969817
博客园Blog Address:https://www.cnblogs.com/bxapollo很多客户都喜欢SharePoint Online的新式通信体验网站构建部门站点,因为这样可以轻松地为网站更改外观,使其适应公司或组织的需求,而且在任何设备上访问网站时都具有良好的响应性和外观,而且目前微软也在积极在新式网站上推送和研发很多新功能,比如多个页眉和页脚,大型菜单之类的导航选项等等,详情请查看Microsoft 365 路线图请添加链接描述。
为了满足业务需求,对于一些使用SharePoint Online比较久的老客户,IT Admin也通过微软最新推出的PowerShell将经典网站启用了新式通信体验的网站,这样就可以避免用户使用经典网站的情况下,为了满足业务部门需要而需要开发人员参与网站功能和导航元素的自定义工作并在母版页、CSS、JavaScript和Web部件方面投入精力。
但再IT启用新式通信网站的命令时,若想自己了解和掌握哪些网站集直接就是新式通信网站创建的,哪些网站集是通过命令调整的,该如何获取启用通信体验的所有经典网站列表?
脚本如下:
function Get-CommsiteEnabledSites{
$adminUrl = Read-Host "Enter the Admin URL of 0365 (eg. https://<Tenant Name>-admin.sharepoint.com)"
$userName = Read-Host "Enter the username of 0365 (eg. admin@<tenantName>.onmicrosoft.com)"
$password = Read-Host "Please enter the password for $($userName)" -AsSecureString
# set credentials
$credentials = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $password
$SPOCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $password)
#connect to to Office 365
try{
Connect-SPOService -Url $adminUrl -Credential $credentials
write-host "Info: Connected succesfully to Office 365" -foregroundcolor green
}
catch{
write-host "Error: Could not connect to Office 365" -foregroundcolor red
Break connectToO365
}
get-siteCollections
}
function get-siteCollections{
write-host "----- List of classic sites with comm site feature enabled -------" -foregroundcolor green
#Get all site collections
$siteCollections = Get-SPOSite#loop through all site collections
foreach ($siteCollection in $siteCollections){
#set variable for a tab in the table
$pixelsweb = 0
$pixelslist = 0
$enabledCommSite = Get-SPOIsCommSiteEnabled($siteCollection.url)
$background = "white"
if($enabledCommSite -ne ""){
$background = "cyan"
}
}
}
function Get-SPOIsCommSiteEnabled($url){
#fill metadata information to the client context variable
$featureID = "f39dad74-ea79-46ef-9ef7-fe2370754f6f"
$context = New-Object Microsoft.SharePoint.Client.ClientContext($url)
$context.Credentials = $SPOcredentials
$web = $context.Web
$context.Load($web)
$context.load($web.Features)
try{
$context.ExecuteQuery()
$isCommSiteEnabled = $web.Features | Where {$_.DefinitionID -eq $featureID}
$webTemplate = $web.WebTemplate
if($webTemplate -ne "SITEPAGEPUBLISHING" -AND $isCommSiteEnabled){
write-host "Found $($web.url)" -foregroundcolor green
return "Enabled"
}
}
catch{
write-host "Could not find web" -foregroundcolor red
}
return ""
}
Get-CommsiteEnabledSites
相关资料:
* Enable-SPOCommSite
精彩评论