Repository navigation
Expand file tree
/
Copy pathRemove-WindowsCustomizations.ps1
More file actions
71 lines (62 loc) · 2.33 KB
/
Copy pathRemove-WindowsCustomizations.ps1
File metadata and controls
71 lines (62 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<#
.SYNOPSIS
Uninstall action for the Windows Customizations app (Intune Win32 app or ConfigMgr application).
.DESCRIPTION
Removes only the HKLM version stamp, which flips the detection rule to "not installed".
It does NOT revert any customization: the Default User hive seeds, the
ClassicContextMenu Active Setup component, machine-level/policy registry keys,
replaced branding files, and removed apps all remain. So new users still inherit most
customizations after uninstall. Per-user values are intentionally left in place - they
live in individual profiles and are user-changeable by design. A full teardown
(clearing the default hive, Active Setup, and HKLM/policy keys) is not implemented.
#>
[CmdletBinding()]
param()
# Re-launch 64-bit when started from a 32-bit host - the IME or a task sequence step (AMD64 or
# ARM64 native).
if ($env:PROCESSOR_ARCHITEW6432 -in 'AMD64', 'ARM64')
{
try
{
& "$env:WINDIR\SysNative\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy Bypass -File $PSCommandPath @args
exit $LASTEXITCODE
}
catch
{
throw "Failed to relaunch under SysNative: $($_.Exception.Message)"
}
}
$ErrorActionPreference = 'Stop'
$PackageRoot = $PSScriptRoot
$EngineRoot = Join-Path -Path $PackageRoot -ChildPath 'Engine'
. (Join-Path -Path $EngineRoot -ChildPath 'Functions.ps1')
Initialize-Logging -FileName 'Remove-WindowsCustomizations.log'
Write-LogEntry -Message 'START - Remove Windows Customizations'
$ConfigPath = Join-Path -Path $PackageRoot -ChildPath 'Config\Settings.json'
$Organization = 'Organization'
if (Test-Path -Path $ConfigPath)
{
try
{
$Config = Get-Content -Path $ConfigPath -Raw | ConvertFrom-Json
if ($Config.Organization)
{
$Organization = $Config.Organization
}
}
catch
{
Write-LogEntry -Message "Failed to read Organization from config: $($_.Exception.Message)" -Level Warning
}
}
try
{
Remove-VersionStamp -Organization $Organization
Write-LogEntry -Message "Removed version stamp under HKLM:\SOFTWARE\$Organization\WindowsCustomizations"
}
catch
{
Write-LogEntry -Message "Failed to remove version stamp: $($_.Exception.Message)" -Level Error
}
Write-LogEntry -Message 'END - Remove Windows Customizations'
exit 0