html - 使用 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
解决方案
您可以检查包含 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()
}
推荐阅读
- outlook - 在 Exchange Online 中自动填充共享日历
- laravel - Laravel nova - 指定镜头的资源与执行镜头的资源无关
- database - typeorm 创建表时不区分数据库
- javascript - 导出时如果excel中有超过65000行,如何保存第二个文件-XLSX
- amazon-web-services - Terraform 对象默认值列表
- python - 如何制作每个点代表 3d 角度的 2D 颜色图?
- wordpress - 为自定义帖子类型激活 WPBakery 自定义 CSS?
- android - 带有 ID 的 Retrofit2 GET 请求
- c++ - 为什么我不能比较 s,或者设置等于字符串 s 的值?
- c# - Autofac 无法解析 Microsoft.Office.Interop.Word.Application