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

[玩转系统] SharePoint Online:使用 PowerShell 更改欢迎页面

作者:精品下载站 日期:2024-12-14 14:16:23 浏览:14 分类:玩电脑

SharePoint Online:使用 PowerShell 更改欢迎页面


要求:在 SharePoint Online 中使用 PowerShell 设置主页。

如何更改 SharePoint Online 中的欢迎页面?

您是否曾经想要更改 SharePoint Online 中的欢迎页面?这实际上是一个非常简单的过程,本指南将引导您完成它。请记住,您必须是网站集管理员才能进行更改。让我们开始吧!

要在 SharePoint Online 中设置欢迎页面,请导航至:

  1. 设置>>站点设置>>点击外观下的“欢迎页面”
  2. 使用浏览按钮或直接键入网站上的任何现有页面来更改欢迎页面。

    [玩转系统] SharePoint Online:使用 PowerShell 更改欢迎页面

  3. 单击“确定”保存更改。

就这样!通过这些步骤,您可以将任何自定义页面指定为网站的新欢迎页面。

PowerShell 更改 SharePoint Online 欢迎页面:

使用此 PowerShell 脚本更改 SharePoint Online 网站的欢迎页面。


#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
  
#Set Variables for Site URL
$SiteURL= "https://crescent.sharepoint.com/sites/sales/"
$WelcomePage="SitePages/Default.aspx" #Relative path to site

#Setup Credentials to connect
$Cred = Get-Credential
$Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)

Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Cred

    #Set welcome page in SharePoint Online
    $Ctx.web.RootFolder.WelcomePage =$WelcomePage
    $Ctx.web.RootFolder.Update()
    $ctx.ExecuteQuery()
        
    Write-host -f Green "Welcome page updated!" 
}
Catch {
    write-host -f Red "Error setting welcome page!" $_.Exception.Message
}

若要使用 PnP PowerShell 在 SharePoint Online 现代网站中设置欢迎页面,请参阅如何使用 PowerShell 更改 SharePoint Online 中的主页?

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

取消回复欢迎 发表评论:

关灯