{"id":166988,"date":"2020-10-05T02:22:36","date_gmt":"2020-10-04T18:22:36","guid":{"rendered":"http:\/\/4563.org\/?p=166988"},"modified":"2020-10-05T02:22:36","modified_gmt":"2020-10-04T18:22:36","slug":"%e8%ae%b0%e4%b8%80%e6%ac%a1%e5%b0%86%e6%9f%90%e4%b8%bb%e6%9c%ba%e7%b3%bb%e7%bb%9f%e7%9b%98%e5%a4%87%e4%bb%bd%e4%b8%ba-wim-%e6%96%87%e4%bb%b6%e5%90%8e%e5%9c%a8-hyper-v-%e4%b8%ad%e8%bf%90%e8%a1%8c","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=166988","title":{"rendered":"\u8bb0\u4e00\u6b21\u5c06\u67d0\u4e3b\u673a\u7cfb\u7edf\u76d8\u5907\u4efd\u4e3a wim \u6587\u4ef6\u540e\u5728 Hyper-V \u4e2d\u8fd0\u884c\u7684\u5b9e\u8df5"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u8bb0\u4e00\u6b21\u5c06\u67d0\u4e3b\u673a\u7cfb\u7edf\u76d8\u5907\u4efd\u4e3a wim \u6587\u4ef6\u540e\u5728 Hyper-V \u4e2d\u8fd0\u884c\u7684\u5b9e\u8df5               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Apol1oBelvedere <\/span>  <span><i><\/i> 7<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>1.\u901a\u8fc7 Windows PE \u7cfb\u7edf\u91cc\u7684 CGI \u5907\u4efd\u5de5\u5177\uff0c\u5c06\u7cfb\u7edf\u76d8\u5907\u4efd\u4e3a.wim \u6587\u4ef6\uff0c\u6211\u5bf9\u6587\u4ef6\u9009\u62e9\u4e86\u201c\u9ad8\u5ea6\u538b\u7f29\u201d\u3002<br \/> 2.\u5c06\u6587\u4ef6\u590d\u5236\u5230\u5bbf\u4e3b\u673a\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4:<\/p>\n<pre><code>set-executionpolicy unrestricted -force . .Convert-WindowsImage.ps1 convert-windowsimage -sourcepath D:SYSTEM.wim -workingdirectory D: -VHDType fixed -vhdformat vhdx -vhdpartitionstyle GPT  -edition Professional <\/code><\/pre>\n<p>\u8fd0\u884c\u7ed3\u679c\u51fa\u9519\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre><code>Windows(R) Image to Virtual Hard Disk Converter for Windows(R) 10 Copyright (C) Microsoft Corporation.  All rights reserved. Version 10.0.9000.0.amd64fre.fbl_core1_hyp_dev(mikekol).141224-3000 Beta  INFO   : Image 1 selected (Professional)... INFO   : Creating sparse disk... INFO   : Attaching VHDX... INFO   : Disk initialized with GPT... INFO   : Disk partitioned INFO   : System Partition created INFO   : Boot Partition created INFO   : System Volume formatted (with DiskPart)... INFO   : Boot Volume formatted (with Format-Volume)... INFO   : Access path (G:) has been assigned to the System Volume... INFO   : Access path (\\?Volume{1bd3b598-bdb9-40a4-bcba-\u6b64\u5904\u6d88\u9690}) has been assigned to the Boot Volume... INFO   : Applying image to VHDX. This could take a while... ERROR  : \u4f7f\u7528\u201c1\u201d\u4e2a\u53c2\u6570\u8c03\u7528\u201cApply\u201d\u65f6\u53d1\u751f\u5f02\u5e38:\u201c\u65e0\u6cd5\u521b\u5efa\u76ee\u5f55\u6216\u6587\u4ef6\u3002\u201d \u6ce8\uff1a\u82f1\u6587\u9519\u8bef\u4e3a\uff1aException calling \"Apply\" with \"1\" argument(s): \"The directory or file cannot be created\" INFO   : Log folder is C:UsersADMIN~1AppDataLocalTempConvert-WindowsImage67ca19bf-c94b-46a8-b2e9-\u6b64\u5904\u6d88\u9690  INFO   : Closing Windows image... INFO   : Closing VHDX... INFO   : Done. <\/code><\/pre>\n<p>3.\u9519\u8bef\u539f\u56e0\uff1a<br \/> \u89e3\u51b3\u529e\u6cd5\u7f51\u9875\uff1a https:\/\/gallery.technet.microsoft.com\/scriptcenter\/Convert-WindowsImageps1-0fe23a8f\/view\/Discussions<br \/> \u6b63\u5982 cryptonym \u6240\u8bf4\uff0c\u9700\u8981\u5c06\u5fae\u8f6f\u5b98\u65b9\u4e0b\u8f7d\u7684<code>Convert-WindowsImage.ps1<\/code>\u6587\u4ef6\u8fdb\u884c\u5982\u4e0b\u4fee\u6539\u540e\u8fd0\u884c\u624d\u80fd\u6210\u529f\u3002<\/p>\n<pre><code>cryptonym said: The fix for the \"Apply\" with \"1\" argument error in Win10 1709 appears to be due to a misuse of the arrays. This is totally unrelated to the old \"1 image\" bug. I changed: Line 4205: from: $drive           = $(Get-Partition -Disk $disk).AccessPaths[0] to: $drive           = $(Get-Partition -Disk $disk)[0].AccessPaths[0]  line 4216  from: $driveSystem = $(Get-Partition -Disk $disk).AccessPaths[1] to: $driveSystem = $(Get-Partition -Disk $disk)[1].AccessPaths[0]  line 4220  from: $drive = $(Get-Partition -Disk $disk).AccessPaths[2] to: $drive = $(Get-Partition -Disk $disk)[2].AccessPaths[0]  line 4229 from: $drive = $(Get-Partition -Disk $disk).AccessPaths[1] to: $drive = $(Get-Partition -Disk $disk)[1].AccessPaths[0]  This indexes into the partition list, then gets the 1st (zero based) entry in the list. Before I think it assumed the list only could have 1 entry per partition. It now seems to have 2 for each partition. I have not yet confirmed this works on older OS, but it appears to fix the 1709 issue. Line 4229 is also untested, as I only am doing VMs, but it should be correct.  Hopefully some of the fixes in the comments section make it into the download codebase. This script is a real time saver.  I really won't be testing this, since it is in the MBR partitioning section. The same logic should still apply I believe though.   I installed a 1703 Win10 to test my suggested fix on an older release, and it worked the same. So my proposed changes are not specific to running on 1709, and can safely be used. No need to test what OS you are running if implemented in this manner. <\/code><\/pre>\n<p>4.\u5bf9<code>Convert-WindowsImage.ps1<\/code>\u6587\u4ef6\u8fdb\u884c\u4fee\u6539\u540e\uff0c\u8fd0\u884c\u6b63\u786e\uff0c\u5f97\u5230\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<pre><code>Windows(R) Image to Virtual Hard Disk Converter for Windows(R) 10 Copyright (C) Microsoft Corporation.  All rights reserved. Version 10.0.9000.0.amd64fre.fbl_core1_hyp_dev(mikekol).141224-3000 Beta  INFO   : Image 1 selected (Professional)... INFO   : Creating fixed disk... INFO   : Attaching VHDX... INFO   : Disk initialized with GPT... INFO   : Disk partitioned INFO   : System Partition created INFO   : Boot Partition created INFO   : System Volume formatted (with DiskPart)... INFO   : Boot Volume formatted (with Format-Volume)... INFO   : Access path (G:) has been assigned to the System Volume... INFO   : Access path (H:) has been assigned to the Boot Volume... INFO   : Applying image to VHDX. This could take a while... INFO   : Signing disk... INFO   : Image applied. Making image bootable... INFO   : Drive is bootable. Cleaning up... INFO   : Generating name for VHDX... INFO   : Closing VHDX...  INFO   : Closing Windows image... INFO   : Done. <\/code><\/pre>\n<p>5.\u4f7f\u7528 Hyper-V \u7ba1\u7406\u5668\u65b0\u5efa\u4e8c\u4ee3\u865a\u62df\u673a\uff0c\u5e76\u9009\u62e9\u751f\u6210\u7684 VHDX \u6587\u4ef6\u4f5c\u4e3a\u786c\u76d8\u6587\u4ef6\uff0c\u542f\u52a8\u865a\u62df\u673a\uff0c\u6210\u529f\u8fd0\u884c\u7cfb\u7edf\u3002 \u4ee5\u4e0a\u5b9e\u6d4b\u53ef\u884c\uff0c\u5728\u6b64\u8bb0\u5f55\u4f9b\u5927\u5bb6\u53c2\u8003\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>1<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3687371\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Shilion <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u597d\u6587\u7ae0\uff0c\u8c22\u8c22\u5206\u4eab                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8bb0\u4e00\u6b21\u5c06\u67d0\u4e3b\u673a\u7cfb\u7edf\u76d8\u5907\u4efd\u4e3a wim&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/166988"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=166988"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/166988\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=166988"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=166988"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=166988"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}