Convert WindowsImage PS1 File: Difference between revisions
No edit summary |
m Root moved page Convert-WindowsImage.ps1 to Convert WindowsImage PS1 File without leaving a redirect |
||
(3 intermediate revisions by the same user not shown) | |||
Line 14: | Line 14: | ||
== Problem #3; Similar to #2 with no error message and it still won't run == | == Problem #3; Similar to #2 with no error message and it still won't run == | ||
Another tip from another contributor on some forum noted that the entire Convert-WindowsImage.ps1 file was written as a Function. Go ahead, open up the file in a text editor and even if you don't know anything about programming, you'll see that 'Function' delimiter right at the top. In layman's terms it means if you type .\Convert-WindowsImage.ps1, it won't work. Maybe it did in the past (prior to 2018) with other versions of this script or other version of Windows, which is why there are so many sites that instruct one to simply type .\Convert-WindowsImage.ps1 and you'll be on your merry way. But if you're trying this in 2018 or later and using the latest version of the script. | Another tip from another contributor on some forum noted that the entire Convert-WindowsImage.ps1 file was written as a Function. Go ahead, open up the file in a text editor and even if you don't know anything about programming, you'll see that 'Function' delimiter right at the top. In layman's terms it means if you type .\Convert-WindowsImage.ps1, it won't work. Maybe it did in the past (prior to 2018) with other versions of this script or other version of Windows, which is why there are so many sites that instruct one to simply type .\Convert-WindowsImage.ps1 and you'll be on your merry way. But if you're trying this in 2018 or later and using the latest version of the script (dated 2015 for me), then it won't work. | ||
Another contributor from another pointed out a solution would be to put the same command one was typing at the end of the script file. So I did. And it worked. | |||
IE, if you're typing... <syntaxhighlight lang="batch"> | |||
Convert-WindowsImage -SourcePath "F:\WhatEverNamed.ISO" -VHDFormat VHDX -Edition ServerEnterprise -VHDPartition GPT -Verbose | |||
</syntaxhighlight>...at a command line and it isn't doing anything, then put that same command at the very, very, very, last line end of the Convert-WindowsImage.ps1 file.T | |||
=== Tip; === | |||
If you don't know what to put for the -Edition switch, just run it once without the -Edition switch and it will of course error out, but, it will also give you a list of the different 'editions' that are on that DVD, so then add that to the script after the -Edition switch. | |||
== Problem #4; The script just stopped during the generation of the VHDX file == | |||
Really? All these issue aren't enough? No one to reference here. I just hit the CTRL C key combo to kill the script, but that caused it to continue and complete successfully without any errors. Hmmm. Who cares, it worked. | |||
== Can it get worse? YES! == | == Can it get worse? YES! == | ||
OK! Great! I've got my VHDX file and I'm good to go, right? Of course not. After attaching the VHDX file to the Hyper-V VM, it wouldn't start because the VHDX file was still locked, even after terminating the script and checking Task Manager to see if the VHDX file was still in use. Nope, logging | OK! Great! I've got my VHDX file and I'm good to go, right? Of course not. After attaching the VHDX file to the Hyper-V VM, it wouldn't start because the VHDX file was still locked, even after terminating the script and checking Task Manager to see if the VHDX file was still in use. Nope, logging off and logging back on didn't work. Checked what process had the file locked using [https://lockhunter.com/ LockHunter] (I'm not affiliated with this person or company, but it is really useful software so consider contributing to them) and it was locked by a process called System. | ||
=== Tip === | === Tip === | ||
Don't ever end a process called System, especially if it has a PID (Process ID) of 4, which indicates it started fairly early in the Windows boot process and is probably important. Seems obvious. I learned this one about 20 or so years ago in the Windows NT 4 era. | Don't ever end a process called System, especially if it has a PID (Process ID) of 4, which indicates it started fairly early in the Windows boot process and is probably important. Seems obvious. I learned this one about 20 or so years ago in the Windows NT 4 era. | ||
So, reboot the server? Nope, a better idea. A simple one, just like the 'copy and paste' solution mentioned above, I just copied and pasted the VHDX to a new file. And that file wasn't locked. Virtual machine started with VHDX file! | |||
== The End == | == The End == | ||
Line 29: | Line 41: | ||
And another tip from another contributor indicated that indeed the ISO was successfully booting, but was displaying the "Press any key to boot from CD or DVD..." so quickly there wasn't a chance to press a key, let alone see the message. This seemed credible to me as during booting, newer versions of Windows (8 plus I believe) no longer let one press the F8 key during boot to bring up the boot menu, that is unless one configures that to happen ahead of time, which if one is dealing with a crashed system isn't possible. | And another tip from another contributor indicated that indeed the ISO was successfully booting, but was displaying the "Press any key to boot from CD or DVD..." so quickly there wasn't a chance to press a key, let alone see the message. This seemed credible to me as during booting, newer versions of Windows (8 plus I believe) no longer let one press the F8 key during boot to bring up the boot menu, that is unless one configures that to happen ahead of time, which if one is dealing with a crashed system isn't possible. | ||
== The Real End == | == The Origin and the Real Story's End == | ||
My original objective in this story was to convert a server based on Windows Server 2008 R2 to a UEFI Generation 2 machine hosted on a Windows 2016 Server with Hyper-V. | |||
I had read in Microsoft's documentation that Hyper-V on Server 2016 did support Windows Server 2008 R2. And it did. What I didn't read was the fine print about it requiring that W2K8R2 be configured as a Generation 1 machine, not a Generation 2 machine. | |||
I know, I know, even Vista and maybe XP as a 64 bit machine can boot as a UEFI machine, which is the real difference between a Generation 1 and 2 Hyper-V machine. But it isn't about what is possible, it's about what Microsoft allows with their software. So if you don't like Pepsi, have a Coke, IE, ditch Hyper-V and head on over to VMWare. Keep in mind I still use Hyper-V on all of my servers, so I'm not actually recommending VMWare, I'm just pointing out there are other choices if Microsoft makes you unhappy. | |||
== Conclusion == | |||
I can be angry about wasting so many hours on a cause that resulted in a unsatisfactory conclusion. Or I can hope that writing this about my little journey will help someone else on theirs. I'll pick the latter. | |||
Also, if things were right in the world and I had the time to put footnotes in this article attributing all of origins of this story to their original authors just like a properly documented story I would. But I don't. So I'll just say thank you to everyone that gave me the ideas for this tech story and if someone else writes something based on this article and doesn't reference me, I won't feel upset. : ) |