Convert WindowsImage PS1 File

Wiki.TerraBase.info
Revision as of 09:51, 25 January 2018 by Root (talk | contribs)
Jump to navigation Jump to search

Convert-WindowsImage.ps1

First, the disclaimer. This article is not about a step by step of how to use this utility. Rather it is about the problems I ran into using this utility.

Problem #1; Error message and it won't run

Basically I typed the name of the file to run Convert-WindowsImage.ps1 and got a warning and remember immediately that I should have pre-pended .\ to the beginning of it.
.\Convert-WindowsImage.ps1

Problem #2; No error message after using the Set-Execution command and it still won't run

This issue was related to all of the restrictions and protections Microsoft puts in place to protect us from all the evil in the world and at the same time make the PowerShell completely dysfunctional (or so it seems). You've might have already read about and tried the Set-Execution Policy to Unrestricted or Bypass and still have nothing work as happened to me. The key to figuring this out was a simple comment by a contributor on a forum. He said, "...downloaded from the internet." That made me think about these warning dialogs in Windows 10 that would pop up when I opened videos, music files, graphics, or anything else downloaded from the internet that put up an extra warning alluding to the file being from the internet and asking if I really wanted to open the file.

I did download the Convert-WindowsImage.ps1 file from the internet, but wait, it's just a text file, why don't I just create a new text file on my computer and copy and paste the contents of the original file into the new one? So I did. And it worked as the new file I created wasn't downloaded from the internet, but whose origins were local on my computer.

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.