聊聊VDI虚拟桌面的SID问题-前传(下)

Posted HaoHu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了聊聊VDI虚拟桌面的SID问题-前传(下)相关的知识,希望对你有一定的参考价值。

​ 这一系列的文字(聊聊VDI虚拟桌面的SID问题-前传「上」聊聊VDI虚拟桌面的SID问题-前传「中」)其实都是为了这一篇:因为之前项目中出现了不少不能完成自定义过程导致桌面池无法完整制备的问题,当我尝试解决这些问题之后,就非常想记录下来。排错的基本思路是分段和隔离,接下来我们就分别看看这些环节。

Sysprep的诊断

​ Sysprep自身会在不同阶段写入不同日志。

项目 日志路径
Generalize %WINDIR%\\System32\\Sysprep\\Panther
Specialize %WINDIR%\\Panther
(OOBE的无人参与 Windows 安装程序操作) %WINDIR%\\Panther\\Unattendgc

​ setupact.log 文件是主日志文件。setuperr.log会记录错误摘要,但详细信息会记录在主日志中。

​ 只要我们看到大概在哪个阶段出现了问题,就可以去找对应的日志看看原因。如果没有日志呢?那说明都没执行到这一步……

VC自定义的诊断

​ 使用VC的自定义规范时,除了Sysprep,还可以检查GuestCsutUtil的日志。看上去这个日志的路径是 C:\\WINDOWS\\TEMP\\customize-guest.log 。看一个例子吧…

[2016-05-24T16:10:37  INFO] GuestCustUtil invoked.
[2016-05-24T16:10:37  INFO] Params: customize -sealparam "/quiet /generalize /oobe /reboot" -nics 4000 -schedulenativeunobfusc
[2016-05-24T16:10:37  INFO] Checking for Windows Sysprep Respecialize operation.
[2016-05-24T16:10:37 DEBUG] Sysprep process is currently running.
[2016-05-24T16:10:37  INFO] Windows Sysprep Respecialize operation was detected.
[2016-05-24T16:10:37  INFO] Copying files from C:\\Windows\\TEMP\\vmwA4EB.tmp to C:\\Windows\\TEMP\\vmwB575.tmp.
[2016-05-24T16:10:40  INFO] Rescheduling Guest OS Customization.
[2016-05-24T16:10:40 DEBUG] Executing command C:\\Windows\\system32\\schtasks.exe /create /sc ONSTART /rl HIGHEST /np /z /v1 /ru SYSTEM /tr "C:\\Windows\\TEMP\\vmwB575.tmp\\guestcustutil.exe customize -sealparam \\"/quiet /generalize /oobe /reboot\\" -nics 4000 -schedulenativeunobfusc" /tn "VMware Guest OS Customization Task"
[2016-05-24T16:10:41  INFO] Waiting for Sysprep to exit.
[2016-05-24T16:10:42  INFO] Sysprep is no longer running.
[2016-05-24T16:12:42  INFO] Rebooting...
[2016-05-24T16:12:42 DEBUG] Successfully retreived process access token.
[2016-05-24T16:12:42 DEBUG] Got LUID for SHUTDOWN privilege.
[2016-05-24T16:12:42 DEBUG] Successfully added shutdown privilege.
[2016-05-24T16:12:42  INFO] GuestCustUtil exiting.

​ 如果是VC自定义的过程,建议先看看这个日志,再去看Sysprep的日志寻找问题根源。

几个遇到的问题 - 因为Microsoft Store应用导致的失败

​ 我们在之前说过,如果通用化之前安装或更新过Microsoft Store应用,将会导致Sysprep失败。原因在于:Sysprep /generalize 要求为所有用户预配所有应用;但是,从 Microsoft Store 更新应用时,该应用将与登录的用户帐户相关联。 以下错误将出现在 Sysprep 日志文件中(位于 %WINDIR%\\System32\\Sysprep\\Panther 中):

<package name> was installed for a user, but not provisioned for all users. This package will not function properly in the sysprep image.

​ 解决这类问题不要使用 Microsoft Store 来更新应用,而应将更新旁加载到业务线应用,为所有用户预配脱机许可的适用于企业的 Microsoft Store 应用,或者让最终用户在其目标电脑上使用 Microsoft Store 更新其应用。有关旁加载业务线 Microsoft Store 应用的详细信息,请参阅使用 DISM 旁加载应用自定义“开始”屏幕

​ 具体到我遇到的问题,日志里能够看到如下错误:

