2019年10月30日 星期三

How to install/excute WCSTest on WinPE / 如何在WinPE上安裝/執行 WCSTest



tool 可以從git上抓下來 https://github.com/rockyshek/ocs-source-code-and-operations-toolkit-for-open-cloudserver


如何在WinPE上安裝WcsTest


參考文件 OCS Tools User Guide.pdf (路徑在DeploymentKit\WcsTest\Scripts\References\Documentation)

1. 安裝Windows ADK

下載並安裝Windows ADK https://docs.microsoft.com/zh-tw/windows-hardware/get-started/adk-install#winADK
















2. 用管理員權限開啟【部屬與映像工具環境】













3. 建立WinPE工作環境

copype amd64 C:\WinPE_amd64_PS











4. 安裝Powershell 

先mount WinPE 在OS上
Dism /Mount-Image /ImageFile:"C:\WinPE_amd64_PS\media\sources\boot.wim" /Index:1 /MountDir:"C:\WinPE_amd64_PS\mount"


新增powershell元件
Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-WMI.cab"

Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-WMI_en-us.cab"

Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-NetFX.cab"

Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-NetFX_en-us.cab"

Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-Scripting.cab"

Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-Scripting_en-us.cab"

Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-PowerShell.cab"

Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-PowerShell_en-us.cab"

Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-StorageWMI.cab"

Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-StorageWMI_en-us.cab"

如果command fail可以先檢查一下路徑是否正確

5. 複製script到powershell資料夾下

複製DeploymentKit\WcsTest\Scripts\References\Documentation\WinPE底下的三個script  WinPEBootloader.ps1, Start-WcsTools.bat and Start-OcsTools.bat 到 C:\WinPE_amd64_PS\mount\Windows\System32\WindowsPowershell\v1.0

6. FOR USB IMAGE ONLY: 更新powershell 啟動時會執行的profile.ps1

如果沒有profile.ps1就新增一個在C:\WinPE_amd64_PS\mount\Windows\System32\WindowsPowershell\v1.0\
內容為

. x:\Windows\System32\WindowsPowerShell\v1.0\WinPeBootloader.ps1
. x:\WcsTest\Scripts\WcsScripts.ps1

如下






















7. 修改registry 允許 PowerShell 執行scripts

Modify the registry C:\WinPE_amd64_PS\mount\Windows\System32\Config\Software
先load registry:
 reg load HKLM\WimRegistry C:\WinPE_amd64_PS\mount\Windows\System32\Config\Software

執行registry 
Win+X















Add SOFTWARE\Microsoft\PowerShell\1\ShellIds\ExecutionPolicy  RemoteSigned
Add SOFTWARE\Microsoft\PowerShell\<all other values>\ShellIds\ExecutionPolicy  RemoteSigned


修改完後再unload registry (否則卸載WinPE會fail)
reg unload HKLM\WimRegistry



8.  Enable ems to allow SAC

bcdedit /store c:\WinPE_amd64_PS\media\boot\bcd /set {default} ems on
bcdedit /store c:\WinPE_amd64_PS\media\efi\microsoft\boot\bcd /set {default} ems on


9. 卸載image

Dism /Unmount-Image /MountDir:C:\WinPE_amd64_PS\mount /Commit

10. 做成可開機USB

MakeWinPEMedia /UFD C:\WinPE_amd64_PS E:

如果要做成iso檔:
MakeWinPEMedia /ISO C:\WinPE_amd64 C:\WinPE_amd64\WinPE_amd64.iso

11. FOR USB IMAGE ONLY: 將/WcsTest 整個folder 複製到 隨身碟

Xcopy /E /I  ../WcsTest/* F:WcsTest/


這樣包含WcsTest的WinPE就安裝好囉!

開機後執行X:\WcsTest\OCS Toolkit
就可以在WinPE下 Wcs Command了!

沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。