PowerTip: Search for YouTube Videos

Summary: Learn how to use Windows PowerShell to search YouTube videos.

Hey, Scripting Guy! Question How can I search for YouTube videos about Desired State Configuration in Windows PowerShell 4.0?

Hey, Scripting Guy! Answer Use Invoke-RestMethod:

Invoke-RestMethod -uri “https://gdata.youtube.com/feeds/api/videos?v=2&q=Desired+State+Configuration+PowerShell” 

The following command lists each video by title, author, and link:

Invoke-RestMethod -uri “https://gdata.youtube.com/feeds/api/videos?v=2&q=Desired+State+Configuration+PowerShell” |
foreach {[PSCustomObject]@{Title=$_.Title; Author=$_.author.name; Link=$_.content.src}} | Format-List

Prefer a function for your profile?

function Get-DSCVideos {

Invoke-RestMethod -uri “https://gdata.youtube.com/feeds/api/videos?v=2&q=Desired+State+Configuration+PowerShell” |
foreach {[PSCustomObject]@{Title=$_.Title; Author=$_.author.name; Link=$_.content.src}} | Format-List }