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

[玩转系统] SharePoint Online:如何使用 PowerShell 隐藏列表或库?

作者:精品下载站 日期:2024-12-14 21:02:50 浏览:17 分类:玩电脑

SharePoint Online:如何使用 PowerShell 隐藏列表或库?


要求:隐藏 SharePoint Online 网站中的列表或库。

[玩转系统] SharePoint Online:如何使用 PowerShell 隐藏列表或库?

如何通过设置权限向用户隐藏 SharePoint 列表?

您还可以通过设置权限来隐藏 SharePoint Online 列表或文档库,以便只有特定用户可以访问它。

  1. 转至列表或库设置页面 >> 单击此列表的权限链接。
  2. 单击“停止继承权限”按钮。这将中断从父站点的权限继承,并且您将能够为列表或库设置唯一的权限。
  3. 最后,仅添加应有权访问列表或库的用户,并删除所有其他用户。

完成这些更改后,列表或库将对所有无权访问的用户隐藏。顺便说一句,具有管理员权限的用户将能够查看和访问隐藏列表或库!有关设置对 SharePoint 列表或文档库的唯一权限的详细信息:SharePoint Online:使用 PowerShell 授予对列表或库的权限

SharePoint Online:使用 PowerShell 隐藏文档库

我们希望在自定义应用程序的 SharePoint Online 中隐藏配置列表,以防止编辑或删除。如何在 SharePoint Online 中隐藏列表?有多种方法可以隐藏 SharePoint Online 列表。以下是用于在 SharePoint Online 中创建隐藏列表的 PowerShell CSOM 脚本:


#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"
  
#Config Parameters
$SiteURL= "https://crescent.sharepoint.com/sites/sales/"
$LibraryName="ProjectConfig"

#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
  
    #Get the web and Library
    $Web=$Ctx.Web
    $List=$web.Lists.GetByTitle($LibraryName)

    #Hide the list
    $List.Hidden = $True
    $List.Update()
    $Ctx.ExecuteQuery()
     
    Write-host -f Green "List hidden Successfully!"
}
Catch {
    write-host -f Red "Error hiding List: " $_.Exception.Message
}

尽管该列表在网站内容页面中是隐藏的,但列表中的所有内容都将照常工作,并且您仍然可以通过列表 URL 访问它。

SharePoint Online:使用 PnP PowerShell 隐藏列表

执行此脚本后,给定列表将立即从站点内容页面隐藏。但是,可以通过 URL 访问该列表,并且该列表上的所有操作都将照常进行。以下是对所有用户隐藏 SharePoint 列表的方法:


#Config Variables
$SiteURL = "https://Crescent.sharepoint.com/Sales"
$ListName ="AppConfig"

#Connect PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive

#SharePoint Online Hide a List
Set-PnPList -Identity $ListName -Hidden $True

要使列表再次可见,只需将“隐藏”标志的值设置为“False”即可。我们不能直接在SharePoint Online中创建隐藏列表,但我们可以在添加后将其属性设置为隐藏。

使用 SharePoint Designer 的 SharePoint Online 隐藏列表

我们还可以使用 SharePoint Designer 来标记对浏览器隐藏的列表。在此处阅读更多信息:如何在 SharePoint 中隐藏列表?

[玩转系统] SharePoint Online:如何使用 PowerShell 隐藏列表或库?

如何查看 SharePoint Online 中的隐藏列表?

SharePoint Online 及其应用程序使用某些隐藏列表存储配置数据。例如,“访问请求”、“组合外观”、“用户信息列表”等。要获取 SharePoint Online 中的所有隐藏列表,请使用以下 PowerShell 脚本:


#Connect to PnP Online
Connect-PnPOnline -Url "https://crescent.sharepoint.com/sites/marketing" -Interactive

#Get Hidden Lists and Libraries
Get-PnPList | Where { $_.Hidden -eq $true}

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

取消回复欢迎 发表评论:

关灯