tag:blogger.com,1999:blog-6230024559279811901.post6012793259972946001..comments2023-08-28T14:37:10.715-07:00Comments on I.T. Proctology: PowerShell for reducing the size of a VHDBrianEhhttp://www.blogger.com/profile/09946552115562772058noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-6230024559279811901.post-44524868861363789312013-03-26T15:03:44.910-07:002013-03-26T15:03:44.910-07:00I literally changed one small line:
$newVh...I literally changed one small line:<br /> $newVhdPath = $orgvhd.ImagePath.Split(".")[0] + $partNum +"New." + "vhdx"<br /><br />Forcing the VHDX and assuming the original disk was a VHD.<br />Server 2012 / Windows 8 have some built in assumptions based on the extension. You get the VHD format that the extension defines. That is why you just cannot modify the file extension.<br />BrianEhhttps://www.blogger.com/profile/09946552115562772058noreply@blogger.comtag:blogger.com,1999:blog-6230024559279811901.post-6821109058747305492013-03-26T14:52:46.792-07:002013-03-26T14:52:46.792-07:00You can get sneaky and convert from VHD to VHDX us...You can get sneaky and convert from VHD to VHDX using ImageX / DISM. It is built-in.<br /><br />Take what I did here for example.<br /><br />In this case, simply alter the script to have the opposite disk format as your target. Instead of VHD, have the new disk be VHDX or vice versa.<br /><br />This de-couples you from the dependency on Hyper-V.<br />Yes, you still need Win8 / Server 2012 since they know VHDX.<br />BrianEhhttps://www.blogger.com/profile/09946552115562772058noreply@blogger.comtag:blogger.com,1999:blog-6230024559279811901.post-42009985366593425992013-03-25T08:27:14.555-07:002013-03-25T08:27:14.555-07:00All of the carriage returns are in there properly....All of the carriage returns are in there properly. You should just be able to do a copy and paste into the PowerShell ISE and it will alert you to any problems.<br /><br />The formatting on the screen is not right. (I just edited my template to handle code blocks, lets give it a go).BrianEhhttps://www.blogger.com/profile/09946552115562772058noreply@blogger.comtag:blogger.com,1999:blog-6230024559279811901.post-83006431672737354402013-03-23T18:17:43.422-07:002013-03-23T18:17:43.422-07:00Hello, i came across your script and due to the wa...Hello, i came across your script and due to the way that it got posted and the spacing that exists, it doesn't work and i can't figure out how to make it work properly. Would it be possible for you to also include a link to the script in a properly carriage returned text file that we'd be able to use as reference? Thank you!Nick Mnoreply@blogger.comtag:blogger.com,1999:blog-6230024559279811901.post-13103062216202388712013-03-05T09:52:39.373-08:002013-03-05T09:52:39.373-08:00Ah. Only if you have spaces in your path. ;-)
Bu...Ah. Only if you have spaces in your path. ;-)<br />But yes, that would cover both cases. Nice catch.<br />(I just avoid spaces in paths these days - my bad assumption).<br />BrianEhhttps://www.blogger.com/profile/09946552115562772058noreply@blogger.comtag:blogger.com,1999:blog-6230024559279811901.post-75412583631770221022013-03-05T09:24:56.278-08:002013-03-05T09:24:56.278-08:00$newVhdPath must be between quotes in the $diskPar...$newVhdPath must be between quotes in the $diskPart = @" section :<br /> create vdisk file="$newVhdPath" type=expandable maximum=$newSize<br /> select vdisk file="$newVhdPath"<br /><br />Amazing work :)Anonymousnoreply@blogger.com