【发布时间】:2019-06-11 00:24:58
【问题描述】:
我怎样才能只导出具有 .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://sourcevideo.f.com/"
$Data = foreach ($list in $web.Lists["Video"]) {
if ($list.BaseType -eq “DocumentLibrary”){
#if ($item -Like "*.mp4"){
foreach ($item in $list.Items) {
$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()
}
$Data | Export-Csv C:\Users\ptadmin\Desktop\process9.csv -NoTypeInformation
【问题讨论】:
标签: shell powershell sharepoint powershell-2.0