This project is read-only.

New-EnvironmentConfiguration fails without EncryptionKey.txt


It appears that unless <InstallationPath>\Private\EncryptionKey.txt is created (after expanding a recently downloaded GEM zip, and completing step 1 [Import-Module -Name <InstallationPath>\ConfigurationDatabase\libConfigurationDatabase.psm1]), the New-EnvironmentConfiguration throws numerous errors, such as the following example:
PS .\> New-EnvironmentConfiguration -shortName Dev -fullName Development
Get-Content : Cannot find path C:\Users\Tester\Documents\WindowsPowerShell\Modules\Private\EncryptionKey.txt'
because it does not exist.
At C:\Users\Tester\Documents\WindowsPowerShell\Modules\GEM\ConfigurationDatabase\libConfigurationDatabase.psm1:545
+     $password=Get-Content -Path ..\Private\EncryptionKey.txt
+               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\Tester...cryptionKey.txt:String) [Get-Content], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand

Exception calling "Open" with "0" argument(s): "A password must be specified when a database is created by using encryption."
At C:\Users\Tester\Documents\WindowsPowerShell\Modules\GEM\ConfigurationDatabase\libConfigurationDatabase.psm1:780
+     $connection.Open()
+     ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SqlCeException

Exception calling "ExecuteReader" with "0" argument(s): "ExecuteReader requires an open and available Connection. The connection's current state is Closed."
At C:\Users\Browser\Documents\WindowsPowerShell\Modules\GEM\ConfigurationDatabase\libConfigurationDatabase.psm1:781
+     $rdr = $cmd.ExecuteReader()
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : InvalidOperationException

Exception calling "Load" with "1" argument(s): "Value cannot be null.
Parameter name: dataReader"
At C:\Users\Tester\Documents\WindowsPowerShell\Modules\GEM\ConfigurationDatabase\libConfigurationDatabase.psm1:783
+     $dt.Load($rdr)
+     ~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentNullException

Inserted environment Dev - Development


misabel_gem wrote Aug 12, 2015 at 1:11 PM

Hi Bryan!

The first step to do after downloading the package would be to run New-ConfigurationDatabase. This creates the SQL Compact database and creates .\Private\EncryptionKey.txt .

We could look into making an assertion/test function to check that the database and key have been created. Once that's done, we could insert that function in all the functions that requires interaction with the database. . If it's not the case, we call New-ConfigurationDatabase. We will need to add a user prompt for the encryption key for the case where the function is called without the password parameter supplied. Do you think that would work?


misabel wrote Aug 13, 2015 at 3:01 AM