misc.ps1

function Disable-WindowsHotkeys {
    #warning, disables all Windows Hotkeys including Win+R etc.
    $RegPath = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"
    New-ItemProperty -Path $RegPath -Name "NoWinKeys" -Value 1 -PropertyType dword
}

function Enable-WindowsHotkeys {
    $RegPath = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"
    New-ItemProperty -Path $RegPath -Name "NoWinKeys" -Value 0 -PropertyType dword
}

function Block-MicrosoftAccounts {
    <#
    .SYNOPSIS Prevent users from adding Microsoft accounts (or signing in with -Force)
    #>

    param(
        [switch]$Force
    )
    $RegPath = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System"
    If (-not (Test-Path $RegPath)) {
        New-Item -Path $RegPath -Force | Out-Null
    }
    $Value = if ($Force) { 3 } else { 1 }
    New-ItemProperty -Path $RegPath -Name "NoConnectedUser" -Value $Value -PropertyType dword -Force
}

function Unblock-MicrosoftAccounts {
    <#
    .SYNOPSIS Allow users to sign in with Microsoft accounts
    #>

    $RegPath = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System"
    If (Test-Path $RegPath) {
        Remove-ItemProperty -Path $RegPath -Name "NoConnectedUser" -ErrorAction SilentlyContinue
    }
}