Surendra Sharma

Surendra Sharma

Search This Blog

Thursday, September 21, 2017

Fixing Sitecore PowerShell post installation issues

I was trying to install Sitecore PowerShell on my Sitecore 8.2 instance by downloading “Full 4.6 release for Sitecore 8”. After successful installation, when I started PowerShell console, I hit with error

"Could not load file or assembly 'System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified."

As my laptop running on Windows 7 (Yes, it’s still on WIN 7) on 64-bit processor, so I fixed this by downloading and installing "Windows Management Framework 4.0" having setup file name "Windows6.1-KB2819745-x64-MultiPkg.msu" from https://www.microsoft.com/en-us/download/details.aspx?id=40855

Note - You must need to restart your machine after this setup.

After restarting machine, login to Sitecore instance and open PowerShell Console. It was started but received pop up note that "Elevated session state is required to run the script." and Sitecore asking for current Sitecore logged-in user password. This pop up will raise when you open any PowerShell window with every Sitecore login time.

To fix this 

Open "include\Cognifide.PowerShell.config" file and make entry as "allow" in below keys

<token name="Default" expiration="00:00:00" elevationAction="Allow"/>
<token name="Console" expiration="00:05:00" elevationAction="Allow"/>
<token name="ISE" expiration="00:05:00" elevationAction="Allow"/>
<token name="ItemSave" expiration="00:05:00" elevationAction="Allow"/>    

Please note, this configuration changes are only for local development environment. Don’t make it on Production environment.

After this my PowerShell started working fine on my new Sitecore 8.2 instance.

Please leave your comments or share this trick if it’s useful for you.

References

Sunday, September 3, 2017

Another way to render WFFM Form



WFFM is a nice module to capture details from visitors. But when developers try to render WFFM forms in web page, then she has to face CSS and JS conflict with webpage. However this is good for testers and QA team as they will able to find lots of cosmetic issues ;)

Most of the time, WFFM’s CSS and JS stop or change the UI and functionality of the web page.
However there is an alternative way to render WFFM form – Iframe.

Follow below steps use it
* Create WFFM form
* Create item having separate page layout and MVC rendering for WFFM form only.
* Create one parameter rendering IFrame with three field - IFrame Url, Width and Height as shown below

WFFM form via IFRAME
WFFM form via IFRAME


Specify relative path of above item page rendering path in IFrame URL field

Specify below line in Iframe.cshtml as 

<iframe src="@Model.Url" width="@Model.Width" height="@Model.Height" scrolling="auto" frameborder="0" align="left" name=""></iframe>


When you render web page, your WFFM form will be rendered in IFRAME and all WFFM form CSS and JS are also load into IFRAME. In this way we separated CSS and JS of web page with WFFM form CSS and JS. So they will never conflict.

However there are two issues that I encountered with this approach

* If your website is running on HTTPS and you have entered the WFFM item path as HTTP then you will face issue. To fix it, instead of using full URL, you must use relative path.

* How to handle multi lingual WFFM forms? Let’s suppose your page is in French and now if you try to render your WFFM form with relative path then it try to render by default in English language. To fix it specify your relative path with language query string as "/wffm-forms/contact-form?sc_lang=fr-fr"

That’s it. 

I hope you will try this alternative approach. Stay tuned for more Sitecore related articles.

Till that happy Sitecoring :)

Please leave your comments or share this trick if it’s useful for you.

Tuesday, August 22, 2017

How to deal with large Sitecore databases: Part II




In first part, I had covered how to shrink the log file of database. This article focus on how to take backup of large database in multiple files at different locations and how to restore them.

Split database into multiple files
Split database into multiple files

If you asked to any developer about how to take database backup, they will generally reply - its very easy. Just use SQL server backup window or use the ready-made script.

But if you asked them take the backup of 20 GB database and upload on some different machine?
If you are making a single heavy backup file with 20GB and try to upload on FTP server then it might take hours. By any chance, this upload operation truncate in between then again you have to waste your time by uploading the same file on FTP server as well as you have monitor them now.

Is there any better way?

Yes. SQL server provide a way where you can split single database into multiple smaller file. Let suppose you have 20 GB database and now you can take backup in 10 different files and each file having 2 GB in size.

Here are other advantages of splitting database into multiple files

  • Store each file in different drive or locations.
  • ZIP individual file 
  •  Upload individual file on FTP location


Here is a sample script for backup database in 3 different files at three different locations.

BACKUP DATABASE SitecoreLessonsSitecore_Master
TO DISK = 'D:\Backup\SitecoreLessonsSitecore_Master\1.bak',
   DISK = 'C:\Other_Drive_Backup\SitecoreLessonsSitecore_Master\2.bak',
   DISK = 'E:\Daily_Backup\SitecoreLessonsSitecore_Master\3.bak'
GO

Note:- Folder path must exist for successful backup operation.

Use below query to restore these files

RESTORE DATABASE [SitecoreLessonsSitecore_Master_Staging]
FROM DISK = N'D:\Backup\SitecoreLessonsSitecore_Master\1.bak',
     DISK = N'D:\Backup\SitecoreLessonsSitecore_Master\2.bak',
     DISK = N'D:\Backup\SitecoreLessonsSitecore_Master\3.bak'
GO

Note:- Restore work on server where this database is not exist.

You can backup and restore by using SQL server management studio also. Here is a reference link for it https://solutioncenter.apexsql.com/how-to-create-sql-server-database-split-backup-files/

I have used this backup script multiple times.

I hope you like this Sitecore database trick. Stay tuned for more Sitecore articles.

Till that happy Sitecoring :)

Please leave your comments or share this database trick if it’s useful for you.
 
To know more about Sitecore database, Download this eBook.