GoogleCloudPlatform / google-cloud-powershell

PowerShell cmdlets for the Google Cloud Platform
http://googlecloudplatform.github.io/google-cloud-powershell/
Apache License 2.0
135 stars 61 forks source link

'Import-Module GoogleCloud' fails when PowerShell ExecutionPolicy is set to 'AllSigned' #602

Closed wdwinslow closed 6 years ago

wdwinslow commented 6 years ago

We recently changed our PowerShell Execution Policy domain wide to AllSigned.

Some GCP PowerShell scripts - such as the Compute Engine auto updater are digitally signed and work fine with this policy. For example: C:\Program Files\Google\Compute Engine\tools\auto_updater.ps1

However, after setting this policy we are unable to run Import-Module GoogleCloud. Doing so yields this error.

Import-Module : Errors occurred while loading the format data file:
C:\Program Files (x86)\Google\Cloud
SDK\google-cloud-sdk\platform\PowerShell\GoogleCloud\1.0.1.4\GoogleCloudPlatform.Format.ps1xml, , C:\Program Files
(x86)\Google\Cloud SDK\google-cloud-sdk\platform\PowerShell\GoogleCloud\1.0.1.4\GoogleCloudPlatform.Format.ps1xml: The
file was skipped because of the following validation exception: File C:\Program Files (x86)\Google\Cloud
SDK\google-cloud-sdk\platform\PowerShell\GoogleCloud\1.0.1.4\GoogleCloudPlatform.Format.ps1xml cannot be loaded. The
file C:\Program Files (x86)\Google\Cloud
SDK\google-cloud-sdk\platform\PowerShell\GoogleCloud\1.0.1.4\GoogleCloudPlatform.Format.ps1xml is not digitally
signed. You cannot run this script on the current system. For more information about running scripts and setting
execution policy, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170..
At line:1 char:1
+ Import-Module GoogleCloud
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Import-Module], RuntimeException
    + FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand

Is this something you all could resolve?

quoctruong commented 6 years ago

@wdwinslow Did you have any problem before changing the Policy to AllSigned? We can look into signing the scripts and I think this will solve the problem.

wdwinslow commented 6 years ago

@quoctruong Everything works perfectly with PowerShell Execution set to RemoteSigned. Thanks for your help!