EncoderPowerShellModule sample

This sample shows how to encapsulate the Microsoft Expression Encoder batch-encoding capabilities in a PowerShell 2.0 Module.

Using the Expression Encoder object model, single or multiple files can be processed from the PowerShell command line. The sample supports encoding a job file saved by the Expression Encoder graphical user interface (GUI), applying a preset, and setting metadata fields.


To run this sample, you will need to have access to .Net 4.0 within PowerShell. For more information, see Microsoft Connect Ff396032.xtlink_newWindow(en-us,Expression.40).png. You will also need one of the following:

  • Windows 7.

  • Windows Vista.

  • Windows XP SP3 with Windows PowerShell V2 CTP3 installed. You can download PowerShell from the Microsoft Download Center Ff396032.xtlink_newWindow(en-us,Expression.40).png.

Compiling and installing the EncoderPowerShellModule

If you had to download the PowerShell module, you will need to install it.

To compile and install the EncoderPowerShellModule

  • From the EncoderPowerShellModule directory, open a command prompt and use the command msbuild. EncoderPowerShellModule.csproj to compile the project. This will install the Expression Encoder module in %HOMEPATH%\Documents\WindowsPowerShell\Modules.

Example scripts

Below are some example scripts that you can use to process media from the PowerShell command line. The sample file paths to media files may not represent actual paths to your media files. Make sure that you use file paths that are pertinent to your system.

Import the expressionencoder module

import-module expressionencoder

Encode a single file using the default preset

sl $home\desktop
Convert-Media -Input 'C:\users\Public\Videos\Sample Videos\Bear.wmv'

Encode single file using a system preset

Convert-Media -Input 'C:\users\Public\Videos\Sample Videos\Bear.wmv' -Preset 'VC-1 Zune HD'

Encode single file using a file preset

Convert-Media -Input 'C:\users\Public\Videos\Sample Videos\Bear.wmv' -Preset 'C:\test\Preset.xml'

Encode a single file with metadata specifying the output directory

Convert-Media -Input 'C:\users\Public\Videos\Sample Videos\Bear.wmv' -Title "Cool" -Description "Long video" -Output $home\desktop

Encode a jobfile saved by the Expression Encoder GUI

Convert-Media -jobfile "C:\users\Public\joboverlay.xej"

   © 2011 Microsoft Corporation. All rights reserved.

Community Additions