Skip to content

Instantly share code, notes, and snippets.

@TravisEz13
Last active December 20, 2017 02:22
Show Gist options
  • Save TravisEz13/cb0403bc21f1506531d609c2933f1166 to your computer and use it in GitHub Desktop.
Save TravisEz13/cb0403bc21f1506531d609c2933f1166 to your computer and use it in GitHub Desktop.
#This is intended for Win7/Windows Server 2008 R2 sysprep issues with WMF 5.x
$Path ='HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\Sysprep\Generalize'
$acl=Get-Acl -Path $Path
$rights = $acl.Access|?{$_.IdentityReference -eq 'BUILTIN\Administrators'} | Select-Object -ExpandProperty RegistryRights
if($rights -ne 'FullControl')
{
throw "Please give administrators full control to $Path"
}
if(!(get-command -name 'Get-ItemPropertyValue' -erroraction silentlycontinue))
{
throw "Please update to PowerShell 5.1 or newer"
}
Get-Item $Path | Select-Object -ExpandProperty Property | %{
$name = $_
$value=Get-ItemPropertyValue -Path $path -Name $Name
$plugin=($value -split ',')[0]
if(![System.IO.Path]::IsPathRooted($plugin)){
$plugin=Join-Path -path "$env:windir\system32" -ChildPath $plugin
}
if($plugin -like '*silsysprep.dll')
{
# This is my more aggressive fix
# I've hit other issues with this sysprep provider than the official fix addresses.
Remove-ItemProperty -Path $Path -Name $Name
Continue
}
$exists = Test-Path -Path $plugin
$message = "$plugin - Exists: $exists"
if($exists){
Write-Verbose $message -Verbose
}
else
{
Write-error $message
}
}
# This is the official fix
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\StreamProvider" -Name LastFullPayloadTime -Value 0 -PropertyType DWord -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment