Integrating Intel® Active Management Technology (Intel® AMT) by taking advantage of the Windows PowerShell Module for Intel® vPro™

Starting with the Intel® AMT SDK version 7.0 and higher, it’s becoming much easier to access Intel® AMT Technology using Windows PowerShell. PowerShell, as you have probably heard, is Microsoft’s task automation framework for Windows and provides a scripting language built on top of the .NET framework. Intel now provides a PowerShell Module for Intel® AMT. A PowerShell Module is a package of reusable commands and features that expose their functionality as if they were directly built into PowerShell. If you’re new to PowerShell, a reusable command is called a cmdlet (Pronounced “Command let”).
You can download the initial release of the module here, also there is a version included the latest Intel® AMT 7.0 SDK and if you have noticed the SDK now provides code snippets written in PowerShell. Moreover, there will be a new release of the module at the end of March/2011 that will have a host of new features including PowerShell Drive support that what will allow you manage nearly every Intel® AMT firmware setting in PowerShell using simple get-Item set-Item cmdlets. However, the primary purpose of this blog is not to go over each individual command offered in the Module but instead focus on how you can integrate the PowerShell commands into a management console GUI.


After Installing the Intel module, users can open a command prompt, then import the PowerShell module, and start running Intel® AMT commands from the shell environment. However, what if you wanted to provide a GUI application for your users? Would such a GUI application need to be written in PowerShell ? The answer is no. In fact, the GUI can be written in any language that’s capable of launching the PowerShell.exe and passing in the command arguments. However, if you’re GUI application happens to be a .NET application it can use the PowerShell Module more efficiently and I’ll demonstrate this in the blog.
Let’s start with a simple sample .NET application that will demonstrate calling the PowerShell Module command” Invoke-AMTPowerManagement”.


What we want to do this have a GUI menu item that will invoke call Invoke-AMTPowerManagment when it’s clicked. That’s it pretty simple right? After that it would be fairly simple using the same techniques to write a full featured GUI all built on top of the reusable PowerShell commands.



The first then we need to do is create a PowerShell Runspace in .NET. The PowerShell runspace allows us to run our Module commands directly in our .NET application (no need to spawn Powshell.exe or anything like that)



// add reference C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0\
//System.Management.Automation.dll
// If no such file exists on your system then download and Install the PowerShell 2.0 SDK from microsoft.com

using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Collections.ObjectModel;

// Create the default initial session state
InitialSessionState iss = InitialSessionState.CreateDefault();

// import the Intel Module into the runspace
iss.ImportPSModule(new string[] { "IntelvPro" });
Runspace runSpace = RunspaceFactory.CreateRunspace(iss);
runSpace.Open();

_ps = PowerShell.Create();
_ps.Runspace = runSpace;




Next we will use the PowerShell object to define the Module command that we want to run.




// Add the cmdlet and specify the runspace.
_ps.AddCommand("Invoke-AmtPowerManagement");

_ps.AddParameter("Operation","PowerOn");this could also be poweroff




Finally we will specify the target computer and credentials that will be used when performing the command.




_ps.AddParameter("ComputerName",textBox1.Text);
//Note:TextBox1.Text holds the computerName in our simple GUI

_ps.AddParameter("Port", "16992");
// this can be changed to 16993 for TLS


//PowerShell uses secure strings for credentials
System.Security.SecureString secString = new System.Security.SecureString();
foreach (char passwordChar in textBox3.Text)
secString.AppendChar(passwordChar);
// Note: Note:TextBox3.Text holds digest password in our simple GUI

PSCredential amtCred = new PSCredential(textBox2.Text,secString);
// Note: Note:TextBox2.Text holds digest user in our simple GUI

_ps.AddParameter("Credential", amtCred);


Collection results = _ps.Invoke();


Note: the PowerShell module can support Mutual TLS and Kerberos credentials using the currently logged on user. However, for simplicity, this short sample assumes your Intel AMT device is configured using HTTP/Digest authentication. If you want to know how to invoke commands using HTTPS/Kerberos authentication just let me know and I’ll show you how to do that, it’s pretty easy.






That’s it! We can now securely leverage all the commands available in the PowerShell Module from our .NET GUI application. You can also write a PowerShell script that performs an entire sequence of AMT commands and just use the runspace to run the script as well. If you’re into PowerShell (or are planning on being into PowerShell) the Intel module just made things a lot easier.


You can download the full DevStudio 2008 project source for this example here

For more complete information about compiler optimizations, see our Optimization Notice.