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
                New-Object PSObject -Property $data | Select "List Name", "Item Name", "Version", "Created By", "Created Date", "Modified By", "Modified Date", "URL"
$Data  |  Export-Csv C:\Users\ptadmin\Desktop\process7.csv -NoTypeInformation

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]


Good luck :)

  • 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. – SLE Jan 16 '19 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. – Fredrik Svensson Jan 16 '19 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. – Fredrik Svensson Jan 16 '19 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.