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

[玩转系统] PowerShell 管理 SharePoint 中没有签入版本的文件

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

PowerShell 管理 SharePoint 中没有签入版本的文件


要求: PowerShell 用于管理 SharePoint 中没有签入版本的文件。

如何在SharePoint 2016中管理没有签入版本的文件?

当通过资源管理器视图或多个文件上传上传文件时 - 未提供强制列值或将“需要签出”选项设置为“是”时,该文件将变为“没有签入版本的文件”!

这些没有签入版本的文件不会向任何其他用户显示,甚至不会向管理员显示 - 直到上传者签入它们为止。作为管理员,您可以使用“管理那些文件”来控制这些文件。库设置中没有签入版本”链接。

如何控制未签入版本的文件?

管理签出文件页面为您提供了已上传到文档库但从未签入的所有文档的列表。具有完全控制访问权限的任何用户都可以拥有这些文档的所有权,根据需要提供元数据并签入文档使它们可供所有用户使用。

  1. 转到文档库设置 >> 单击权限和管理组下的“管理没有签入版本的文件”链接。
  2. 通过选中每个文件中的复选框来选择“文件签出给其他人:”下的文件。
  3. 单击“取得所选内容的所有权”并确认提示“您确定要取得文件名的所有权吗”。
  4. 这使得该文件可供您使用。现在,转到文档库并签入文件。
  5. 您可能必须提供强制性元数据或添加签入评论。一旦他们签入,每个人都可以看到他们。

[玩转系统] PowerShell 管理 SharePoint 中没有签入版本的文件

PowerShell 用于管理 SharePoint 文档库中没有签入版本的文件:

让我们获得所有签出文件的所有权并使用 PowerShell 签入它们。


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
  
#Variables
$WebURL="https://intranet.crescent.com"
$ListName="Documents"
 
#Get Objects
$Web = Get-SPWeb $WebURL
$List = $web.Lists.TryGetList($ListName)
 
If($List -ne $Null)
{
    #Get Checked out files with no checked in versions
    $CheckedOutFiles = $List.CheckedOutFiles

    Write-host "Total Number of Files with No Checkin version:"$CheckedOutFiles.count

    #Loop through each checked out File
    ForEach ($File in $CheckedOutFiles) 
    {
        Write-Host -f Yellow "'$($File.LeafName)' at $($File.Url) is Checked out by: $($File.CheckedOutByName)"
        
        #Take ownership
        $File.TakeOverCheckOut()
        #Check in
        $List.GetItemById($File.ListItemId).File.Checkin("Checked in by Administrator")
        Write-host -f Green "Took Ownership and Checked in the File!"
    }
}
else
{
    Write-Host -f Yellow "List '$ListName' Does not Exist!"
}

SharePoint PowerShell 管理未签入版本的文件

让我们稍微扩展一下脚本,以签入 SharePoint 网站集级别中未签入版本的所有文档。此 PowerShell 查找没有签入版本的文件,获取所有权并将其签入。


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
  
#Site Collection Variable
$SiteURL="https://intranet.crescent.com"
 
#Get the Site Collection
$Site = Get-SPSite $SiteURL

#Loop through each sub-site of the site collection
ForEach($Web in $Site.AllWebs)
{
    Write-host -f Yellow "Searching for Checked out Files in Web:" $Web.Url
    #Loop through each list
    ForEach($List in $Web.Lists)
    {
            #Get Checked out files with no checkin versions
            $CheckedOutFiles = $List.CheckedOutFiles

            #Loop through each checked out File
            ForEach ($File in $CheckedOutFiles) 
            {
                Write-Host -f Yellow "`t '$($File.LeafName)' at $($File.Url) is Checked out by: $($File.CheckedOutByName)"
        
                #Take ownership of the file
                $File.TakeOverCheckOut()
                
                #Check in the file
                $List.GetItemById($File.ListItemId).File.Checkin("Checked in by Administrator")
                Write-host -f Green "`t Took Ownership and Checked in the File!"
            }
    }
}

总之,我们讨论了如何管理 SharePoint 中没有签入版本的文件。按照此处提供的脚本,您可以识别需要签入的文件、将其签入或放弃签出,并通知用户。

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

取消回复欢迎 发表评论:

关灯