Welcome to MSDN Blogs Sign in | Join | Help

Device Emulator and the Windows PowerShell

Was playing around with Windows PowerShell recently and it ROCKS. there has been a lot of coverage around PowerShell so I won't bore you with some of them, here's a great video screencast by Scott Hanselman to get your started on PowerShell.

What I wanted to do was to see how easily it would be for one to write a test harness for automating the instantiation of Device Emulators so that developers and testers can quickly test their application on different device configurations.

This sample uses the Managed Core Connectivity Wrappers that we've built into Visual Studio 2008 and the new Windows Mobile SDK.

You need the following installed before you can proceed:

  1. Windows Mobile 5.0 or 6 SDKs
  2. Windows PowerShell 1.0
  3. PowerTab Version 0.98

Here's how you can instantiate a device emulator from powershell.

Step 1: Start PowerShell in Administrator mode and enable script execution by typing "Set-ExecutionPolicy unrestricted", especially if you're on Vista.

powershell01

Step 2: Load the Microsoft.SmartDevice.Connectivity assembly using the LoadWithPartialName method.

powershell02

Step 3: Create the DataStoreManager object. "1033" is locale for "en-en"

powershell03

Step 4: Query the types of platforms that are installed on your machine. This will return the list of Windows Mobile Emulator platforms that were installed together with the SDK. If you have not installed the Windows Mobile 6 SDK, you won't see the Windows Mobile 6 Professional nor the Standard SDKs.

powershell04

Step 5: Enumerate Platforms and create a collection of platforms in $plat. Assign platform that you're interested in to $wm6, in this case we're using the Windows Mobile 6 Professional SDK. (item 0 in the collection)

powershell05

Step 6: Get the list of devices for that platform. This shows you all the possible device configurations / types that were installed with that platform.

powershell06

Step 7: Let's pick the Windows Mobile 6 Professional Emulator by picking device [1] and connect to the emulator using the $device.Connect() method.

powershell07

That's it :) pretty powerful. You can imagine how flexible PowerShell is by allowing you to write .NET Code together with Shell code to create automated scripts. You can now easily instantiate emulators and deploy custom configurations automatically to create a full automated test environment.

Published Wednesday, September 26, 2007 3:27 PM by lokeuei

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

Wednesday, September 26, 2007 6:30 PM by Techy News Blog » Device Emulator and the Windows PowerShell

# Techy News Blog » Device Emulator and the Windows PowerShell

Wednesday, September 26, 2007 8:21 PM by Daniel Moth

# PowerShell combined with CoreCon

PowerShell combined with CoreCon

Thursday, September 27, 2007 3:19 AM by Staffan Gustafsson

# re: Device Emulator and the Windows PowerShell

Is it really necessary with an unrestricted execution policy? Wouldn't RemoteSigned have worked?

/Staffan

Thursday, September 27, 2007 12:33 PM by lokeuei

# re: Device Emulator and the Windows PowerShell

Staffan, of course not, that would be best way to do it, but i'm using unrestricted in this demo to make life easier for me. :)

Saturday, September 29, 2007 7:26 PM by Jeffry van de Vuurst

# re: Device Emulator and the Windows PowerShell

This looks great! So, do I need to have Visual Studio 2008 installed for the Managed Core Connectivity Wrappers or is the Windows Mobile 5 or 6 SDK enough?

Having to install VS 2008 on my build server doesn't seem like a good idea.

Thanks,

Jeffry

Monday, October 01, 2007 5:34 PM by lokeuei

# re: Device Emulator and the Windows PowerShell

Jeffry,

yes unfortunately you need to have Visual Studio 2008 installed to get the CoreCon wrapper.

Maybe you can install it, identify which components you need and copy them out manually ;)

Wednesday, December 12, 2007 7:56 PM by Mike Francis' Weblog

# PowerShell and Quick UI Check for WM Applications

Thanks to those of you that attended Reed and my presentation at the Windows Mobile Partner Summit .

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker