1

I'm wanting to retrieve all items within a Video Library on SharePoint and grab the owners/Created By list and all that I haven't been able to target videos only.

I'm able to pull in all of the document libraries:
enter image description here

How do I pull items in only from the Video library?
enter image description here

Here is what I currently have:

# 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 

1 Answer 1

3

Right now you are iterating all lists that has the base type "Document Library".

If you want to target a specific library you should use the method "Get-SPList" instead of the first for-loop.

$list = Get-SPList -ListName "Video" -Web $web 

If you don't have the get-splist cmdlet use this

$list = $web.Lists["Video"] 

[Check if the file extension is .mp4]

if($item.File.Name.EndsWith(".mp4")) 

Good luck :)

3
  • Thanks so much Fredrik! This worked like a charm, is there a way that I can grab only the .mp4's? It's currently grabbing all files even the thumbnails. I have this if ($item.extension -eq "*mp4*"){ but it's not working well. Commented Jan 16, 2019 at 20:00
  • 1
    @SaintLouisEvents, yes. You can find the file information on $item.File and to get the name, including the extension, you can use $item.File.Name. Use this to filter out the extensions with PowerShell. Commented Jan 16, 2019 at 20:59
  • 1
    @SaintLouisEvents, added a row to my answer to check if the extension is ".mp4". Please mark as Answer if you are pleased. Cheers. Commented Jan 16, 2019 at 21:10

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.