Skip to content

Instantly share code, notes, and snippets.

public static string NormalizePostcode(string postcode)
{
//removes end and start spaces
postcode = postcode.Trim();
//removes in middle spaces
postcode = postcode.Replace(" ", "");
switch (postcode.Length) {
//add space after 2 characters if length is 5
case 5: temp_postcode = temp_postcode.Insert(2, " "); break;
private static int CalculateAge(DateTime dateOfBirth)
{
int age = 0;
age = DateTime.Now.Year - dateOfBirth.Year;
if (DateTime.Now.DayOfYear < dateOfBirth.DayOfYear)
age = age - 1;
return age;
}
@naveed-ahmad-biz
naveed-ahmad-biz / Sitecore.Ship.Update.UpdatePackageRunner.cs
Created November 19, 2017 05:18
Sitecore Ship failing silently fix
using (new SecurityDisabler())
{
bool flag;
DiffInstaller installer = new DiffInstaller(installationInfo.Action);
entries = installer.InstallPackage(installationInfo.Path, installationInfo.Mode, logger, new List<ContingencyEntry>(), "rollbackPackage.rlb", out flag, ref historyPath);
}
@naveed-ahmad-biz
naveed-ahmad-biz / sitecore-9-error.ps1
Created November 15, 2017 03:27
ERROR_SCRIPTDOM_NEEDED_FOR_SQL_PROVIDER
[WebDeploy]:[Path] C:\Program Files\iis\Microsoft Web Deploy V3\msdeploy.exe
Error Code: ERROR_SCRIPTDOM_NEEDED_FOR_SQL_PROVIDER
More Information: The SQL provider cannot run because of a missing dependency. Please make sure that Microsoft SQL Server Transact-SQL ScriptDom is installed. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_SCRIPTDOM_NEEDED_FOR_SQL_PROVIDER.
**********************
Command start time: 20171023170201
**********************
PS>TerminatingError(Invoke-CommandTask): "The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Command C:\Program Files\iis\Microsoft Web Deploy V3\msdeploy.exe returned a non-zero exit code - (-1)"
>> TerminatingError(Invoke-CommandTask): "The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Command C:\Program Files\iis\Microsoft Web Deploy V3\msdeploy.exe returned a non-zero exit code - (-1)"
>> TerminatingError(I
@naveed-ahmad-biz
naveed-ahmad-biz / install.ps1
Created November 15, 2017 03:19
Sitecore 9 Install File
#define parameters
$prefix = "xp0"
$PSScriptRoot = "C:\Resources"
$XConnectCollectionService = "$prefix.xconnect"
$sitecoreSiteName = "$prefix.sc"
$SolrUrl = "https://localhost:8989/solr"
$SolrRoot = "C:\data\Solr-6.6.1"
$SolrService = "Solr-6.6.1"
$SqlServer = "MYCOMPUTERNAME\SQLEXPRESS2016"
$SqlAdminUser = "sitecoreUser"
#generate certificate
$thumbprint = (New-SelfSignedCertificate `
-Subject "CN=$env:COMPUTERNAME @ Sitecore, Inc." `
-Type SSLServerAuthentication `
-FriendlyName "$env:USERNAME Certificate").Thumbprint
#export certificate with password
$certificateFilePath = "C:\Temp\$thumbprint.pfx"
Export-PfxCertificate `
-cert cert:\LocalMachine\MY\$thumbprint `
-FilePath "$certificateFilePath" `
New-AzureRmResourceGroupDeployment : 2:34:31 PM - Error: Code=InvalidTemplate; Message=Deployment template validation failed: 'The template resource 'templateLinkBase' at line '28' and column '30' is not valid: The language expression property 'templateLink' doesn't
exist, available properties are 'template, parameters, mode, provisioningState'.. Please see https://aka.ms/arm-template-expressions for usage details.'.
At C:\azure\sitecore-azure-2.0\tools\Sitecore.Cloud.Cmdlets.psm1:112 char:35
+ ... eployment = New-AzureRmResourceGroupDeployment -Name $Name -ResourceG ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet
New-AzureRmResourceGroupDeployment : The deployment validation failed
At C:\azure\sitecore-azure-2.0\tools\Sitecore.Cloud.Cmdlets.psm1:112 ch
New-AzureRmResourceGroupDeployment : 6:18:47 PM - Resource Microsoft.Web/certificates 'sitecore-9cloud-auth' failed
with message '{
"Code": "NotFound",
"Message": "Cannot find Certificate with name sitecore-9cloud-auth.",
"Target": null,
"Details": [
{
"Message": "Cannot find Certificate with name sitecore-9cloud-auth."
},
{
$licenseFile = "C:\azure\sitecore-azure-2.0\license.xml"
$ArmTemplateUrl = "https://raw.githubusercontent.com/Sitecore/Sitecore-Azure-Quickstart-Templates/master/Sitecore 9.0.0/XP/azuredeploy.json";
$ArmParametersPath = "C:\azure\sitecore-azure-2.0\xp\azuredeploy.parameters.json";
$RGName = "SitecoreXP1";
$DeploymentID = "SitecoreXP1"
$location = "East US";
Start-SitecoreAzureDeployment -location $location -Name $RGName -ArmTemplateUrl $ArmTemplateUrl -ArmParametersPath $ArmParametersPath -LicenseXmlPath $licenseFile
$fileContentBytes = get-content 'C:\path\to\cert.pfx' -Encoding Byte
[System.Convert]::ToBase64String($fileContentBytes) | Out-File 'pfx-bytes.txt'