A Device Factory Reset re-applies a pre-stored Windows image (from the recovery partition) to the OS partition. It also allows the clearing of the TPM.
The Device Factory Reset operation is initiated by either:
- The application calling
DeviceManagementClient.StartFactoryResetAsync()
. - The application calling
DeviceManagement.StartFactoryResetAsync()
. - The operator invoking the Azure direct method
windows.startFactoryResetAsync
.
Namespace: Microsoft.Devices.Management
Class: DeviceManagementClient
Methods: public async Task StartFactoryResetAsync(bool clearTPM, string recoveryPartitionGUID)
Notes:
DeviceManagementClient.StartFactoryResetAsync()
requires a connection to IoT Hub and it will update the device twin with its status.
Example
async Task OnRebootClicked(DeviceManagementClient dmClient) { await dmClient.StartFactoryResetAsync(true, "<recoveryPartitionGUID>"); }
Namespace: Microsoft.Devices.Management
Class: DeviceManagement
Methods: public async Task StartFactoryResetAsync(bool clearTPM, string recoveryPartitionGUID)
Notes:
DeviceManagement.StartFactoryResetAsync()
does not require a connection to IoT Hub and it will not update the device twin with its status.
Example
async Task OnRebootClicked(DeviceManagementClient dmClient) { DeviceManagement dm = DeviceManagement.CreateWithoutAzure(); await dm.StartFactoryResetAsync(true, "<recoveryPartitionGUID>"); }
This interface is asynchronous and will return before completing the operation. The status can be tracked through the device twin factoryReset
node (see below).
{ "recoveryPartitionGUID" : "recoveryPartitionGuid" "clearTPM" : "see below" }
"recoveryPartitionGUID"
: This is the guid of the partition that contains the Windows image file (wim) to be re-applied."clearTPM"
: When set to"true"
, all TPM slots will be cleared - otherwise, TPM will be not be cleared.
windows.startFactoryResetAsync
returns a Status Object (see Status Reporting).
{ "status" : { <Status Object> } }
For details on Status Object, see Error Reporting.
As the method executes, it will also update the device twin with its current status and its final state.
"reported" : { "windows" : { "factoryReset": { "lastChange" = <Status Object> } } }
Input
{ "recoveryPartitionGUID" : ""66F49469-6F65-4E1D-9891-2EB2E83C8B85"" "clearTPM" : "true" }
Output
{ "status" : { "time" : "time stamp", "state": "pending", } }
Device Twin Reporting
"reported" : { "windows" : { "factoryReset": { "lastChange": { "time" : "time stamp", "state": "pending" } } } }
And then, upon success, it will be changed to:
"reported" : { "windows" : { "factoryReset": { "lastChange": { "time" : "time stamp", "state": "completed" } } } }