Closed petemounce closed 5 years ago
The change you mention wont impact you as you are running with the -noshutdown flag. It appears as though sysrep.exe is hanging for some reason, this is usually because of some issue with the OS like a previously failed sysprep run (this is all Windows sysprep and shouldn't have anything to do with the GCE specific wrapping code) C:\Windows\Panther\setupact.log wont tell you much as that is from the instance startup, for the list of logs see: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/windows-setup-log-files-and-event-logs You should take a look at c:\System32\Sysprep\Panther, that should show logs from the sysprep generalize run.
Thanks for responding; I've retried (been working on something different). I'm now onto the 20180911 image. Now, gcesysprep ran but ended part way through. Output is below. I had a look inside c:\windows\system32\sysprep\panther\setuperr.log
- that's pasted below too.
packer's output from the gcesysprep run:
googlecompute: 2018/09/15 18:04:26 GCESysprep: Beginning GCESysprep.
googlecompute: 2018/09/15 18:04:26 GCESysprep: No answer file was specified. Using default file.
googlecompute: 2018/09/15 18:04:26 GCESysprep: Running 'schtasks' with arguments '/delete /tn GCEStartup /f'
googlecompute: 2018/09/15 18:04:26 GCESysprep: --> SUCCESS: The scheduled task "GCEStartup" was successfully deleted.
googlecompute: 2018/09/15 18:04:28 GCESysprep: Clearing events in EventViewer.
googlecompute: 2018/09/15 18:04:30 GCESysprep: Running 'C:\Windows\System32\Sysprep\sysprep.exe' with arguments '/generalize /oobe /quit /unattend:C:\Program Files\Google\Compute Engine\sysprep\unattended.xml'
So - that's missing some output based on expectations reading the sysprep.ps1
wrapper, but it's also not returning an error, and I haven't figured out how that's possible so far.
c:\windows\system32\sysprep\panther\setuperr.log:
2018-09-11 19:59:53, Error SYSPRP setupdigetclassdevs failed with error 0
2018-09-11 19:59:53, Error SYSPRP MRTGeneralize:107 - ERROR: Failed DeleteInstance AntiSpywareProduct.instanceGuid="{D68DDC3A-831F-4FAE-9E44-DA132C1ACF46}" hr=2147749904
2018-09-11 19:59:53, Error SYSPRP MRTGeneralize:116 - ERROR: Failed DeleteInstance AntiVirusProduct.instanceGuid="{D68DDC3A-831F-4FAE-9E44-DA132C1ACF46}" hr=2147749904
2018-09-15 18:08:32, Error [0x0f00b0] SYSPRP spopk.dll:: Failed to query pending CBS operations; hr = 0x80080005
2018-09-15 18:08:32, Error [0x0f0082] SYSPRP ActionPlatform::LaunchModule: Failure occurred while executing 'Sysprep_Clean_Validate_Opk' from C:\Windows\System32\spopk.dll; dwRet = 0x5
2018-09-15 18:08:32, Error SYSPRP SysprepSession::Validate: Error in validating actions from C:\Windows\System32\Sysprep\ActionFiles\Cleanup.xml; dwRet = 0x5
2018-09-15 18:08:32, Error SYSPRP RunPlatformActions:Failed while validating SysprepSession actions; dwRet = 0x5
2018-09-15 18:08:32, Error [0x0f0070] SYSPRP RunExternalDlls:An error occurred while running registry sysprep DLLs, halting sysprep execution. dwRet = 0x5
2018-09-15 18:08:32, Error [0x0f00d8] SYSPRP WinMain:Hit failure while pre-validate sysprep cleanup internal providers; hr = 0x80070005
c:\windows\system32\sysprep\panther\setupact.log
:
2018-09-15 18:04:30, Info SYSPRP ========================================================
2018-09-15 18:04:30, Info SYSPRP === Beginning of a new sysprep run ===
2018-09-15 18:04:30, Info SYSPRP ========================================================
2018-09-15 18:04:30, Info [0x0f004d] SYSPRP The time is now 2018-09-15 18:04:30
2018-09-15 18:04:30, Info [0x0f004e] SYSPRP Initialized SysPrep log at C:\Windows\System32\Sysprep\Panther
2018-09-15 18:04:30, Info [0x0f0054] SYSPRP ValidateUser:User has required privileges to sysprep machine
2018-09-15 18:04:30, Info [0x0f007e] SYSPRP FCreateTagFile:Tag file C:\Windows\System32\Sysprep\Sysprep_succeeded.tag does not already exist, no need to delete anything
2018-09-15 18:04:30, Info [0x0f005f] SYSPRP ParseCommands:Found supported command line option 'GENERALIZE'
2018-09-15 18:04:30, Info [0x0f005f] SYSPRP ParseCommands:Found supported command line option 'OOBE'
2018-09-15 18:04:30, Info [0x0f005f] SYSPRP ParseCommands:Found supported command line option 'QUIT'
2018-09-15 18:04:30, Info [0x0f005f] SYSPRP ParseCommands:Found supported command line option 'UNATTEND'
2018-09-15 18:04:30, Info [0x0f00d7] SYSPRP WinMain:Pre-validing 'cleanup' internal providers.
2018-09-15 18:04:30, Info SYSPRP RunExternalDlls:Running platform actions specified in action file for phase 3
2018-09-15 18:04:30, Info [0x0f00ba] SYSPRP SysprepSession::CreateSession: Successfully created instance with mount path C:, action file C:\Windows\System32\Sysprep\ActionFiles\Cleanup.xml, and mode <null>
2018-09-15 18:04:30, Info SYSPRP SysprepSession::Validate: Beginning action execution from C:\Windows\System32\Sysprep\ActionFiles\Cleanup.xml
2018-09-15 18:04:30, Info SYSPRP ActionPlatform::GetStringValue: Getting REG_SZ value SysprepMode under key HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Setup\Sysprep
2018-09-15 18:04:30, Info SYSPRP ActionPlatform::GetValue: Getting value SysprepMode under key HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Setup\Sysprep
2018-09-15 18:04:30, Warning SYSPRP ActionPlatform::GetValue: Error from RegQueryValueEx on value SysprepMode under key HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Setup\Sysprep; dwRet = 0x2
2018-09-15 18:04:30, Info SYSPRP SysprepSession::CreateXPathForSelection: Sysprep mode in registry is <null>
2018-09-15 18:04:30, Info SYSPRP ActionPlatform::GetStringValue: Getting REG_SZ value PROCESSOR_ARCHITECTURE under key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
2018-09-15 18:04:30, Info SYSPRP ActionPlatform::GetValue: Getting value PROCESSOR_ARCHITECTURE under key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
2018-09-15 18:04:30, Info SYSPRP SysprepSession::CreateXPathForSelection: Processor architecture in registry is AMD64
2018-09-15 18:04:30, Info [0x0f0080] SYSPRP ActionPlatform::LaunchModule: Found 'Sysprep_Clean_Validate_Opk' in C:\Windows\System32\spopk.dll; executing it
2018-09-15 18:08:32, Error [0x0f00b0] SYSPRP spopk.dll:: Failed to query pending CBS operations; hr = 0x80080005
2018-09-15 18:08:32, Error [0x0f0082] SYSPRP ActionPlatform::LaunchModule: Failure occurred while executing 'Sysprep_Clean_Validate_Opk' from C:\Windows\System32\spopk.dll; dwRet = 0x5
2018-09-15 18:08:32, Error SYSPRP SysprepSession::Validate: Error in validating actions from C:\Windows\System32\Sysprep\ActionFiles\Cleanup.xml; dwRet = 0x5
2018-09-15 18:08:32, Error SYSPRP RunPlatformActions:Failed while validating SysprepSession actions; dwRet = 0x5
2018-09-15 18:08:32, Error [0x0f0070] SYSPRP RunExternalDlls:An error occurred while running registry sysprep DLLs, halting sysprep execution. dwRet = 0x5
2018-09-15 18:08:32, Error [0x0f00d8] SYSPRP WinMain:Hit failure while pre-validate sysprep cleanup internal providers; hr = 0x80070005
2018-09-15 18:25:29, Info SYSPRP ========================================================
2018-09-15 18:25:29, Info SYSPRP === Beginning of a new sysprep run ===
2018-09-15 18:25:29, Info SYSPRP ========================================================
2018-09-15 18:25:29, Info [0x0f004d] SYSPRP The time is now 2018-09-15 18:25:29
2018-09-15 18:25:29, Info [0x0f004e] SYSPRP Initialized SysPrep log at C:\Windows\system32\Sysprep\Panther
2018-09-15 18:25:29, Info [0x0f0054] SYSPRP ValidateUser:User has required privileges to sysprep machine
2018-09-15 18:25:29, Info [0x0f007e] SYSPRP FCreateTagFile:Tag file C:\Windows\system32\Sysprep\Sysprep_succeeded.tag does not already exist, no need to delete anything
2018-09-15 18:25:29, Info [0x0f005f] SYSPRP ParseCommands:Found supported command line option 'RESPECIALIZE'
2018-09-15 18:25:29, Info [0x0f005f] SYSPRP ParseCommands:Found supported command line option 'QUIET'
2018-09-15 18:25:29, Info SYSPRP WinMain:Processing 're-specialize' internal provider request.
2018-09-15 18:25:29, Info SYSPRP RunExternalDlls:Running platform actions specified in action file for phase 6
2018-09-15 18:25:29, Info [0x0f00ba] SYSPRP SysprepSession::CreateSession: Successfully created instance with mount path C:, action file C:\Windows\System32\Sysprep\ActionFiles\ReSpecialize.xml, and mode <null>
2018-09-15 18:25:29, Info SYSPRP SysprepSession::Execute: Beginning action execution from C:\Windows\System32\Sysprep\ActionFiles\ReSpecialize.xml
2018-09-15 18:25:29, Info SYSPRP ActionPlatform::GetStringValue: Getting REG_SZ value SysprepMode under key HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Setup\Sysprep
2018-09-15 18:25:29, Info SYSPRP ActionPlatform::GetValue: Getting value SysprepMode under key HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Setup\Sysprep
2018-09-15 18:25:29, Warning SYSPRP ActionPlatform::GetValue: Error from RegQueryValueEx on value SysprepMode under key HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Setup\Sysprep; dwRet = 0x2
2018-09-15 18:25:29, Info SYSPRP SysprepSession::CreateXPathForSelection: Sysprep mode in registry is <null>
2018-09-15 18:25:29, Info SYSPRP ActionPlatform::GetStringValue: Getting REG_SZ value PROCESSOR_ARCHITECTURE under key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
2018-09-15 18:25:29, Info SYSPRP ActionPlatform::GetValue: Getting value PROCESSOR_ARCHITECTURE under key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
2018-09-15 18:25:29, Info SYSPRP SysprepSession::CreateXPathForSelection: Processor architecture in registry is AMD64
2018-09-15 18:25:29, Info SYSPRP SysprepSession::ExecuteInternal: After sorting, providers will be excuted in this order:
2018-09-15 18:25:29, Info SYSPRP SysprepSession::ExecuteInternal: name:Microsoft-Windows-PnpSysprep, order: 100d
2018-09-15 18:25:29, Info [0x0f00bd] SYSPRP CreateSysprepActionList: Building action list for component Microsoft-Windows-PnpSysprep
2018-09-15 18:25:29, Info [0x0f0080] SYSPRP ActionPlatform::LaunchModule: Found 'Sysprep_Respecialize_Pnp' in C:\Windows\System32\sppnp.dll; executing it
2018-09-15 18:25:29, Info SYSPRP SPPNP: Sysprep_Respecialize_Pnp: Enter
2018-09-15 18:25:29, Info SYSPRP SPPNP: Created progress thread.
2018-09-15 18:25:29, Info SYSPRP SPPNP: Creating device install status thread...
2018-09-15 18:25:29, Info SYSPRP SPPNP: Waiting for thread to exit...
2018-09-15 18:25:29, Info SYSPRP SPPNP: Waiting for service to start.
2018-09-15 18:25:29, Info SYSPRP SPPNP: Waiting for progress thread to exit.
2018-09-15 18:25:29, Info SYSPRP SPPNP: Status: Idle
2018-09-15 18:25:29, Info SYSPRP SPPNP: Finished waiting for device install status...
2018-09-15 18:25:29, Info SYSPRP SPPNP: Progress thread exited.
2018-09-15 18:25:29, Info SYSPRP SPPNP: Sysprep_Respecialize_Pnp: Exit
2018-09-15 18:25:29, Info [0x0f0081] SYSPRP ActionPlatform::LaunchModule: Successfully executed 'Sysprep_Respecialize_Pnp' from C:\Windows\System32\sppnp.dll without error
2018-09-15 18:25:29, Info [0x0f00b8] SYSPRP SysprepSession::Execute: Sysprep mode was not specified, deleting it from registry
2018-09-15 18:25:29, Info [0x0f00c6] SYSPRP ActionPlatform::DeleteValue: Deleting registry value SysprepMode under key HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Setup\Sysprep
2018-09-15 18:25:29, Warning SYSPRP ActionPlatform::DeleteValue: Registry value SysprepMode to be deleted does not exist under key HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Setup\Sysprep
2018-09-15 18:25:29, Info [0x0f0052] SYSPRP Shutting down SysPrep log
2018-09-15 18:25:29, Info [0x0f004d] SYSPRP The time is now 2018-09-15 18:25:29
One of the things I'm doing within my packer build is disable Windows Defender via Set-MpPreference -DisableBehaviorMonitoring $true -DisableIOAVProtection $true -DisableRealtimeMonitoring $true -DisableScanningNetworkFiles $true
. That makes me think SYSPRP MRTGeneralize:107 - ERROR: Failed DeleteInstance AntiSpywareProduct.instanceGuid="{D68DDC3A-831F-4FAE-9E44-DA132C1ACF46}" hr=2147749904
is related, so I'll retry without doing that.
If it turns out it's related, I'll curse, then swap to disabling the thing via a startup script...
I think I am having a related problem with SysPrep with Windows 2016 latest AMI(September 15th)
2018-09-16 20:44:02, Error SYSPRP setupdigetclassdevs failed with error 0
2018-09-16 20:44:02, Error SYSPRP MRTGeneralize:107 - ERROR: Failed DeleteInstance AntiSpywareProduct.instanceGuid="{D68DDC3A-831F-4FAE-9E44-DA132C1ACF46}" hr=2147749904
2018-09-16 20:44:02, Error SYSPRP MRTGeneralize:116 - ERROR: Failed DeleteInstance AntiVirusProduct.instanceGuid="{D68DDC3A-831F-4FAE-9E44-DA132C1ACF46}" hr=2147749904
2018-09-19 14:25:27, Error SYSPRP setupdigetclassdevs failed with error 0
2018-09-19 14:25:27, Error SYSPRP MRTGeneralize:107 - ERROR: Failed DeleteInstance AntiSpywareProduct.instanceGuid="{D68DDC3A-831F-4FAE-9E44-DA132C1ACF46}" hr=2147749904
2018-09-19 14:25:27, Error SYSPRP MRTGeneralize:116 - ERROR: Failed DeleteInstance AntiVirusProduct.instanceGuid="{D68DDC3A-831F-4FAE-9E44-DA132C1ACF46}" hr=2147749904
Seems like Windows Defender will be the cause of this
A reboot is necessary before the selectable update Windows-Defender of package Windows-Defender-Server-Core-Package can be turned off.
Also I tried to execute wmic product get identifyingnumber,name,vendor,version
to see my current GUIDs but none of them matches {D68...
Will try your approach.
@lmayorga1980 in my case, my provisioning was using Set-MpPreference
to try to turn off that stuff; so, do something different from the default. I still haven't managed to get a successful sysprep. If you find a solution, I'd love to hear too. Likewise, if I do, I'll post an update.
Have you tried a reboot after Set-MpPreference and before running sysprep? This seems like an issue with sysprep and Set-MpPreference if I understand the logs (maybe?).
I did remove the features Uninstall-WindowsFeature Windows-Defender-Features
and my problem was solved.
@adjackura I'm reasonably sure I tried that, but I tried a set of things, so perhaps not.
@lmayorga1980 - I'm not sure I parsed that, sorry. Do you mean, you executed Uninstall-WindowsFeature Windows-Defender-Features
before running gcesysprep and that solved your problem? Or, instead, you removed that from your setup, and that solved your problem?
@petemounce, I got it removed from my setup and now I am back in business. Very interesting that the latest amazon ami
from Windows 2016 contains the same error even before I customize it.
I cut out my windows defender modification and that allowed a successful image. I still have those Failed DeleteInstance
entries in my logs. Oh, Windows.
I'm not sure if this is the same issue as #154, but I have GCESysprep on Windows 2016 (image
windows-server-2016-dc-v20180814
) hung, apparently, while running sysprep.exe. I'm wondering whether I should continue waiting (~3 hours and counting), or write it off.Edit: I elected to hit
Stop
in the cloud console; packer has treated that as a success and captured the image, but when I remote into an instance from it I'm presented with the "shutdown event tracker" helpfully asking me whether that was unplanned or not, andwindeploy
was not run, so I think this is not a clean end result.Packer-side Logs (also visible via serial port):
Triggered via packer provisioner (using
-noshutdown
because I need packer to manage the lifetime of the instance, otherwise it will treat the shutdown as an instance-death and fail the build):Using sysinternals process explorer I can see that the process is alive; it's
"C:\Windows\System32\Sysprep\sysprep.exe" /generalize /oobe /quit "/unattend:C:\Program Files\Google\Compute Engine\sysprep\unattended.xml"
. I have not customised the unattended.xml.I can see that the image that I'm building (from the
windows-2016
image family does not yet have @adjackura's change from 62223fe08b9fbb080b034aa09c4cfc138c8ba080 within it, yet - I took a look at thesysprep.ps1
and it lacks the/f
flag - though the process itself has not executed to that point so far.Inside
C:\Windows\Panther\setupact.log
(80KB, no longer growing) the last few lines are as follows. There are noError
level log lines. There are a few warnings, 2nd block. There's 0KB insidesetuperr.log
, but I don't know whether there are some lines pending being flushed by something.Last few lines:
Warning occurences:
I am naively suspicious of
2018-09-11 10:12:41, Warning [0x06036c] IBS Callback_SystemRestore: Failed to set System Restore state. GLE is [126]
in that while I'm definitely not very familiar with sysprep, those sound like oddities.
Finally, inside
sysprep.ps1
I can see the snippet:The log line suggests that it expects the
Invoke-ExternalCommand
cmdlet to be async, but by observation it is not. Is that an error in the intended behaviour, or the wording of the log message, or am I reading into it too much? When I have run non-powershell things from powershell, I think I've usually usedStart-Process <path> <args> -wait -passthru
- but I'm not a powershell expert, and I'm unfamiliar with the technique being used inside of https://github.com/GoogleCloudPlatform/compute-image-windows/blob/master/gce_base.psm1#L333 to know whether it will stream or wait until the command is done before giving any output.Are there any other things I could provide to you, or try out, to see whether I can get a working sysprep?