Skip to content

Instantly share code, notes, and snippets.

@tkuennen
Created October 29, 2025 17:57
Show Gist options
  • Select an option

  • Save tkuennen/6e3898c4738a2abb904e35833a4b244c to your computer and use it in GitHub Desktop.

Select an option

Save tkuennen/6e3898c4738a2abb904e35833a4b244c to your computer and use it in GitHub Desktop.
Windows 11 Disable Bitlocker sysprep
Disable-BitLocker -MountPoint "C:" -erroraction silentlycontinue
$bl = Get-BitLockerVolume -MountPoint "c:" | select-object -expandproperty VolumeStatus
Do {Get-BitLockerVolume -MountPoint "c:" | select-object -expandproperty VolumeStatus | out-null} Until ($bl = "FullyDecrypted")
$sizemin = Get-PartitionSupportedSize -driveletter c | select-object -expandproperty SizeMin
$result = $sizemin / 10
$final = $sizemin + $result
Resize-Partition -driveletter c -size $final
Import-Module Appx
Import-Module Dism
Get-AppxPackage -allusers | Remove-AppxPackage -erroraction silentlycontinue
Set-ItemProperty -Path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\RunOnce' -name 'firstlogon' -value 'powershell -noexit -ep bypass c:\users\admin\sysprep\firstlogon.ps1'
start-process 'C:\Windows\System32\Sysprep\sysprep.exe' -argumentlist /oobe, /generalize, /shutdown, /unattend:C:\Users\admin\sysprep\unattend.xml -wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment