当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 使用 PowerShell 在 SharePoint Online 中创建现代网站集

作者:精品下载站 日期:2024-12-14 15:36:19 浏览:13 分类:玩电脑

使用 PowerShell 在 SharePoint Online 中创建现代网站集


要求:使用 PowerShell 在 SharePoint Online 中创建现代网站集。

如何在 SharePoint Online 中创建现代团队网站?

SharePoint Online 现代团队网站允许人们一起工作、协作以及共享文档和消息。它们凭借直观的设计、针对移动设备优化的响应式 UI 以及更快的页面加载速度,提供了全新的用户体验。默认情况下,当您在 SharePoint Online 管理中心创建网站时,它会创建一个具有关联 Office 365 组的新式团队。如何在 SharePoint Online 中创建现代网站集?那么,要创建现代 SharePoint Online 网站集,请按照下列步骤操作:

  1. 以租户管理员或 SharePoint Online 管理员身份登录新 SharePoint 管理中心。
  2. 单击左侧导航中的站点 >> 活动站点 >> 单击“创建”。
  3. 单击“团队网站”在 SharePoint Online 中创建现代团队网站。

    [玩转系统] 使用 PowerShell 在 SharePoint Online 中创建现代网站集

  4. 提供网站名称、URL 和组所有者选项,然后单击“完成”以在 SharePoint Online 中创建新式网站集。

    [玩转系统] 使用 PowerShell 在 SharePoint Online 中创建现代网站集

  5. 要设置隐私设置和语言,您可以展开“高级设置”并选择站点的隐私,无论是私有站点还是组织中每个人都可以访问的公共站点。然后,单击“下一步”按钮。

    [玩转系统] 使用 PowerShell 在 SharePoint Online 中创建现代网站集

稍等片刻,您的网站集应该出现在网站集列表中。具有关联 Microsoft 365 组的现代团队网站,已成功创建 Planner、共享日历等服务。

顺便说一句,您也可以从 SharePoint Online 起始页创建新的网站集 (https://.sharepoint.com/_layouts/15/sharepoint.aspx)。现在,让我们看看如何使用 PowerShell 在 SharePoint Online 中创建一个没有组的现代团队网站。

SharePoint Online:使用 PowerShell 创建现代团队网站集

SharePoint Online PowerShell cmdlet 是自动执行日常任务的好方法。您可以轻松创建网站集、移动网站集或批量配置网站。它是一个非常强大的工具,可以让您在更短的时间内做更多的事情。在本例中,您可以通过将网站模板指定为“STS#3”,在 SharePoint Online 中创建现代网站集:


#Connect to SharePoint Online
Connect-SPOService -url "https://crescent-admin.sharepoint.com" -Credential (Get-credential)
  
#Create a modern team site
New-SPOSite -Url "https://crescent.sharepoint.com/sites/Purchase" -Owner "[email protected]" -StorageQuota 2048 -Title "Purchase Team Site" -Template "STS#3"

使用 PowerShell 在 SharePoint Online 中创建现代网站集

SharePoint 现代团队网站允许您与组织中的团队共享信息。您可以使用团队网站来存储和协作处理文件以及管理信息列表。让我们在 SharePoint Online 中使用 PowerShell 创建一个具有现代体验的新团队网站:


#PowerShell to create modern site collection
Function Create-SPOSite
{
  param
    (
        [string]$Title  = $(throw "Please Provide the Site Title!"),
        [string]$URL = $(throw "Please Provide the Site URL!"),
        [string]$Owner = $(throw "Please Provide the Site Owner!"),
        [int]$StorageQuota = $(throw "Please Provide the Site Storage Quota!")
    )
 
#Connection parameters 
$AdminURL = "https://crescent-admin.sharepoint.com"
$AdminName = "[email protected]"
  
Try{
    #Connect to Office 365
    Connect-SPOService -Url $AdminURL -Credential (Get-Credential)
  
    #Check if the site collection exists already
    $SiteExists = Get-SPOSite | Where {$_.URL -eq $URL}
    
    #Check if the site exists in the recycle bin
    $SiteExistsInRecycleBin = Get-SPODeletedSite | where {$_.url -eq $URL}
 
    If($SiteExists -ne $null)
    {
        write-host "Site $($url) exists already!" -foregroundcolor Yellow
    }
    elseIf($SiteExistsInRecycleBin -ne $null)
    {
        write-host "Site $($url) exists in the recycle bin!" -foregroundcolor Yellow
    }
    else
    {
        #sharepoint online create modern site collection powershell
        New-SPOSite -Url $URL -title $Title -Owner $Owner -StorageQuota $StorageQuota -NoWait -ResourceQuota $ResourceQuota -Template $Template
        write-host "Site Collection $($url) Created Successfully!" -foregroundcolor Green
    }
}
catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
    }
}
 
