PowerShell / PowerShellGetv2

PowerShellGet is the Package Manager for PowerShell
https://www.PowerShellGallery.com
MIT License
432 stars 138 forks source link

PowerShellGet throwing error if ExecutionPolicy is Restricted #449

Closed danielniccoli closed 5 years ago

danielniccoli commented 5 years ago

Steps to reproduce

  1. Install PowerShellGet
**********************
Windows PowerShell transcript start
Start time: 20190320233412
Username: OCTOPUS\Daniel
RunAs User: OCTOPUS\Daniel
Configuration Name: 
Machine: OCTOPUS (Microsoft Windows NT 10.0.18860.0)
Host Application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Process ID: 3392
PSVersion: 5.1.18860.1001
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.18860.1001
BuildVersion: 10.0.18860.1001
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
**********************
Transcript started, output file is c:\install-module.txt
PS C:\WINDOWS\system32> Install-Module PowerShellGet -Force -AllowClobber -Debug -Verbose -Scope AllUsers
DEBUG: 00:00:00.0000002 Calling New() : MethodName = 'GetDynamicOptions'
Confirm
Continue with this operation?
&Yes  Yes to &All  &Halt Command  &Suspend
A
DEBUG: 00:00:00.0001802 Force: True
DEBUG: 00:00:00.0002063 Debug: True
DEBUG: 00:00:00.0002319 Name: PowerShellGet
DEBUG: 00:00:00.0002424 Verbose: True
DEBUG: 00:00:00.0011195 INVOKING PowerShell Fn Get-DynamicOptions with args Provider that has length 1
DEBUG: 00:00:00.0133411 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0283911 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:00.0316123 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0316287 Force: True
DEBUG: 00:00:00.0316390 Debug: True
DEBUG: 00:00:00.0316488 Name: PowerShellGet
DEBUG: 00:00:00.0316759 Verbose: True
DEBUG: 00:00:00.0323191 INVOKING PowerShell Fn Get-DynamicOptions with args Source that has length 1
DEBUG: 00:00:00.0328821 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0346787 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:00.0369957 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0370112 Force: True
DEBUG: 00:00:00.0370213 Debug: True
DEBUG: 00:00:00.0370308 Name: PowerShellGet
DEBUG: 00:00:00.0370402 Verbose: True
DEBUG: 00:00:00.0376238 INVOKING PowerShell Fn Get-DynamicOptions with args Package that has length 1
DEBUG: 00:00:00.0382658 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0444572 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:00.0467530 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0467685 Force: True
DEBUG: 00:00:00.0467788 Debug: True
DEBUG: 00:00:00.0467884 Name: PowerShellGet
DEBUG: 00:00:00.0467980 Verbose: True
DEBUG: 00:00:00.0474145 INVOKING PowerShell Fn Get-DynamicOptions with args Install that has length 1
DEBUG: 00:00:00.0479543 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0504055 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:01.2773398 Calling SearchForPackages. Name='PowerShellGet'
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
DEBUG: 00:00:01.2882084 PackageProvider::FindPackage with name PowerShellGet
DEBUG: 00:00:01.2887280 Calling SearchForPackages After Select 1
DEBUG: 00:00:01.3248470 Calling New() : MethodName = 'FindPackage'
DEBUG: 00:00:01.3282060 ProviderName: PowerShellGet
DEBUG: 00:00:01.3296256 Type: Module
DEBUG: 00:00:01.3308462 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:01.3326437 AllowClobber: True
DEBUG: 00:00:01.3337389 Force: True
DEBUG: 00:00:01.3349294 Debug: True
DEBUG: 00:00:01.3372360 Scope: AllUsers
DEBUG: 00:00:01.3383274 Verbose: True
DEBUG: 00:00:01.3403440 Name: PowerShellGet
DEBUG: 00:00:01.3417698 INVOKING PowerShell Fn Find-Package with args System.String[], , ,  that has length 4
DEBUG: 00:00:01.3947968 In PowerShellGet Provider - 'Find-Package'.
DEBUG: 00:00:01.4469864 OPTION: ProviderName => PowerShellGet
DEBUG: 00:00:01.4509989 OPTION: Type => Module
DEBUG: 00:00:01.4531651 OPTION: MessageResolver => Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:01.4544218 OPTION: AllowClobber => True
DEBUG: 00:00:01.4559003 OPTION: Force => True
DEBUG: 00:00:01.4581643 OPTION: Debug => True
DEBUG: 00:00:01.4608679 OPTION: Scope => AllUsers
DEBUG: 00:00:01.4631566 OPTION: Verbose => True
DEBUG: 00:00:01.4649134 OPTION: Name => PowerShellGet
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
DEBUG: 00:00:01.5490056 PackageProvider::FindPackage with name PowerShellGet
DEBUG: 00:00:01.5570322 Calling 'NuGet'::'FindPackage' - name='PowerShellGet', requiredVersion='',minimumVersion='', maximumVersion='''.
DEBUG: 00:00:01.5612693 Iterating 'PowerShellGet'.
DEBUG: 00:00:01.5756434 Calling 'NuGetRequest'::'RegisteredPackageSources', 'C:\Users\Daniel\AppData\Roaming\NuGet\nuget.config'.
DEBUG: 00:00:01.5803089 Loading a configuration from file 'C:\Users\Daniel\AppData\Roaming\NuGet\nuget.config'.
DEBUG: 00:00:01.5836702 Loaded a configuration from file 'C:\Users\Daniel\AppData\Roaming\NuGet\nuget.config'.
DEBUG: 00:00:01.5866725 There are '0' registered sources in 'NuGet' provider.
DEBUG: 00:00:01.5893705 Source 'https://www.powershellgallery.com/api/v2' is not one of the registered sources in 'NuGet' provider.
DEBUG: 00:00:02.4102099 Source 'https://www.powershellgallery.com/api/v2' is validated.
DEBUG: 00:00:02.4136453 Calling 'NuGetRequest'::'GetPackageById', 'PowerShellGet'.
DEBUG: 00:00:02.7008622 Calling 'HttpClientPackageRepository'::'FindPackagesById', 'PowerShellGet'.
DEBUG: 00:00:02.7405737 Calling 'NuGetClient'::'FindPackage'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PowerShellGet'' for ''.
DEBUG: 00:00:02.7626467 Downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PowerShellGet'&$skip=0&$top=40'.
DEBUG: 00:00:03.5560766 Completed downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PowerShellGet'&$skip=0&$top=40'.
DEBUG: 00:00:03.5700530 '18' packages received in the last request.
VERBOSE: Total package yield:'1' for the specified package 'PowerShellGet'.
DEBUG: 00:00:03.6349702 Completed iterating for 'PowerShellGet'.
DEBUG: 00:00:03.8254358 Done calling powershell «Find-Package» «PSModule»
DEBUG: 00:00:03.8471895 Calling New() : MethodName = 'GetInstalledPackages'
DEBUG: 00:00:03.8516315 ProviderName: PowerShellGet
DEBUG: 00:00:03.8531475 Type: Module
DEBUG: 00:00:03.8547060 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:03.8558482 AllowClobber: True
DEBUG: 00:00:03.8576597 Force: True
DEBUG: 00:00:03.8588000 Debug: True
DEBUG: 00:00:03.8603322 Scope: AllUsers
DEBUG: 00:00:03.8615069 Verbose: True
DEBUG: 00:00:03.8625670 Name: PowerShellGet
DEBUG: 00:00:03.8644487 INVOKING PowerShell Fn Get-InstalledPackage with args PowerShellGet, 2.1.2, ,  that has length 4
DEBUG: 00:00:03.8742337 In PowerShellGet Provider - 'Get-InstalledPackage'.
DEBUG: 00:00:03.8785387 OPTION: ProviderName => PowerShellGet
DEBUG: 00:00:03.8805597 OPTION: Type => Module
DEBUG: 00:00:03.8827251 OPTION: MessageResolver => Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:03.8839694 OPTION: AllowClobber => True
DEBUG: 00:00:03.8855773 OPTION: Force => True
DEBUG: 00:00:03.8873053 OPTION: Debug => True
DEBUG: 00:00:03.8885901 OPTION: Scope => AllUsers
DEBUG: 00:00:03.8900498 OPTION: Verbose => True
DEBUG: 00:00:03.8913228 OPTION: Name => PowerShellGet
DEBUG: 00:00:03.9892464 PowerShell Script 'PSModule' Function 'Get-InstalledPackage' returns null.
DEBUG: 00:00:03.9934035 Done calling powershell «Get-InstalledPackage» «PSModule»
Confirm
Are you sure you want to perform this action?
Performing the operation "Install-Module" on target "Version '2.1.2' of module 'PowerShellGet'".
&Yes  Yes to &All  &No  No to A&ll  &Suspend
A
DEBUG: 00:00:10.5975179 Calling New() : MethodName = 'InstallPackage'
DEBUG: 00:00:10.6022729 ProviderName: PowerShellGet
DEBUG: 00:00:10.6038851 Type: Module
DEBUG: 00:00:10.6058156 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:10.6069777 AllowClobber: True
DEBUG: 00:00:10.6081556 Force: True
DEBUG: 00:00:10.6093171 Debug: True
DEBUG: 00:00:10.6104523 Scope: AllUsers
DEBUG: 00:00:10.6128773 Verbose: True
DEBUG: 00:00:10.6140836 Name: PowerShellGet
DEBUG: 00:00:10.6159577 INVOKING PowerShell Fn Install-Package with args NuGet|PowerShellGet|2.1.2|https://www.powershellgallery.com/api/v2|Module that has length 1
DEBUG: 00:00:10.6238380 In PowerShellGet Provider - 'Install-Package'.
DEBUG: 00:00:10.6645339 In PowerShellGet Provider - 'Install-PackageUtility'.
DEBUG: 00:00:10.6676496 The FastPackageReference is 'NuGet|PowerShellGet|2.1.2|https://www.powershellgallery.com/api/v2|Module'.
DEBUG: 00:00:10.6733083 OPTION: ProviderName => PowerShellGet
DEBUG: 00:00:10.6773418 OPTION: Type => Module
DEBUG: 00:00:10.6792468 OPTION: MessageResolver => Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:10.6815545 OPTION: AllowClobber => True
DEBUG: 00:00:10.6837429 OPTION: Force => True
DEBUG: 00:00:10.6851009 OPTION: Debug => True
DEBUG: 00:00:10.6882553 OPTION: Scope => AllUsers
DEBUG: 00:00:10.6894984 OPTION: Verbose => True
DEBUG: 00:00:10.6913573 OPTION: Name => PowerShellGet
VERBOSE: The installation scope is specified to be 'AllUsers'.
VERBOSE: The specified module will be installed in 'C:\Program Files\WindowsPowerShell\Modules'.
DEBUG: 00:00:10.7078129 ArtifactType is Module
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading module 'PowerShellGet' with version '2.1.2' from the repository 'https://www.powershellgallery.com/api/v2'.
DEBUG: 00:00:10.7757409 Calling 'NuGet'::'InstallPackage', '$aHR0cHM6Ly93d3cucG93ZXJzaGVsbGdhbGxlcnkuY29tL2FwaS92Mg==\UG93ZXJTaGVsbEdldA==\Mi4xLjI=\aHR0cHM6Ly93d3cucG93ZXJzaGVsbGdhbGxlcnkuY29tL2FwaS92Mg==\cG93ZXJzaGVsbGdldA=='.
DEBUG: 00:00:10.7778788 Calling 'NuGetRequest'::'GetPackageByFastpath', '$aHR0cHM6Ly93d3cucG93ZXJzaGVsbGdhbGxlcnkuY29tL2FwaS92Mg==\UG93ZXJTaGVsbEdldA==\Mi4xLjI=\aHR0cHM6Ly93d3cucG93ZXJzaGVsbGdhbGxlcnkuY29tL2FwaS92Mg==\cG93ZXJzaGVsbGdldA=='.
DEBUG: 00:00:10.7814197 Calling 'NuGetRequest'::'ResolvePackageSource', 'https://www.powershellgallery.com/api/v2'.
DEBUG: 00:00:10.7831323 Calling 'NuGetRequest'::'FindRegisteredSource', 'https://www.powershellgallery.com/api/v2'.
DEBUG: 00:00:10.7856985 Source 'https://www.powershellgallery.com/api/v2' is not one of the registered sources in 'NuGet' provider.
DEBUG: 00:00:11.8707383 Calling 'HttpClientPackageRepository'::'FindPackage', 'PowerShellGet'.
DEBUG: 00:00:11.8820669 Calling 'NuGetClient'::'FindPackage'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PowerShellGet'' for ''.
DEBUG: 00:00:11.9068534 Downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PowerShellGet'&$skip=0&$top=40'.
DEBUG: 00:00:12.5106204 Completed downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PowerShellGet'&$skip=0&$top=40'.
DEBUG: 00:00:12.5148857 '18' packages received in the last request.
DEBUG: 00:00:12.5271720 'Package version' is '2.1.2'.
DEBUG: 00:00:12.5287702 'Request's Destination' is 'C:\Users\Daniel\AppData\Local\Temp\1051964010'.
DEBUG: 00:00:12.5358285 Calling 'NuGetClient'::'GetPackageDependencies'.
DEBUG: 00:00:12.5463805 There are '0' registered sources in 'NuGet' provider.
DEBUG: 00:00:12.5507643 Source 'https://www.powershellgallery.com/api/v2' is not one of the registered sources in 'NuGet' provider.
DEBUG: 00:00:12.8257444 Source 'https://www.powershellgallery.com/api/v2' is validated.
DEBUG: 00:00:12.8338951 Calling 'NuGetRequest'::'GetPackageById', 'PackageManagement'.
DEBUG: 00:00:13.1095734 Calling 'HttpClientPackageRepository'::'FindPackagesById', 'PackageManagement'.
DEBUG: 00:00:13.1216834 Calling 'NuGetClient'::'FindPackage'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PackageManagement'' for ''.
DEBUG: 00:00:13.1497889 Downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PackageManagement'&$skip=0&$top=40'.
DEBUG: 00:00:13.3007463 Completed downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PackageManagement'&$skip=0&$top=40'.
DEBUG: 00:00:13.3157620 '14' packages received in the last request.
DEBUG: 00:00:13.3288115 Returning the call 'NuGetClient'::'GetPackageDependencies'.
DEBUG: 00:00:13.4324496 Calling 'NuGetClient'::'InstallPackage'.
VERBOSE: InstallPackage' - name='PackageManagement', version='1.3.1',destination='C:\Users\Daniel\AppData\Local\Temp\1051964010'
VERBOSE: DownloadPackage' - name='PackageManagement', version='1.3.1',destination='C:\Users\Daniel\AppData\Local\Temp\1051964010\PackageManagement\PackageManagement.nupkg', uri='https://www.powershellgallery.com/api/v2/package/PackageManagement/1.3.1'
VERBOSE: Downloading 'https://www.powershellgallery.com/api/v2/package/PackageManagement/1.3.1'.
VERBOSE: Completed downloading 'https://www.powershellgallery.com/api/v2/package/PackageManagement/1.3.1'.
VERBOSE: Completed downloading 'PackageManagement'.
VERBOSE: Hash for package 'PackageManagement' does not match hash provided from the server.
DEBUG: 00:00:14.2771129 Calling 'NuGetClient'::'InstallPackageLocal'.
VERBOSE: InstallPackageLocal' - name='PackageManagement', version='1.3.1',destination='C:\Users\Daniel\AppData\Local\Temp\1051964010'
DEBUG: 00:00:14.2849035 C:\Users\Daniel\AppData\Local\Temp\1051964010\PackageManagement\PackageManagement.nupkg
DEBUG: 00:00:14.7194584 Returning the call 'NuGetClient'::'InstallPackageLocal'.
DEBUG: 00:00:14.7660392 Returning the call 'NuGetClient'::'InstallSinglePackage'.
DEBUG: 00:00:14.7901191 Calling 'NuGetClient'::'InstallPackage'.
VERBOSE: InstallPackage' - name='PowerShellGet', version='2.1.2',destination='C:\Users\Daniel\AppData\Local\Temp\1051964010'
VERBOSE: DownloadPackage' - name='PowerShellGet', version='2.1.2',destination='C:\Users\Daniel\AppData\Local\Temp\1051964010\PowerShellGet\PowerShellGet.nupkg', uri='https://www.powershellgallery.com/api/v2/package/PowerShellGet/2.1.2'
VERBOSE: Downloading 'https://www.powershellgallery.com/api/v2/package/PowerShellGet/2.1.2'.
VERBOSE: Completed downloading 'https://www.powershellgallery.com/api/v2/package/PowerShellGet/2.1.2'.
VERBOSE: Completed downloading 'PowerShellGet'.
VERBOSE: Hash for package 'PowerShellGet' does not match hash provided from the server.
DEBUG: 00:00:15.3132645 Calling 'NuGetClient'::'InstallPackageLocal'.
VERBOSE: InstallPackageLocal' - name='PowerShellGet', version='2.1.2',destination='C:\Users\Daniel\AppData\Local\Temp\1051964010'
DEBUG: 00:00:15.3232654 C:\Users\Daniel\AppData\Local\Temp\1051964010\PowerShellGet\PowerShellGet.nupkg
DEBUG: 00:00:15.5677973 Returning the call 'NuGetClient'::'InstallPackageLocal'.
DEBUG: 00:00:15.5926591 Returning the call 'NuGetClient'::'InstallSinglePackage'.
DEBUG: 00:00:15.8667065 Catalog file 'PackageManagement.cat' is not found in the contents of the previously-installed module 'PackageManagement' with the same name.
DEBUG: 00:00:15.8715066 Using the previously-installed module 'PackageManagement' with version '1.0.0.1' under 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1' for getting the publisher details.
DEBUG: 00:00:15.8743071 Using the 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\PackageManagement.psd1' file for getting the authenticode signature.
DEBUG: 00:00:16.2153354 For publisher validation, using the previously-installed module 'PackageManagement' with version '1.0.0.1' under 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1' with publisher name 'CN=Microsoft Development Root Certificate Authority 2014, O=Microsoft Corporation, L=Redmond, S=Washington, C=US'. Is this module signed by Microsoft: 'True'.
VERBOSE: Found the catalog file 'PackageManagement.cat' in the module 'PackageManagement' contents.
VERBOSE: Valid authenticode signature found in the catalog file 'PackageManagement.cat' for the module 'PackageManagement'.
VERBOSE: Validating the 'PackageManagement' module files for catalog signing using the catalog file 'PackageManagement.cat'.
VERBOSE: The catalog signature in 'PackageManagement.cat' of the module 'PackageManagement' is valid and matches with the hash generated from the module contents.
DEBUG: 00:00:16.9506518 For publisher validation, current module 'PackageManagement' with version '1.3.1' with publisher name 'CN=Microsoft Root Certificate Authority 2011, O=Microsoft Corporation, L=Redmond, S=Washington, C=US'. Is this module signed by Microsoft: 'True'.
VERBOSE: For publisher validation, current module 'PackageManagement' with version '1.3.1' with publisher name 'CN=Microsoft Root Certificate Authority 2011, O=Microsoft Corporation, L=Redmond, S=Washington, C=US'. Is this module signed by Microsoft: 'True'.
VERBOSE: For publisher validation, using the previously-installed module 'PackageManagement' with version '1.0.0.1' under 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1' with publisher name 'CN=Microsoft Development Root Certificate Authority 2014, O=Microsoft Corporation, L=Redmond, S=Washington, C=US'. Is this module signed by Microsoft: 'True'.
DEBUG: 00:00:16.9649590 Previously-installed module publisher: CN=Microsoft Development Root Certificate Authority 2014, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
DEBUG: 00:00:16.9672301 Current module publisher: CN=Microsoft Root Certificate Authority 2011, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
DEBUG: 00:00:16.9698907 Is previously-installed module signed by Microsoft: True
DEBUG: 00:00:16.9719915 Is current module signed by Microsoft: True
VERBOSE: Publisher 'CN=Microsoft Root Certificate Authority 2011, O=Microsoft Corporation, L=Redmond, S=Washington, C=US' of the new module 'PackageManagement' with version '1.3.1' matches with the publisher 'CN=Microsoft Development Root Certificate Authority 2014, O=Microsoft Corporation, L=Redmond, S=Washington, C=US' of the previously-installed module 'PackageManagement' with version '1.0.0.1'. Both versions are signed with a Microsoft root certificate.
VERBOSE: Installing the dependency module 'PackageManagement' with version '1.3.1' for the module 'PowerShellGet'.
VERBOSE: Module 'PackageManagement' was installed successfully to path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.3.1'.
DEBUG: 00:00:17.4487157 Catalog file 'PowerShellGet.cat' is not found in the contents of the previously-installed module 'PowerShellGet' with the same name.
DEBUG: 00:00:17.4541445 Using the previously-installed module 'PowerShellGet' with version '1.0.0.1' under 'C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1' for getting the publisher details.
DEBUG: 00:00:17.4577333 Using the 'C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PowerShellGet.psd1' file for getting the authenticode signature.
DEBUG: 00:00:17.5404347 For publisher validation, using the previously-installed module 'PowerShellGet' with version '1.0.0.1' under 'C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1' with publisher name 'CN=Microsoft Development Root Certificate Authority 2014, O=Microsoft Corporation, L=Redmond, S=Washington, C=US'. Is this module signed by Microsoft: 'True'.
VERBOSE: Found the catalog file 'PowerShellGet.cat' in the module 'PowerShellGet' contents.
VERBOSE: Valid authenticode signature found in the catalog file 'PowerShellGet.cat' for the module 'PowerShellGet'.
VERBOSE: Validating the 'PowerShellGet' module files for catalog signing using the catalog file 'PowerShellGet.cat'.
VERBOSE: The catalog signature in 'PowerShellGet.cat' of the module 'PowerShellGet' is valid and matches with the hash generated from the module contents.
DEBUG: 00:00:17.7246682 For publisher validation, current module 'PowerShellGet' with version '2.1.2' with publisher name 'CN=Microsoft Root Certificate Authority 2011, O=Microsoft Corporation, L=Redmond, S=Washington, C=US'. Is this module signed by Microsoft: 'True'.
VERBOSE: For publisher validation, current module 'PowerShellGet' with version '2.1.2' with publisher name 'CN=Microsoft Root Certificate Authority 2011, O=Microsoft Corporation, L=Redmond, S=Washington, C=US'. Is this module signed by Microsoft: 'True'.
VERBOSE: For publisher validation, using the previously-installed module 'PowerShellGet' with version '1.0.0.1' under 'C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1' with publisher name 'CN=Microsoft Development Root Certificate Authority 2014, O=Microsoft Corporation, L=Redmond, S=Washington, C=US'. Is this module signed by Microsoft: 'True'.
DEBUG: 00:00:17.7407546 Previously-installed module publisher: CN=Microsoft Development Root Certificate Authority 2014, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
DEBUG: 00:00:17.7438065 Current module publisher: CN=Microsoft Root Certificate Authority 2011, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
DEBUG: 00:00:17.7465407 Is previously-installed module signed by Microsoft: True
DEBUG: 00:00:17.7480676 Is current module signed by Microsoft: True
VERBOSE: Publisher 'CN=Microsoft Root Certificate Authority 2011, O=Microsoft Corporation, L=Redmond, S=Washington, C=US' of the new module 'PowerShellGet' with version '2.1.2' matches with the publisher 'CN=Microsoft Development Root Certificate Authority 2014, O=Microsoft Corporation, L=Redmond, S=Washington, C=US' of the previously-installed module 'PowerShellGet' with version '1.0.0.1'. Both versions are signed with a Microsoft root certificate.
VERBOSE: Module 'PowerShellGet' was installed successfully to path 'C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.1.2'.
DEBUG: 00:00:17.8628738 Done calling powershell «Install-Package» «PSModule»
PS C:\WINDOWS\system32> stop-transcript
**********************
Windows PowerShell transcript end
End time: 20190320233450
**********************
  1. Exit powershell and start a new session. Then try to import module PowerShellGet.
**********************
Windows PowerShell transcript start
Start time: 20190320233509
Username: OCTOPUS\Daniel
RunAs User: OCTOPUS\Daniel
Configuration Name: 
Machine: OCTOPUS (Microsoft Windows NT 10.0.18860.0)
Host Application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Process ID: 1504
PSVersion: 5.1.18860.1001
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.18860.1001
BuildVersion: 10.0.18860.1001
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
**********************
Transcript started, output file is c:\import-module.txt
PS C:\WINDOWS\system32> import-module powershellget
PS C:\WINDOWS\system32> TerminatingError(Import-Module): "File C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.3.1\PackageManagement.psm1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170."
>> TerminatingError(Import-Module): "File C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.3.1\PackageManagement.psm1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170."
Import-Module : File C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.3.1\PackageManagement.psm1 cannot 
be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at 
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ import-module powershellget
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [Import-Module], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : File C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.3.1\PackageManagement.psm1 cannot
be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ import-module powershellget
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [Import-Module], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand
PS C:\WINDOWS\system32> import-module powershellget -Debug -Version
>> TerminatingError(Import-Module): "Missing an argument for parameter 'MinimumVersion'. Specify a parameter of type 'System.Version' and try again."
Import-Module : Missing an argument for parameter 'MinimumVersion'. Specify a parameter of type 'System.Version' and 
try again.
At line:1 char:36
+ import-module powershellget -Debug -Version
+                                    ~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Import-Module], ParameterBindingException
    + FullyQualifiedErrorId : MissingArgument,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : Missing an argument for parameter 'MinimumVersion'. Specify a parameter of type 'System.Version' and
try again.
At line:1 char:36
+ import-module powershellget -Debug -Version
+                                    ~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Import-Module], ParameterBindingException
    + FullyQualifiedErrorId : MissingArgument,Microsoft.PowerShell.Commands.ImportModuleCommand

PS C:\WINDOWS\system32> import-module powershellget -Debug -Verbose
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\powershellget\2.1.2\powershellget.psd1'.
PS C:\WINDOWS\system32> TerminatingError(Import-Module): "File C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.3.1\PackageManagement.psm1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170."
>> TerminatingError(Import-Module): "File C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.3.1\PackageManagement.psm1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170."
Import-Module : File C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.3.1\PackageManagement.psm1 cannot 
be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at 
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ import-module powershellget -Debug -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [Import-Module], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : File C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.3.1\PackageManagement.psm1 cannot
be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ import-module powershellget -Debug -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [Import-Module], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand

Expected behavior

Import PowerShellGet module

Actual behavior

Error because of ExecutionPolicy=Restricted.

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.18860.1001
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.18860.1001
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
> Get-Module -ListAvailable PowerShellGet,PackageManagement

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}
> Get-PackageProvider -ListAvailable
Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
NuGet                    2.8.5.208        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Contains, AllowPrereleaseVersions, ConfigFile, SkipValidate
PowerShellGet            1.0.0.1          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, InstallUpdate, NoPathUpdate, Filter, Tag, Includes, DscResource, ...
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent
alerickson commented 5 years ago

Unfortunately, that's not something we can override in PowerShellGet, see execution policies.

danielniccoli commented 5 years ago

Are you sure, because https://docs.microsoft.com/en-us/powershell/gallery/installing-psget does not mention executionpolicies at all. And PowerShellGet 1.0.0.1 that ships with Windows 10 does not have an issue either. Just wondering.

edyoung commented 5 years ago

I find that trying to load PowerShellGet 1.0.0.1 or PackageManagement 1.0.0.1 (the Windows in-box versions) fails when ExecutionPolicy is Restricted - ie I can't reporduce your finding that it works. (If it was already imported, then you change the executionpolicy and import it again, you won't see any error because the module is already loaded).

I don't expect this to work, I am afraid. RemoteSigned or AllSigned policies should work though, because both modules are signed.

danielniccoli commented 5 years ago

I find that trying to load PowerShellGet 1.0.0.1 or PackageManagement 1.0.0.1 (the Windows in-box versions) fails when ExecutionPolicy is Restricted.

I think in this case, something on your computer is broken, because I never had this issue. The built-in modules always load with the default Restriced execution policy, regardless of Windows 10 Version or computer I worked on in the past year.

Here I am removing and importing the modules again, to show that.

**********************
Windows PowerShell transcript start
Start time: 20190322191306
Username: OCTOPUS\Daniel
RunAs User: OCTOPUS\Daniel
Configuration Name: 
Machine: OCTOPUS (Microsoft Windows NT 10.0.18860.0)
Host Application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Process ID: 6756
PSVersion: 5.1.18860.1001
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.18860.1001
BuildVersion: 10.0.18860.1001
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
**********************
Transcript started, output file is .\Documents\modules.txt
PS C:\Users\Daniel> get-module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   3.0.0.0    Microsoft.PowerShell.Host           {Start-Transcript, Stop-Transcript}
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con...

PS C:\Users\Daniel> get-module | Remove-Module
PS C:\Users\Daniel> import-module powershellget
PS C:\Users\Daniel> import-module PackageManagement
PS C:\Users\Daniel> Get-ExecutionPolicy
Restricted
PS C:\Users\Daniel> Get-Module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con...
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl...
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Binary     1.0.0.1    PackageManagement                   {Find-Package, Find-PackageProvider, Get-Package, Get-Pack...
Script     1.0.0.1    powershellget                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCap...

PS C:\Users\Daniel> Stop-Transcript
**********************
Windows PowerShell transcript end
End time: 20190322191348
**********************
SteveL-MSFT commented 5 years ago

The difference between PSGet inbox and from PSGallery is the digital signature. The one inbox has the Windows signature so it's trusted implicitly thus restricted doesn't affect it. It's considered part of PowerShell. The one from PSGallery has a Microsoft signature, but that's not the same as the Windows signature, so it's treated as a foreign script (which it is). If you set execution policy to AllSigned, then PSGet from PSGallery works because the signature is trusted. Again, a Microsoft signature is not treated the same as the Windows signature.

edyoung commented 5 years ago

resolving this since the behavior is expected.

danielniccoli commented 5 years ago

@SteveL-MSFT I see, thanks for clarifying this. Then I hope to see the new psreadline shipped with Windows soon.

SteveL-MSFT commented 5 years ago

@Borkason me too!