Hello vPro Experts,

 

In case you've worked with any of the Powershell code samples I've previously posted, you've probably noticed that the AmtSystem.Connect() method executes asynchronously, and returns immediately. In this case, you'd have to develop some sort of loop in order to determine whether or not the connection was successful. Typically, I would just use this code to prevent a script from continuing before the connection was established:

 

while ($amtdevice.State -eq "Connecting") { Start-Sleep 1 }

 

But that's ugly, because, what happens if it never connects? Although it's nice to have the ability to asychronously connect to AMT devices, writing code and understanding the logic, to handle async processes is significantly more difficult than writing code that is synchronous. For this reason, we will look at how to modify and recompile the ManageabilityStack .NET assembly in the Intel AMT Developer Toolkit (DTK) to allow synchronous connections to AMT from PowerShell code.

 

In order to perform the next steps, you'll need the following:

 

 

Once you've installed these components, continue on:

 

  1. Download the Intel AMT DTK source code and extract to a folder
  2. Navigate to <Source>\Manageability Stack and open the Manageability Stack.csproj file in Visual Studio 2008
  3. Open the AmtSystem.cs file in the Visual Studio Solution Explorer
  4. Rename the Connect() method to ConnectAsync()
  5. Copy the following code above the ConnectAsync() method:
    public void Connect()
    {
       if (State != AmtSystemObjState.Disconnected) return;
       ChangeState(AmtSystemObjState.Connecting);
       ConnectEx(this);
    }
  6. In the Visual Studio Solution Explorer, right-click the Manageability Stack project, and click Build
  7. Go to your <Source>\Manageability Stack\obj\Debug folder, and grab your new ManageabilityStack.dll .NET assembly

 

Now that you have a recompiled ManageabilityStack assembly, you can load this into PowerShell, and connect synchronously using the Connect() method!

 

Update: I attached the AmtSystem.cs file to this blog post, if you're not comfortable modifying source code yourself! You'll still need to replace the file, open the project, and recompile the library though

 

Trevor Sullivan

Systems Engineer

OfficeMax Corporation