我正在寻找一种方法来重新应用 wim 映像,而不会丢失 Windows PE 中的任何用户数据。到目前为止,我的脚本如下所示:
$TSProgressUI = New-Object -COMObject Microsoft.SMS.TSProgressUI
$TSEnv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$OSDDownload = $TSEnv.Value("osDownload01")
$LogsDirectory = $TSEnv.Value("_SMSTSLogPath")
$wimImagePath = "$OSDDownload\install.wim"
$systemDriveLetter = "S"
Remove-Item -Path "$($env:_OSDDetectedWinDrive)Program Files\WindowsApps" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "$($env:_OSDDetectedWinDrive)ProgramData\Microsoft\Windows\AppRepository" -Recurse -Force -ErrorAction SilentlyContinue
$wimIndex = (Get-WindowsImage -ImagePath $wimImagePath | Where-Object {$_.ImageName -eq "Windows 10 Enterprise"} | select -property ImageIndex).ImageIndex
dism /Apply-Image /ImageFile:$wimImagePath /index:$wimIndex /ApplyDir:$($env:_OSDDetectedWinDrive)
#dism /Image:$($env:_OSDDetectedWinDrive) /Cleanup-Image /RestoreHealth /Source:$wimImagePath /LimitAccess
Get-Partition | Where-Object {$_.GptType -eq "{C12A7328-F81F-11D2-BA4B-00A0C93EC93B}"} | Set-Partition -NewDriveLetter $systemDriveLetter
cmd /c """$($env:_OSDDetectedWinDrive)Windows\System32\bcdboot.exe"" ""$($env:_OSDDetectedWinDrive)Windows"" /s $($systemDriveLetter): /f UEFI"
但是,我在 apply-image 命令之后尝试的并没有更好,之后我的 Windows 安装会停留在加载屏幕中。如果我进行重置,我会收到消息“计算机意外重新启动或遇到意外错误”。
知道我做错了什么吗?
谢谢 md