[R2 Gold:] install on R2 ends with red lines in Powershell command prompt :-(

Feb 20, 2010 at 11:14 AM

Hi there, still no joy as "R2 gold" setup fails when importing modules.
I installed the Jan 18th package from an elevated administrator command line,
on a brand new WS 2008 R2 Enterprise, en-US.

The exact message is:
Import-Module : There were errors in loading the format data file:
Microsoft.PowerShell, , C:\Program Files\modules\Hyperv\hyperv.Format.ps1xml : File skipped bec
ause of the following validation exception: File C:\Program Files\modules\Hyperv\hyperv.Format.
ps1xml cannot be loaded. The file C:\Program Files\modules\Hyperv\hyperv.Format.ps1xml is not d
igitally signed. The script will not execute on the system. Please see "get-help about_signing"
 for more details...
At line:1 char:14
+ Import-Module <<<<  'C:\Program Files\modules\Hyperv'
    + CategoryInfo          : InvalidOperation: (:) [Import-Module], RuntimeException
    + FullyQualifiedErrorId : FormatXmlUpateException,Microsoft.PowerShell.Commands.ImportModu
   leCommand

so, where I am wrong?
do I need to "set-executionpolicy unrestricted" first? how to make it permanent, as when I re-run PS, it's back in signed?

Thanks,
another MS Evangelist, from Paris, France :-).

Feb 22, 2010 at 6:55 PM
Edited Feb 22, 2010 at 7:45 PM

First, default execution policy is set to restricted by design as protection against downloaded (either deliberate or maliciously delivered) scripts. 

A few options here, you can run "set-executionpolicy unrestricted", then run the import if you are mainly interested in checking functionality.  Of course, this is only as long as the session lasts, which would lead you to adding it to your profile so you won't run into it again.  I wouldn't do this under any circumstances on anything other than a test machine. 

The best option is to check the code and if you trust it's not going to do harm, modify the module files properties and unblock them.  Right-click the file, under 'General', at the bottom of the tab, under the file attributes, you should see 'Security' if the file was downloaded.  Click the 'Unblock' button to remove the flag.  This allows the files to be run under regular execution policy settings.

Here's a great article and code to unblock files from within PS.  I use it instead of stepping through each file via explorer.

And the last, converted into a small set of cmdlets.

Another option is to sign certs yourself.  I won't go into the methods to get a cert; those are well documented.  Here's a method to automatically sign certs. 

 

Dec 13, 2010 at 3:38 PM

I found this thread as I originally had the same error.

I had my policy set to:  Set-ExecutionPolicy RemoteSigned

From the advice above I changed it to:   set-executionpolicy unrestricted

 

I now receive a different error, and not quite sure what to do.

I did try running install cmd file at some point in trying to get this working, not sure if this complicated the issue.

 

Here is the error I get now when trying to run the Import-Module command:

 

PS C:\Users\admin\Documents\HyperV_Install> Import-Module C:\Users\admin\Documents\HyperV_Install\HyperV.psd1
Import-Module : There were errors in loading the format data file:
Microsoft.PowerShell, C:\Users\admin\Documents\HyperV_Install\HyperV_Install\hyperv.Format.ps1xml : File not found
.
Microsoft.PowerShell, C:\MyUser\PowerShell-HyperV-Module\HyperV_Install\hyperv.Format.ps1xml : File skipped because i
t was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\MyUser\PowerShell-HyperV-Module\HyperV_Install\hyperv.Format.ps1xml : File skipped because i
t was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\MyUser\PowerShell-HyperV-Module\HyperV_Install\hyperv.Format.ps1xml : File skipped because i
t was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\MyUser\PowerShell-HyperV-Module\HyperV_Install\hyperv.Format.ps1xml : File skipped because i
t was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\MyUser\PowerShell-HyperV-Module\HyperV_Install\hyperv.Format.ps1xml : File skipped because i
t was already present from "Microsoft.PowerShell".
At line:1 char:14
+ Import-Module <<<<  C:\Users\admin\Documents\HyperV_Install\HyperV.psd1
    + CategoryInfo          : InvalidOperation: (:) [Import-Module], RuntimeException
    + FullyQualifiedErrorId : FormatXmlUpateException,Microsoft.PowerShell.Commands.ImportModuleCommand

 


Any advice on this would be much appreciated.

Thank you

 

Jan 20, 2011 at 4:19 PM

I had this exact same issue. I fixed it by mapping the C drive of the Hyper-V (Server Core) host server to a workstation. I then right click each file in the downloaded zip file, hit properties and clicked on Unblock. This is so much easier than having to do the coding as decribed above. After that, I ran the install.cmd and it installed fine with no red text errors. Be sure to do this on every file in the downloaded zip file.

Coordinator
Feb 4, 2011 at 12:22 PM
mschatte wrote:

I had this exact same issue. I fixed it by mapping the C drive of the Hyper-V (Server Core) host server to a workstation. I then right click each file in the downloaded zip file, hit properties and clicked on Unblock. This is so much easier than having to do the coding as decribed above. After that, I ran the install.cmd and it installed fine with no red text errors. Be sure to do this on every file in the downloaded zip file.

 Alternatively Unblock the zip file before unzipping it.

Jul 13, 2011 at 9:51 AM

This issue has been posted a while back, but I ran into the same issue natv was going through.. I fixed it by moving the Module Folder to the PSPATH indicated by the system variable. Once there I had no issues importing the library.

An interesting issue was that running the install with the folder on a drive different than C, I was able to use the the v1.0 powershell interface and not the ISE. Moving the library file to the PSPAth resolved that issue as well.