Skip to content

Instantly share code, notes, and snippets.

@win2000b
Last active June 20, 2025 09:21
Show Gist options
  • Select an option

  • Save win2000b/6545b22eec7cb1684506233a6076979b to your computer and use it in GitHub Desktop.

Select an option

Save win2000b/6545b22eec7cb1684506233a6076979b to your computer and use it in GitHub Desktop.
Set Registry Key via Win32 App
# Sample Script for Win32 Application to set a reg key and monitor it.
$regPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WinRM\Client"
$valueName = "AllowBasic"
$desiredValue = 0
# Ensure the registry key exists
if (-not (Test-Path $regPath)) {
New-Item -Path $regPath -Force | Out-Null
}
# Set or update the registry value
$currentValue = Get-ItemProperty -Path $regPath -Name $valueName -ErrorAction SilentlyContinue
if ($null -eq $currentValue -or $currentValue.$valueName -ne $desiredValue) {
Set-ItemProperty -Path $regPath -Name $valueName -Value $desiredValue
}
# Saved as DisableBasicAuth.ps1
# Intune Creation would be
IntuneWinAppUtil.exe -c C:\IntuneApps\DisableWinRM -s C:\IntuneApps\DisableWinRM\DisableBasicAuth.ps1 -o C:\IntuneApps\DisableWinRMIntune
# Install Command in Intune would be
powershell.exe -ExecutionPolicy Bypass -File DisableBasicAuth.ps1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment