Whether you manage a digital asset library, archive enterprise webinar recordings, or maintain hundreds of video tutorial screen captures, tracking media collections quickly becomes chaotic.
Opening hundreds of nested folders and manually checking file properties is out of the question. Running standard Windows PowerShell commands like Get-ChildItem | Export-Csv only captures surface-level operating system timestamps and byte sizes. Crucial technical metadata—such as the true video codec (H.264, HEVC, AV1), audio tracks, aspect ratios, frame rates, and exact playback runtimes—remains completely hidden inside the media container.
In our earlier guide on automating Excel tasks using ChatGPT and VBA macros and our pipeline for extracting web tables safely into Excel, we emphasized the value of clean, structured data ingestion. In this tutorial, we will build a production-ready, unattended PowerShell pipeline paired with FFprobe that scans entire directory trees and generates a polished, hyperlinked Excel spreadsheet in seconds.
1. Why the Windows Shell Property System Fails at Scale
Many Windows sysadmins attempt to extract video metadata by querying the Windows Explorer Shell COM object (Shell.Application). While functional for a quick desktop script, this method has severe operational limitations:
- Slow COM Instantiation: Querying Shell COM properties requires instantiating an out-of-process COM server for every single file, grinding multi-gigabyte library scans to a crawl.
- Fragile Column Indexes: Shell detail indexes (e.g., column 27 for duration, column 314 for frame rate) change across Windows 10, Windows 11, and Windows Server builds.
- Zero Headless / Container Support: Shell COM fails completely on headless virtual machines, CI runners, or Linux servers.

