首页 > 解决方案 > 使用 PowerShell 检索视频库中的项目

问题描述

我想检索 SharePoint 上视频库中的所有项目,并获取所有者/创建者列表以及我无法仅定位视频的所有内容。

我能够提取所有文档库
在此处输入图像描述

如何仅从视频库中提取项目?
在此处输入图像描述

这是我目前拥有的:

# Add SharePoint Snapin to PowerShell
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
  Add-PSSnapin Microsoft.SharePoint.PowerShell
}
$web = Get-SPWeb "http://sourcevideo.f.com"
$Data = foreach ($list in $web.Lists) {
        if ($list.BaseType -eq “DocumentLibrary”) {
            foreach ($item in $list.Items) {
                foreach($version in $item.Versions){
                $data = @{
                        "Version" = $version.VersionLabel
                        "List Name" = $list.Title
                        "Created By" = $item["Author"]
                        "Created Date" = $item["Created"]
                        "Modified By" = $item["Editor"]
                        "Modified Date" = $item["Modified"]
                        "Item Name" = $item.File.Name
                        "URL"=$web.Site.MakeFullUrl("$($web.ServerRelativeUrl.TrimEnd('/'))/$($item.Url)");
                }
                New-Object PSObject -Property $data | Select "List Name", "Item Name", "Version", "Created By", "Created Date", "Modified By", "Modified Date", "URL"
                }
            }
            $web.Dispose();
        }
    }
$Data  |  Export-Csv C:\Users\ptadmin\Desktop\process7.csv -NoTypeInformation

标签: htmlshellpowershellsharepoint

解决方案


您可以检查包含 mp4 的文件扩展名是否像这样:

# Add SharePoint Snapin to PowerShell                                        
# $_.extension -eq $FileExtension
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
  Add-PSSnapin Microsoft.SharePoint.PowerShell
}
$web = Get-SPWeb "http://sp:12001/"
$Data = foreach ($list in $web.Lists["MyDoc"]) {
        if ($list.BaseType -eq "DocumentLibrary"){
            #if ($item -Like "*.mp4"){
                foreach ($item in $list.Items) {
                $fileExtension= $item.File.Name.Split('.')[1]
                if($fileExtension -eq 'mp4'){
                    $data = @{
                        "List Name" = $list.Title
                        "Created By" = $item["Author"]
                        "Created Date" = $item["Created"]
                        "Modified By" = $item["Editor"]
                        "Modified Date" = $item["Modified"]
                        "Item Name" = $item.File.Name                       
                        "URL"=$web.Site.MakeFullUrl("$($web.ServerRelativeUrl.TrimEnd('/'))/$($item.Url)");
                        }
                    New-Object PSObject -Property $data | Select "List Name", "Item Name", "Created By", "Created Date", "Modified By", "Modified Date", "URL"
                #}
                }
            }

        }
        $web.Dispose()
    }

推荐阅读