2021-09-23 12:49:58, Info                  SYSPRP Entering SysprepGeneralizeValidate (Appx) - validating whether all apps are also provisioned.
2021-09-23 12:49:58, Error                 SYSPRP Package Windows.MiracastView_6.3.0.0_neutral_neutral_cw5n1h2txyewy was installed for a user, but not provisioned for all users. This package will not function properly in the sysprep image.
2021-09-23 12:49:59, Error                 SYSPRP Failed to remove apps for the current user: 0x80073cf2.
2021-09-23 12:49:59, Error                 SYSPRP Exit code of RemoveAllApps thread was 0x3cf2.
2021-09-23 12:49:59, Error                 SYSPRP ActionPlatform::LaunchModule: Failure occurred while executing \'SysprepGeneralizeValidate\' from C:\\Windows\\System32\\AppxSysprep.dll; dwRet = 0x3cf2
2021-09-23 12:49:59, Error                 SYSPRP SysprepSession::Validate: Error in validating actions from C:\\Windows\\System32\\Sysprep\\ActionFiles\\Generalize.xml; dwRet = 0x3cf2
2021-09-23 12:49:59, Error                 SYSPRP RunPlatformActions:Failed while validating Sysprep session actions; dwRet = 0x3cf2
2021-09-23 12:49:59, Error      [0x0f0070] SYSPRP RunDlls:An error occurred while running registry sysprep DLLs, halting sysprep execution. dwRet = 0x3cf2
2021-09-23 12:49:59, Error      [0x0f00d8] SYSPRP WinMain:Hit failure while pre-validate sysprep generalize internal providers; hr = 0x80073cf2
2021-09-23 12:49:59, Info       [0x0f0052] SYSPRP Shutting down SysPrep log

​ 知道了Microsoft Store应用在Sysprep的限制之后,这个问题就很容易理解和解决了——想办法把这个APPX包删掉就行了。更何况还有官方的步骤可以参考:MiracastView 在版本 1709 Windows 10 sysprep 错误 。如果想一探究竟,了解为什么会有这样的问题,可以参考:Sysprep fails with Microsoft Store apps

几个遇到的问题 - 因为Windows更新导致的失败

​ 当Syprep运行时,会对很多系统服务的状态进行检查确认。如果自定义过程刚好卡在Windows Update未完成的时候,就会导致失败。

2021-08-31 09:49:37, Error                 SYSPRP Sysprep_Clean_Validate_Opk: Audit mode cannot be turned on if reserved storage is in use. An update or servicing operation may be using reserved storage.; hr = 0x800F0975
2021-08-31 09:49:37, Error                 SYSPRP ActionPlatform::LaunchModule: Failure occurred while executing \'Sysprep_Clean_Validate_Opk\' from C:\\Windows\\System32\\spopk.dll; dwRet = 0x975
2021-08-31 09:49:37, Error                 SYSPRP SysprepSession::Validate: Error in validating actions from C:\\Windows\\System32\\Sysprep\\ActionFiles\\Cleanup.xml; dwRet = 0x975
2021-08-31 09:49:37, Error                 SYSPRP RunPlatformActions:Failed while validating Sysprep session actions; dwRet = 0x975
2021-08-31 09:49:37, Error      [0x0f0070] SYSPRP RunDlls:An error occurred while running registry sysprep DLLs, halting sysprep execution. dwRet = 0x975
2021-08-31 09:49:37, Error      [0x0f00d8] SYSPRP WinMain:Hit failure while pre-validate sysprep cleanup internal providers; hr = 0x80070975
2021-08-31 09:49:37, Info       [0x0f0052] SYSPRP Shutting down SysPrep log

​ 知道了这一原因,解决起来就简单了。打开Windows的设置,点进更新和安全,直接来个暂停更新7天。重启之后再运行自定义试试。

几个遇到的问题 - 因为加域失败导致的失败

​ 别忘了Sysprep的过程。即使sysprep命令行成功完成,我们还需要借助应答文件来完成加域动作。因此你见到如下错误提示时,应该收集日志及检查加域等定制化步骤是否有问题。

"Windows could not parse or process unattend answer file [C:\\Windows\\Panther\\unattend.xml] for pass [oobeSystem]. "

​ 通常这个错误会给一点有限的信息,例如我之前看到的一个错误是:“处理组件设置是检测到错误 [Microsoft-Windows-Shell-Setup]”。根据以上信息,回过头看看不同阶段Sysprep日志的位置,猜测是专门化过程中pass=“oobeSystem”没有完成。就是可惜来不及再搜集日志进一步分析了。只能找到个相近的应答文件参考下。

    <settings pass="oobeSystem">
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <AutoLogon>
                <Password>
                    <Value>***********==</Value>
                    <PlainText>false</PlainText>
                </Password>
                <Enabled>true</Enabled>
                <LogonCount>1</LogonCount>
                <Username>itstaff</Username>
            </AutoLogon>
            <OOBE>
                <HideEULAPage>true</HideEULAPage>
                <ProtectYourPC>1</ProtectYourPC>
            </OOBE>

​ 猜测是使用的VC的自定义规范勾选了自动登录但配置有问题。

​ 另一个错误就比较明显了。系统没有完成自定义过程,重启之后在系统日志中看到了Event ID 4097,错误代码 1909的错误。这个是由于自定义过程使用的加域账号已禁用或密码错误导致失败造成的。

以上是关于聊聊VDI虚拟桌面的SID问题-前传(下)的主要内容,如果未能解决你的问题,请参考以下文章

聊聊VDI虚拟桌面的重复SID问题(上)

虚拟桌面 VDI

龙存桌面虚拟化(VDI)存储解决方案

IDV和VDI,桌面虚拟化选哪种好?

桌面虚拟化是该选用IDV还是VDI?

桌面虚拟化是该选用IDV还是VDI?云桌面这两种技术哪个更符合趋势?