Tech Community Live: Windows edition
Jun 05 2024, 07:30 AM - 11:30 AM (PDT)
Microsoft Tech Community

Factory Reset Windows 10 without user intervention

Copper Contributor

I've looked for this answer online and have come across the "systemreset -factoryreset" command which works, but it comes up with the prompt asking if I want to keep my files or remove everything, I want to remove everything, but without the prompt. 


We are not doing this from any pre-exiting images, and our laptops are running the pre-loaded Windows 10 Pro install, we are just using the in-built Windows 10 "reset this PC" feature as we have no MDM configured. We just want the laptops to be totally reset so they don't contain any company information, we're not bothered about completing the OOBE once they are wiped.


We are trying to accomplish this remotely as our users are all at home, so I need to automate it and have no user involvement in the process, I just want it to factory reset, and bring the laptop up to the off-the-shelf state configuration. We have the facility to push commands and scripts to the laptops so was hoping to do this via powershell.


Does anyone know if this is possible?



27 Replies
That is great Thank You! Is there a way to dis-enroll / remove device record from intune, before this script is run?


It's much smarter to employ Unified Write Filters alongside siloed provisioning packages with the associated STIG tools / SCAP profiles (NIST's National Checklist Program for Windows Server 2019, which does work for the desktop SKUs.)


You could also accomplish this with the push-button reset feature built-into WinRE (by writing a custom WinRE application,) and then locate that somewhere on a separate recovery partition on the drive. It could be easier to just network boot with a fresh image, or selectively block changes inside / outside the Windows Namespace via the Unified Write Filter (ie. Blocking writes or virtualizing some part of the drive in memory temporarily, vs deleting everything after data is written to the drive, etc.)

"Bare metal recovery" ->
"Deploy push-button reset features using Auto-apply folders" ->
"Add a custom tool to the Windows RE Advanced startup menu" ->
"Unified Write Filter (UWF) feature" ->
"Sdelete / Sdelete64 / Sdelete64a" ->
"Microsoft Windows Server 2019 Ver 2, Rel 2 Checklist Details" ->
"STIG Viewing Tools" ->


"Capture, apply, and work with Windows images" ->
"Sysprep (Generalize) a Windows installation" ->
"Use Answer Files with Sysprep" ->
"ScanState Syntax" ->
"Sample scripts" ->
"Siloed provisioning packages" ->
"Capture and apply a Windows image using a single .WIM file" ->
"Compact OS Size comparisons" ->



