Converting database to UTC not working with powershell

Vote:
 

When upgrading to EPi 10 I try to convert the database with powershell for the staging environment. I run the following:

(...)\packages\EPiServer.Framework.10.0.1\tools> powershell -ExecutionPolicy ByPass Import-Module .\ConvertDatabaseToUtc.psm1 -Verbose

which runs fine. But when I try to run ConvertEPiDatabaseToUtc, I get the message "...is not recognized as the name of a cmdlet, function, scriptfile...". Any idea what I am doing wrong?

#174934
Feb 08, 2017 11:02
Vote:
 

I think it's Convert-EPiDatabaseToUtc, note the hyphen.

#174937
Feb 08, 2017 11:17
Vote:
 

Ok. I think I understand the problem. You seems to be running in a command line context. You should run it in the context of powershell, such as PS ISE. Otherwise the modules imported will not be available on your next command.

#174942
Feb 08, 2017 11:47
Vote:
 

Thanks. I run it with Windows Powershell ISE as Administrator. Isn't that enough?

#174943
Feb 08, 2017 11:56
Vote:
 

It should be enought to be admin.
When your run the import with the verbose flag on, does it say anything that can hint on what is happening?

#174947
Feb 08, 2017 13:22
Vote:
 

This is the entire response when I run the command: 

"powershell -ExecutionPolicy ByPass Import-Module .\ConvertDatabaseToUtc.psm1 -Verbose"

VERBOSE: Loading module from path
'C:\Prosjekter\[project]\packages\EPiServer.Framework.10.0.1\tools\ConvertDatabaseToUtc.psm1'.
VERBOSE: Exporting function 'Get-WebConfig'.
VERBOSE: Exporting function 'New-DateTimeConversionOffset'.
VERBOSE: Exporting function 'GenerateOffsets'.
VERBOSE: Exporting function 'CreateOffsetRows'.
VERBOSE: Exporting function 'CreateOffsetInDB'.
VERBOSE: Exporting function 'InitFieldNames'.
VERBOSE: Exporting function 'InitBlocks'.
VERBOSE: Exporting function 'RunBlocks'.
VERBOSE: Exporting function 'SwitchToUtc'.
VERBOSE: Exporting function 'ExecuteSP'.
VERBOSE: Exporting function 'ConvertEPiDatabaseToUtc'.
VERBOSE: Exporting function 'GetConnectionString'.
VERBOSE: Exporting function 'Convert-EPiDatabaseToUtc'.
VERBOSE: Importing function 'Convert-EPiDatabaseToUtc'.
VERBOSE: Importing function 'ConvertEPiDatabaseToUtc'.
VERBOSE: Importing function 'CreateOffsetInDB'.
VERBOSE: Importing function 'CreateOffsetRows'.
VERBOSE: Importing function 'ExecuteSP'.
VERBOSE: Importing function 'GenerateOffsets'.
VERBOSE: Importing function 'Get-WebConfig'.
VERBOSE: Importing function 'GetConnectionString'.
VERBOSE: Importing function 'InitBlocks'.
VERBOSE: Importing function 'InitFieldNames'.
VERBOSE: Importing function 'New-DateTimeConversionOffset'.
VERBOSE: Importing function 'RunBlocks'.
VERBOSE: Importing function 'SwitchToUtc'.

#174956
Feb 08, 2017 14:39
Vote:
 

Looks good, and after that running the command in the same folder gives you the error?

#174957
Feb 08, 2017 14:49
Vote:
 

I had the same problem when running the script in pre-prod. The staging environment worked fine, even though their setup should be identical. I haven't found the reason yet.

The error was "Get-Project is not recognised...". I simply commented out the line "$connectionString = GetConnectionString $connectionString" and everything worked. 

GetConnectionString tries to analyze your project and figure out your connectionstring. Since this is passed as an argument, I figured this line was not needed.

#174963
Feb 08, 2017 15:57
Vote:
 

@Espen The cmdlet Convert-EPiDatabaseToUtc (with a hyphen) is designed for Visual Studio so it requires cmdlets like Get-Project. When you run standalone just call the function ConvertEPiDatabaseToUtc to bypass this.

@Torunn Remove "powershell -ExecutionPolicy ByPass" if you run inside ISE, otherwise you start another powershell session rather than importing the module in your session.

#174965
Feb 08, 2017 17:01
Vote:
 

Thanks everyone! The reason I added "powershell -ExecutionPolicy ByPass" was that I got the error "the running scripts  are disabled on this system". What I did, was to change this policy by running "Set-ExecutionPolicy RemoteSigned".

Then I was able to run the Import-Module without the bypass, and finally run ConvertEPiDatabaseToUtc.

#174987
Edited, Feb 09, 2017 7:33
Vote:
 

@Per

 Does cmdlet Convert-EPiDatabaseToUtc work with connectionstring in a separate file with configSource option? I couldn't make it working without specify the full connectionstring in the parameter when using the configSource. 

p.s. I see the Get-WebConfig function handles the configSource, but not sure how to debug this. Would you be able to give some details how Epi team debug these PS scripts? 

#178823
May 23, 2017 14:45
This thread is locked and should be used for reference only.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.