Learn about Windows PowerShell
Summary: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to find installed video codecs on Windows 8.
Hey, Scripting Guy! Dude, I am in trouble. Big time! Last week, I installed Windows 8 on the laptops used by all our department heads and front-line supervisors. I thought the responsiveness and the apps would be very useful and a welcome upgrade—I mean, Windows 8 has gotten great reviews, and personally, I love it. But no!!!!! Come to find out, I guess the only thing these people use their laptops for is to watch DVDs when they are on the road. (I imagine they also check their email, but they could use their phones to do that.) Anyway, I never noticed that Windows 8 does not ship with a CODEC to enable someone to watch a DVD. Huh? I mean, get real, this is ridiculous. Personally, I like Media Player and have used it for years, but not if it is going to get me fired. I need a way to find out if a laptop has a particular CODEC, AND I need to find a DVD CODEC now. Can you help me?
Microsoft Scripting Guy, Ed Wilson, is here. WOW, ML, I am sorry you are in trouble. I can imagine that I might have gotten into a similar predicament because I also would not consider watching a DVD on my laptop as a mission-critical use case scenario, and it would have fallen out of the test specs.
Yes, there has been some mixed messaging around playing DVDs on Windows 8. A quick search via Bing reveals lots of blog posts that state that Media Center would be in Windows 8, and not so much that says it will not be in Windows 8. And since we have had Media Center in various editions of Windows for several releases now, I can also expect that you might have missed it. The good news is that you can download the Windows 8 Media Center Pack for Windows 8 Pro for $9.99 USD. The details are available via this web page. Also, if you are not running Windows 8 Pro, we have an upgrade that is available—this upgrade also includes Windows 8 Media Center. I actually did this for one of the Scripting Wife’s computers and it worked very slick, and kept all of her settings (of course, I backed everything up first, just in case).
To find video codecs installed on your computers, use the Win32_VideoCodec WMI class. You can query it via the old Get-WmiObject cmdlet, as shown here.
Get-WmiObject win32_codecfile -Filter 'group = "video"'
But because you are targeting computers running Windows 8, you can also use the Get-CimInstance cmdlet, as shown here.
Get-CimInstance win32_codecfile -Filter 'group = "video"'
To query multiple remote computers, by using the Get-WmiObject cmdlet, you can simply add multiple computer names, and specify the appropriate credentials. This technique is shown here.
Get-WmiObject win32_codecfile -Filter 'group = "video"' -Credential iammred\administrator -ComputerName ws1,ws2,ws3
To query multiple computers by using the CIM cmdlets, first create a cim session, and then do the query. This is shown here.
$session = New-CimSession -ComputerName ws1,ws2,ws3 -Credential iammred\adminIstrator
Get-CimInstance win32_codecfile -Filter 'group = "video"' -CimSession $session
After you have the data, you can examine it by piping it to the Format-List cmdlet and selecting all of the properties. You can then peruse the output to see what properties are most useful for you. Here is an example.
ML, that is all there is to using WMI to examine video codecs. Join me tomorrow for the Weekend Scripter, when I will talk about creating test log files on Saturday and about parsing those log files on Sunday. It will be fun, I promise.
I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at email@example.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.
Ed Wilson, Microsoft Scripting Guy
@Nana Narayanan thank you. I am glad you liked it.