#Parameters to create new site collection
$SiteTitle = "Purchase"
$SiteURL= "https://crescent.sharepoint.com/sites/purchase"
$SiteOwner = "[email protected]"
$StorageQuota = 2048
$SiteTemplate = "STS#3"
 
#Call The function to create site collection in SharePoint Tenant
Create-SPOSite -Title $SiteTitle -URL $SiteURL -Owner $SiteOwner -StorageQuota $StorageQuota -Template $SiteTemplate

如果要在 SharePoint Online 中创建经典网站,请使用:在 SharePoint Online 中创建经典网站

PnP PowerShell 创建现代网站

如果要使用 Office 365 组创建新的现代团队网站集,请使用 SharePoint Online 中 PnP PowerShell 的 New-PnPSite cmdlet。确保在创建新的 SharePoint 网站集之前安装了 PnP PowerShell 模块。


New-PnPSite -Type TeamSite -Title "Test Modern TeamSite" -Alias TestModernTeamSite -IsPublic

让我们将其包装在一个函数中,并向 PnP PowerShell 脚本添加一些错误处理,以便为您的 SharePoint 环境创建一个现代网站:


#Define Variables
$AdminCenterURL = "https://crescent-Admin.sharepoint.com"
$SiteURL = "https://crescent.sharepoint.com/sites/procurement2"
$SiteTitle = "crescent Procurement Portal"
$SiteOwner = "[email protected]"
$Template = "STS#3" #Modern Team Site
$Timezone = 24 #GMT+4
 
Try
{
    #Connect to Tenant Admin
    Connect-PnPOnline -URL $AdminCenterURL -Interactive
     
    #Check if site exists already
    $Site = Get-PnPTenantSite | Where {$_.Url -eq $SiteURL}
 
    If ($Site -eq $null)
    {
        #sharepoint online pnp powershell create site collection
        New-PnPTenantSite -Url $SiteURL -Owner $SiteOwner -Title $SiteTitle -Template $Template -TimeZone $TimeZone -RemoveDeletedSite
        write-host "Site Collection $($SiteURL) Created Successfully!" -foregroundcolor Green
    }
    else
    {
        write-host "Site $($SiteURL) exists already!" -foregroundcolor Yellow
    }
}
Catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
} 

如何在没有 Microsoft 365 组的情况下创建现代团队网站? SharePoint Online:创建无组的现代团队网站

包起来

总之,创建现代 SharePoint Online 网站是改善用户体验、协作和工作效率的有效方法。通过使用 SharePoint Online 用户界面或 PowerShell,管理员可以轻松创建移动响应、易于使用且具有视觉吸引力的现代网站。创建现代 SharePoint Online 网站的过程相对简单,只需单击几下或使用几行代码即可完成。

经常问的问题:

如何在 SharePoint Online 中将团队网站转换为通信网站?

您可以使用“Enable-SPOCommSite”PowerShell cmdlet 将经典团队站点转换为通信站点。但是,您无法将现代团队网站或连接到 Microsoft 365 组的网站转换为现代通信网站。不过,如果您需要全角页面,则只需禁用快速启动即可。
更多信息:SharePoint Online:将团队网站转换为通信网站

如何将根站点转换为通信站点?

除了使用 PowerShell 启用通信站点功能之外,您还可以创建新的通信站点并使用“Invoke-SPOSiteSwap”cmdlet 将其与根站点 (https://YourDomain.SharePoint.com) 交换。
更多信息:将根网站转换为 SharePoint Online 中的通信网站

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