Last active
June 20, 2025 09:21
-
-
Save win2000b/6545b22eec7cb1684506233a6076979b to your computer and use it in GitHub Desktop.
Set Registry Key via Win32 App
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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