I would just make a program that uses the PowerShell API / ConPTY API, and have it make the changes for you unattended utilizing the servicing stack. Normally you change the policy with a SCAP profile based on the NIST one, which you could pick and choose various options from the accepted defaults located in the Microsoft Security Compliance Toolkit 1.x (which is the most common way of doing it, being sure to harden services and the network stack at the same time.) The first step obviously is to start out with a fresh image, capture the programs inside / outside the Windows Namespace using a virtual machine, reboot the VM after you capture each SPP / provisioning package, apply them individually, along with the drivers, registry patches, and an XML answer file via sysprep (audit mode,) / manufacturing mode (This is for the recovery image.) You could even edit the WinRE portion of the recovery image at the same time so when you apply it, it automatically has a custom program that resets it upon reboot (if you don't want to utilize SCAP profiles / or a template.) Another example is WinPE resets itself after 72 hours and has a similar setup (albeit with a limited version of .NET 4.0 and no WPF forms.) It is totally possible anyways, and a lot of organizations already do this...

Development tools:

Visual Studio Channels and Release Rhythm ->
Visual Studio Product Lifecycle and Servicing ->
Older versions of Visual Studio ->
Visual Studio Older Downloads ->

VS 2017:
VS 2019:
VS 2022:

vs_Community.exe --quiet --wait --layout "C:\VS22_Offline" --lang en-US --add Microsoft.VisualStudio.Workload.CoreEditor --add Microsoft.VisualStudio.Workload.ManagedDesktop;includeOptional --add Microsoft.VisualStudio.Workload.NativeCrossPlat;includeOptional --add Microsoft.VisualStudio.Workload.NetCrossPlat;includeRecommended --add Microsoft.VisualStudio.Workload.NativeMobile;includeOptional --add Microsoft.VisualStudio.Workload.NativeDesktop;includeOptional --add Microsoft.VisualStudio.Workload.Universal;includeOptional --add Microsoft.Component.HelpViewer

Update the layout to the most current version of the product ->

vs_Community.exe --quiet --wait --layout "C:\VS22_Offline" --useLatestInstaller

Remove older versions from a layout ->

Example: "C:\VS22_Offline\vs_Community.exe" --quiet --wait --layout "C:\VS22_Offline" --clean "C:\VS22_Offline\Archive\d675ef22-858d-47cc-b333-ec38c2d6745f\Catalog.json"

"%ProgramFiles%\WinRAR\Rar.exe" a -r -k -htb -mc31:d+e+ "C:\ISO\VS22_Offline.rar" -r "C:\VS22_Offline\*.*"

"Use command-line parameters to install Visual Studio" ->

"Bootstrapper commands and command-line parameters" ->

"Create an offline installation of Visual Studio" ->

"Visual Studio Community component directory" ->

"Automate installs by using settings in a response file" ->

"Command-line arguments for the Help Content Manager" ->

"Microsoft Help Viewer SDK" ->

"Help API Reference" ->

"Help Viewer 2.0 Code Examples" ->

Language documentation ->
C++ Language Reference ->
C# Language Reference ->
F# Language Reference ->
Visual Basic Language Reference ->
Razor syntax reference for ASP.NET Core ->

^ These are not the best references, they are just basic references for this particular toolchain. The C++/C# reference does not necessarily go into great detail with operator overloading or even arrays, which you have to basically purchase books to be able to grasp this more easily, or take training. The reason is obviously that each toolchain has their own implementation, and in some respects you could consult an official reference on C++ or C#, and it will vary a lot in comparison to Microsoft's toolchain (most compilers are like this.) I really only use this for Visual Studio, based on what is acceptable for this IDE, not necessarily all other IDEs. You have to take into account what version of the language they support, and which features from this language are available in this toolchain, which are not, and for what reason (which is not necessarily good or bad. Another thing you have to take into account when porting software anyways.)


"If you experience a catastrophic error and can't repair or uninstall Visual Studio, you can run the InstallCleanup.exe tool to remove installation files and product information for all installed instances of Visual Studio 2017, Visual Studio 2022, or Visual Studio 2022." ->

C:\Program Files (x86)\Microsoft Visual Studio\Installer>installcleanup /?

Usage:  InstallCleanup.exe <mode>
        mode should be one of the following:
                -f | -full:  cleanup all installed assets (default)
                -i | -instance [version]:  cleanup only instance data
                        [version]:  filter to only instances that start with this version string

C:\Program Files (x86)\Microsoft Visual Studio\Installer>installcleanup -f
Detecting Visual Studio Installs:
        Detecting Instances... Done

Removing Installer Assets:
        Uninstalling MSIs... Done
        Deleting AppData Channels... Done
        Deleting LocalAppData Channels... Done
        Deleting User Cache... Done
        Deleting Installer... Done
        Deleting Package Cache... Done
        Deleting Installer Shortcut... Done
        Deleting Installer ARP Entry... Done

C:\Program Files (x86)\Microsoft Visual Studio\Installer>


Hi there,

Recently cloud download option became available for factory reset and I'm wondering if it's possible to use DoWipeProtectedMethod and download OS image from the cloud. As I understood with provided PS script, factory reset uses local files for OS reinstallation?

Thank you!


I think the cloud option is only present in Windows RE?

I know that if you enter Windows RE by repeatedly hard powering off during boot, you can then reset using cloud download.

Does anyone know a way to access it through PowerShell?

@dretzer Can that tool be user with an unattended.xml? I am trying to remotely wipe the device and have it skip the setup screen and login and maybe even install a program (remote management software).

@dretzer So I have has weird success with this.  It worked on a machine. Once.  The next machine I tried this on gave me a Exception calling "InvokeMethod" with "4" argument(s): "The requested object could not be found."
Any Ideas? Anyone?


Super useful thanks!