Closed danielniccoli closed 5 years ago
Unfortunately, that's not something we can override in PowerShellGet, see execution policies.
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.
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.
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
**********************
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.
resolving this since the behavior is expected.
@SteveL-MSFT I see, thanks for clarifying this. Then I hope to see the new psreadline shipped with Windows soon.
@Borkason me too!
Steps to reproduce
Expected behavior
Import PowerShellGet module
Actual behavior
Error because of ExecutionPolicy=Restricted.
Environment data