Disassembler0 / Win10-Initial-Setup-Script

PowerShell script for automation of routine tasks done after fresh installations of Windows 10 / Server 2016 / Server 2019
MIT License
4.69k stars 1.08k forks source link

Add developer modes tweaks #279

Closed ghost closed 4 years ago

ghost commented 4 years ago

Another tweak that can be useful for developers: Enable/Disable Sideload mode and Developer mode (https://docs.microsoft.com/it-it/windows/uwp/get-started/enable-your-device-for-development)

These can be the functions:

function EnableDeveloperMode {
    $regKeyPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock"
    if (!(Test-Path -Path $regKeyPath)) { New-Item -Path $regKeyPath -Force | Out-Null }
    Set-ItemProperty -Path $regKeyPath -Name "AllowAllTrustedApps" -Type DWord -Value "1"
    Set-ItemProperty -Path $regKeyPath -Name "AllowDevelopmentWithoutDevLicense" -Type DWord -Value "1"
}
function EnableDeveloperModeSideLoad {
    $regKeyPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock"
    if (!(Test-Path -Path $regKeyPath)) { New-Item -Path $regKeyPath -Force | Out-Null }
    Set-ItemProperty -Path $regKeyPath -Name "AllowAllTrustedApps" -Type DWord -Value "1"
    Set-ItemProperty -Path $regKeyPath -Name "AllowDevelopmentWithoutDevLicense" -Type DWord -Value "0"
}
function DisableDeveloperMode {
    $regKeyPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock"
    if (!(Test-Path -Path $regKeyPath)) { New-Item -Path $regKeyPath -Force | Out-Null }
    Set-ItemProperty -Path $regKeyPath -Name "AllowAllTrustedApps" -Type DWord -Value "0"
    Set-ItemProperty -Path $regKeyPath -Name "AllowDevelopmentWithoutDevLicense" -Type DWord -Value "0"
}

Note: Developer mode is already enabled by function InstallLinuxSubsystem but ONLY if Windows version 1607.