flowchart LR
A["📂 Media Folder Recursion
Get-ChildItem -Recurse"] --> B["⚙️ Headless FFprobe Stream
JSON Output (-show_streams)"]
B --> C["📊 Object Transformation
Extract Codec, Res, & Duration"]
C --> D["📑 Structured Excel Export
Clickable Hyperlinks & Summary"]
style A fill:#1e293b,stroke:#38bdf8,stroke-width:2px,color:#f8fafc
style B fill:#1e293b,stroke:#a855f7,stroke-width:2px,color:#f8fafc
style C fill:#1e293b,stroke:#f59e0b,stroke-width:2px,color:#f8fafc
style D fill:#064e3b,stroke:#34d399,stroke-width:2px,color:#f8fafc
📋 Click to view / copy raw Mermaid source
flowchart LR
A["Media Folder Recursion (Get-ChildItem -Recurse)"] --> B["Headless FFprobe Stream (JSON Output -show_streams)"]
B --> C["Object Transformation (Extract Codec, Res, & Duration)"]
C --> D["Structured Excel Export (Clickable Hyperlinks & Summary)"]
2. The Architecture: Headless FFprobe Stream Parsing
FFprobe—the standalone multimedia stream analyzer packaged with FFmpeg—is the industry gold standard for media inspection. When invoked with -print_format json -show_format -show_streams, it parses container headers in milliseconds without decoding full frames.
By capturing FFprobe’s standard output directly into PowerShell’s native ConvertFrom-Json cmdlet, each video file is instantly mapped to an object with strongly typed stream properties (video width, height, audio channels, bitrates, and durations).
3. Complete Working Script: Media Inventory Generator
Save the following script as Export-VideoInventory.ps1. Ensure you have FFmpeg installed (e.g., via winget install Gyan.FFmpeg):
<#
.SYNOPSIS
Exports comprehensive video metadata to CSV/Excel using PowerShell and FFprobe.
.DESCRIPTION
Recursively scans media directories, invokes headless ffprobe, and generates
a structured inventory with durations, codecs, resolutions, and clickable links.
#>
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[string]$MediaDirectory,
[Parameter(Mandatory=$false)]
[string]$OutputPath = ".\Video_Inventory.csv"
)
# Ensure ffprobe exists in PATH
if (-not (Get-Command ffprobe -ErrorAction SilentlyContinue)) {
throw "Error: 'ffprobe' not found in PATH. Please install FFmpeg (winget install Gyan.FFmpeg)."
}
$SupportedExtensions = @(".mp4", ".mkv", ".mov", ".avi", ".webm", ".m4v")
$VideoFiles = Get-ChildItem -Path $MediaDirectory -Recurse -File | Where-Object { $SupportedExtensions -contains $_.Extension.ToLower() }
Write-Host "Discovered $($VideoFiles.Count) media files. Processing stream metadata..." -ForegroundColor Cyan
$Results = [System.Collections.Generic.List[PSCustomObject]]::new()
foreach ($file in $VideoFiles) {
try {
# Execute ffprobe silently in JSON format
$jsonRaw = & ffprobe -v quiet -print_format json -show_format -show_streams $file.FullName
$meta = $jsonRaw | ConvertFrom-Json
$vStream = $meta.streams | Where-Object { $_.codec_type -eq "video" } | Select-Object -First 1
$aStream = $meta.streams | Where-Object { $_.codec_type -eq "audio" } | Select-Object -First 1
$durationSeconds = [double]($meta.format.duration)
$timeSpan = [TimeSpan]::FromSeconds($durationSeconds)
$durationFormatted = "{0:D2}:{1:D2}:{2:D2}" -f $timeSpan.Hours, $timeSpan.Minutes, $timeSpan.Seconds
$Results.Add([PSCustomObject]@{
FileName = $file.Name
FolderDirectory = $file.DirectoryName
SizeBytes = $file.Length
SizeMB = [math]::Round($file.Length / 1MB, 2)
Duration = $durationFormatted
DurationSec = [math]::Round($durationSeconds, 1)
VideoCodec = if ($vStream) { $vStream.codec_name } else { "N/A" }
Resolution = if ($vStream) { "$($vStream.width)x$($vStream.height)" } else { "N/A" }
FrameRate = if ($vStream) { $vStream.r_frame_rate } else { "N/A" }
AudioCodec = if ($aStream) { $aStream.codec_name } else { "N/A" }
BitrateKbps = if ($meta.format.bit_rate) { [math]::Round([int64]$meta.format.bit_rate / 1000, 0) } else { "N/A" }
FullPathHyperlink= "=HYPERLINK(`"$($file.FullName.Replace('"', '""'))`", `"Open File`")"
})
}
catch {
Write-Warning "Failed to parse metadata for: $($file.FullName) - Error: $_"
}
}
$Results | Export-Csv -Path $OutputPath -NoTypeInformation -Encoding utf8
Write-Host "Success: Video inventory exported to $OutputPath ($($Results.Count) records)." -ForegroundColor Green
Notice the inclusion of the =HYPERLINK() formula. When opened in Microsoft Excel, users can click any row to launch the local video file in their default media player directly from the sheet.
4. Gotchas, Encoding, and Performance Tuning
When running this script across massive multi-terabyte enterprise file shares, keep these edge cases in mind:
- Long Path Support (>260 Characters): Ensure Windows Long Paths are enabled in the registry (
LongPathsEnabled = 1inHKLM:\SYSTEM\CurrentControlSet\Control\FileSystem). Without this, nested directory paths will triggerPathTooLongExceptionerrors. - UTF-8 Unicode Character Handling: Video titles and folder paths often contain special characters (emojis, accents, non-Latin alphabets). Always specify
-Encoding utf8when piping output to CSV. - Corrupted Stream Headers: If a video download was interrupted or a recording aborted unexpectedly, FFprobe will write errors to stderr. The script isolates these via
try/catchblocks, logging a warning and continuing without aborting the batch.
Executive Takeaways
- Automated Asset Visibility: Replace hours of tedious manual data entry with an automated scanner that inventories thousands of video files in under two minutes.
- Standardized Technical Audits: Instantly isolate legacy video codecs (e.g., MPEG-2, WMV) and non-standard resolutions before migrating storage to cloud or modern CMS platforms.
- Zero Cloud Vendor Dependency: Execute the entire metadata extraction locally with zero third-party SaaS fees, maintaining complete data confidentiality across private homelabs and corporate networks.

