Windows - Local Auto Device Registration and Enrollment

This set of scripts will run locally on a device and use AirWatch's APIs to register itself using it's serial number then perform an auto enrollment using a staging account, but auto map to the correct user in AirWatch. You can use your existing deployment tool, bake into the image, or manually run on a device. 

Sign in to be able to add comments.

Comments 2


4876323717 5 years ago
I'm running into a issue when attempting to run the register_device_ps.ps1 script. I have copied the AirWatch folder to a local location on a Win10 device, modified the localdevice.ini file, downloaded the latest AirWatchAgent.msi, and ensured that MVC4 is installed (from the link provided in the instructions. But when I run the ps script as an admin I receive the following error- "Add-Type : (0) : Metadata file 'C:\Setup\AirWatch\bin\System.Web.Helpers.dll' could not be found".

Does the "Bin" directory and the .dll files get created as part of the script, or is this suppose to be include along with the zipped contents?
4876323717 5 years ago
I was able to find the "System.Web.Helpers.dll" and copy it to the Bin directory (which I had to create). After doing this I was able to get a little further down the script, until I received the error output seen below:

PS C:\Installs\AirWatch> C:\Installs\AirWatch\register_device_ps.ps1
AirWatch Agent Exists

Name Value
---- -----
serialNumber VM0Vs9EE5qC0
username WIN10Device1\AdminTest
Exception calling "RegisterDeviceArg" with "1" argument(s): "The given key was not present in the dictionary."
At C:\Installs\AirWatch\register_device_ps.ps1:107 char:1
+ $isRegister = $Register.RegisterDeviceArg($regArgs);
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : KeyNotFoundException

Do not enroll device and email IT


In digging into the C# code in Registration.cs, I see where the dictionary keys are coming from the localdevice.ini file, but the code looks like it is attempting to if the devices serialname is already registered to the Username of the locally logged on user and if this returns false, it craps out. Am I reading this wrong or is there something else I'm over looking? I figured that the point of the script was to check if the device was already registered and if not register it and install the agent. Am I correct?