Comments (20)
Ok, I have released Microsoft.PowerShell.SecretManagement v1.1.2
and Microsoft.PowerShell.SecretStore v1.0.6
that has the fix. I verified that they run correctly on WindowsPowerShell in WS2016 with .NetFramework 4.6.
https://www.powershellgallery.com/packages/Microsoft.PowerShell.SecretManagement/1.1.2
https://www.powershellgallery.com/packages/Microsoft.PowerShell.SecretStore/1.0.6
from secretmanagement.
Same error here (Windows Server 2016 10.0.14393 Build 14393):
PS C:\> Set-SecretStoreConfiguration -Default
Set-SecretStoreConfiguration : The type initializer for 'Microsoft.PowerShell.SecretStore.Utils' threw an exception.
At line:1 char:1
+ Set-SecretStoreConfiguration -Default
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-SecretStoreConfiguration], TypeInitializationException
+ FullyQualifiedErrorId : System.TypeInitializationException,Microsoft.PowerShell.SecretStore.SetSecretStoreConfiguration
PS C:\> Register-SecretVault -Name 'Test' -ModuleName 'SecretManagement.Keepass' -VaultParameters @{
>> Path = "C:\Users\******\documents\Test.kdbx"
>> UseMasterPassword = $true
>> }
Register-SecretVault : The type initializer for 'Microsoft.PowerShell.SecretManagement.RegisteredVaultCache' threw an exception.
At line:1 char:1
+ Register-SecretVault -Name 'Test' -ModuleName 'SecretManagement.Keepa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Register-SecretVault], TypeInitializationException
+ FullyQualifiedErrorId : System.TypeInitializationException,Microsoft.PowerShell.SecretManagement.RegisterSecretVaultCommand
PS C:\> Get-Module -ListAvailable Microsoft.PowerShell.SecretManagement
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Binary 1.1.1 Microsoft.PowerShell.SecretManag... {Register-SecretVault, Unregister-SecretVault, Get-SecretVault, Set-SecretVaultDefault...}
PS C:\> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.14393.4583
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.4583
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
from secretmanagement.
For what it is worth:
PS C:\> $Error[0].Exception.InnerException
Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
from secretmanagement.
Having the exact same issue on Server 2016:
PS Y:\> Register-SecretVault -Name SecretStore -ModuleName Microsoft.PowerShell.SecretStore -DefaultVault
Register-SecretVault : The type initializer for 'Microsoft.PowerShell.SecretManagement.RegisteredVaultCache'
threw an exception.
At line:1 char:1
+ Register-SecretVault -Name SecretStore -ModuleName Microsoft.PowerShe ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Register-SecretVault], TypeInitializationException
+ FullyQualifiedErrorId : System.TypeInitializationException,Microsoft.PowerShell.SecretManagement.Regis
terSecretVaultCommand
And module and $PSversionTable info:
PS Y:\> get-module *secret*
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Binary 1.0.0 Microsoft.PowerShell.SecretManag... {Get-Secret, Get-SecretInfo, Get-SecretVault, Re...
Binary 1.0.2 microsoft.powershell.secretstore {Get-SecretStoreConfiguration, Reset-SecretStore...
PS Y:\> $psVersionTable
Name Value
---- -----
PSVersion 5.1.14393.4467
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.4467
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Matches Version and build number mentioned by @SamLue above
from secretmanagement.
@SydneyhSmith maybe you can change the status "Needs-Repro-Info"
Or which further info do you need?
If you want reproduce this issue, setup a System with BuildVersion 10.0.14393
If you need more information feel free to contact me.
from secretmanagement.
Thanks for reporting this, and sorry for the delayed response, but I have been busy with other tasks.
Both SecretManagement and SecretStore have a dependency on 'System.Runtime.InteropServices', which is only supported in .NetFramework starting with version 4.7.
I will try to have a fix for this by end of week. In the meantime the workaround is to install .NetFramework 4.7 or greater.
from secretmanagement.
Issue Label Bot is not confident enough to auto-label this issue. See dashboard for more details.
from secretmanagement.
Thanks @SamLue when this error occurs do you have any SecretVaults registered, what is the output of Get-SecretVault
?
from secretmanagement.
Also what version of the module, and PowerShell are you using?
from secretmanagement.
Hello @SydneyhSmith,
thanks for your answer.
Already the implicit Import-Module produces this error.
Also when I try to execute Get-SecretVault:
PS C:\Windows\system32> Get-SecretVault
Get-SecretVault : Der Typeninitialisierer für "Microsoft.PowerShell.SecretManagement.RegisteredVaultCache" hat eine
Ausnahme verursacht.
In Zeile:1 Zeichen:1
+ Get-SecretVault
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-SecretVault], TypeInitializationException
+ FullyQualifiedErrorId : System.TypeInitializationException,Microsoft.PowerShell.SecretManagement.GetSecretVaultC
ommand
PS C:\Windows\system32>
Version is 0.9.0
PS C:\Windows\system32> Get-Module -ListAvailable Microsoft.PowerShell.SecretManagement
Verzeichnis: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Binary 0.9.0 Microsoft.PowerShell.SecretManag... {Register-SecretVault, Unregister-SecretVault, Get-SecretV...
Powershell-Version
PS C:\Windows\system32> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.14393.3866
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.3866
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
from secretmanagement.
I have this problem on every System with an Windows 10 1607 (Windows 10 Enterprise - IOT)
Version Buildnumber
10.0.14393 14393
Maybe an important hint.
from secretmanagement.
Running this command (with the secretstore module installed v0.9.2) Register-SecretVault -Name SecretStore -ModuleName Microsoft.PowerShell.SecretStore -DefaultVault gives us the same error. This is on server 2016. Any more info i can provide to assist?
from secretmanagement.
Any news about it? I'm having the same issue on Windows Server 2016
Register-SecretVault -Name SecretStore -ModuleName Microsoft.PowerShell.SecretStore -DefaultVault
Register-SecretVault : The type initializer for 'Microsoft.PowerShell.SecretManagement.RegisteredVaultCache'
threw an exception.
At line:1 char:1
- Register-SecretVault -Name SecretStore -ModuleName Microsoft.PowerShe ...
-
+ CategoryInfo : NotSpecified: (:) [Register-SecretVault], TypeInitializationException + FullyQualifiedErrorId : System.TypeInitializationException,Microsoft.PowerShell.SecretManagement.Regis terSecretVaultCommand
from secretmanagement.
I've had the exact problem and it was resolved by installing .NET Framework 4.8 Full.
This will quickly show you the Full version installed (if any)
(Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse | Where-Object -FilterScript { $_.name -match 'Full' } | Get-ItemProperty | Where-Object {$_.PSChildName -eq 'Full'}).Version
from secretmanagement.
I am having the same issue as well on 2016 servers at .net 4.6.1. 2016 Servers on .net 4.8 work fine. @PaulHigin @SydneyhSmith is this similar to this issue on the secret store - PowerShell/SecretStore#28?
from secretmanagement.
Repro information
Server 2016 OS Build Number
PS C:\Users\x> $PSVersionTable
Name Value
PSVersion 5.1.14393.4583
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.4583
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PS C:\Users\x> Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full'
CBS : 1
Install : 1
InstallPath : C:\Windows\Microsoft.NET\Framework64\v4.0.30319
Release : 394802
Servicing : 0
TargetVersion : 4.0.0
Version : 4.6.01586
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework
Setup\NDP\v4\Full
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4
PSChildName : Full
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
from secretmanagement.
I am still running into an error when attempting to register a secret vault. I am using the current releases provided by @PaulHigin listed above, including verifying I'm on .NetFramework greater than 4.7
PS C:\> Get-Date
Thursday, February 10, 2022 10:00:57 AM
PS C:\> $PSVersionTable
Name Value
---- -----
PSVersion 7.2.1
PSEdition Core
GitCommitId 7.2.1
OS Microsoft Windows 10.0.22000
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
PS C:\> (Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse | Where-Object -FilterScript { $_.name -match 'Full' } | Get-ItemProperty | Where-Object {$_.PSChildName -eq 'Full'}).Version
4.8.04161
PS C:\>
PS C:\>
PS C:\> Get-Module | Format-Table -AutoSize
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Manifest 7.0.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-Item, Clear-ItemProperty…}
Binary 1.1.2 Microsoft.PowerShell.SecretManagement {Get-Secret, Get-SecretInfo, Get-SecretVault, Register-SecretVault…}
Binary 1.0.6 Microsoft.PowerShell.SecretStore {Get-SecretStoreConfiguration, Reset-SecretStore, Set-SecretStoreConfiguration, Set-SecretStorePassword…}
Manifest 7.0.0.0 Microsoft.PowerShell.Security {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSignature…}
Manifest 7.0.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object…}
Manifest 7.0.0.0 Microsoft.WSMan.Management {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, Enable-WSManCredSSP…}
Script 2.1.0 PSReadLine {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSReadLineKeyHandler, Set-PSReadLineKeyHandler…}
PS C:\> Register-SecretVault -Name SecretStore -ModuleName Microsoft.PowerShell.SecretStore -DefaultVault
Register-SecretVault: Could not load and retrieve module information for module: Microsoft.PowerShell.SecretStore with error : The specified module 'Microsoft.PowerShell.SecretStore' was not loaded because no valid module file was found in any module directory..
PS C:\>
PS C:\>
from secretmanagement.
I was able to circumvent the issue above by installing the module with the "-AllowPrerelease" parameter.
Is there another release and/or method I can install the prerelease version in an offline environment that cannot reach out to the PSGallery?
from secretmanagement.
You should not need the -AllowPrerelease
parameter as all latest versions of SecretManagement and SecretStore are full releases.
I am wondering if you have older versions of the module still on your machine. Try running Get-Module *secret* -list
and ensure that any older versions are removed and that you are only using the latest versions.
from secretmanagement.
Found the culprit! When I downloaded the .nupkg file so that I can use this module in an offline environment, I renamed the file extension to ".zip" and unpacked the contents. At that point, the folder name was "microsoft.powershell.secretmanagement.1.1.2" and all of the contents were inside of that folder. The proper folder structure when installing it via command line configures it as microsoft.powershell.secretmanagement\1.1.2\ContentsHere. Comparison listed below:
Incorrect folder structure:
C:\Users\username\Documents\PowerShell\Modules\Microsoft.PowerShell.SecretManagement.1.1.2\Microsoft.PowerShell.SecretManagement.psd1
Correct folder structure:
C:\Users\username\Documents\PowerShell\Modules\Microsoft.PowerShell.SecretManagement\1.1.2\Microsoft.PowerShell.SecretManagement.psd1
from secretmanagement.
Related Issues (20)
- Test-SecretVault cmdlet failing with "Assembly with same name is already loaded" HOT 2
- Documentation is just the stock help template. HOT 1
- Verbose output for Get-Secret is incorrect
- Get-Secret is Overzealous in SecureString Generation When Returning Hashtables. HOT 8
- CredManStore does not appear to work in a PowerShell remote session
- Provide Password/Passphrase Generator
- Inconsistent behaviour of -Verbose when encountering Throw HOT 1
- While developing an extension: Prevent session restart for reloading the module HOT 2
- AdditionalParameters is providing a CaseSensitive HashTable HOT 1
- Random unexpected secrets appear in vault HOT 1
- Get-SecretInfo : Exception calling "GetInstance" with "0" argument(s): "Padding is invalid and cannot be removed."
- Publish the library as netstandard20
- Secret object type for deeper integration HOT 2
- Binary extension module not returning objects?
- Add ArgumentCompleters
- Creating a Secret HOT 1
- Make secret vaults not require use of PowerShell HOT 1
- Get-SecretInfo: The specified module '...\Microsoft.PowerShell.SecretStore' was not loaded because no valid module file was found in any module directory. HOT 4
- Set/Add/New secret should be separate cmdlets HOT 1
- Set-Secret asks for password to unlock vault that has already been unlocked with Unlock-SecretStore
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from secretmanagement.