Posts

Powershell script for VS build and deploy

$solutionName = "$PSScriptRoot/SWSC.sln" dotnet restore $solutionName function Get-MsBuildPath() { $vsWherePath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" if ((Test-Path $vsWherePath) -eq $false) { throw "It seems you have no Visual Studio installed. You won't be able to build the solution without it." } $path = &"$vsWherePath" -latest -prerelease -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe if ($path.Length -eq 0) { throw "No MSBuild can be found. Make sure you have Visual Studio installed." } return $path } $msBuildPath = Get-MsBuildPath $buildToPaths = @("$PSScriptRoot/docker/deploy/cm") $buildToPaths | ForEach-Object { Write-Host "[$((Get-Date).ToString("hh:mm:ss"))] Building the backend code to $_..." -ForegroundColor Yellow &$msBuildPath $solutionName "...

Read and export Sitecore item fields using powershell.

 $database = "master" $root = Get-Item -Path (@{$true="$($database):\content\ExactSciences\Websites\Cologuard\Cologuard\Settings\Redirects"; false="$($database):\content\ExactSciences\Websites\Cologuard\Cologuard\Settings\Redirects"}[(Test-Path -Path "$($database):\content\ExactSciences\Websites\Cologuard\Cologuard\Settings\Redirects")]) $props = @{     Parameters = @(         @{Name="root"; Title="Choose the report root"; Tooltip="Only items from this root will be returned."; })     Title = "Export Lists all content items and media items"     Description = "Choose the criteria for the report."     Width = 550     Height = 300     ShowHints = $true } $result = Read-Variable @props if($result -eq "cancel") {     exit } $templateId="{F4FB6125-F113-4373-8AA2-4648C2C1960E}" $items = Get-ChildItem -Path $root.ProviderPath -Recurse | Where-Object { $_.TemplateId -eq $templateId } if(...

Target Machine Actively refused at - Invoke-RestMethod "http://localhost:xxx/api/http/routers

When I am running up.ps1 script while setting up my local to run XM Cloud, I'm getting the below error. Background: my system got restarted and after that am facing this issue, docker containers are in the exited state, and not able to restart. Tried fix: I completely deleted all my docker containers and ran up.ps1 script to install containers again and then the script was running fine. Docker installed: docker for windows and running in windows containers Error: strconv.Atoi: parsing "": invalid syntax Waiting for CM to become available... Invoke-RestMethod: C:\pathtoxmcloudproject\up.ps1:59:19 Line | 59 | … $status = Invoke-RestMethod "http://localhost:xxxx/api/http/routers … | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | No connection could be made because the target machine actively refused it. I tried deleting all containers and re-running the up.ps1 script. ==================================================== ...

Render HTML in Single line text field in Sitecore Scriban or Encode HTML in Single line text field in Sitecore Scriban

 If you use field type is Single line text and if you read the field in Sitecore scriban like i_item.Title it will not encode html string. if you want to encode html string for single line text use .raw property like below. i_item.Title.raw So single line text will also encode and render the html in scriban.

Sitecore user full references for developers.

  I found some useful Sitecore blogs at below site, Thanks Pranay for your efforts.  https://www.logicalfeed.com/posts/1222/powershell-script-to-search-a-keyword-in-all-items-in-sitecore https://www.logicalfeed.com/

Unlock all the items in Sitecore locked by specific user

We can use any of the below PowerShell scripts to unlock the all items. Get-ChildItem master:\content -rec -Language * | Where-Object { $_ .Locking.GetOwner() -eq "sitecore\USERNAME" } | % { $_ .Locking.Unlock() } or $script :counter = 0 $script :unlockedCounter = 0 $owner = $user .Replace( "\"," \\") function Unlock-Item-And-Descendants { param( [Parameter(Mandatory= $true ,ValueFromPipeline= $true )] [Sitecore.Data.Items.Item] $item ) if ( $item [ "__Lock" ] -match $owner ) { Write-Host "Unlocking" $item .Paths.ContentPath ":" $item .ID Unlock-Item $item #| Out-Null $script :unlockedCounter++ if ( $script :unlockedCounter % 500 -eq 0) { Write-Host " $script :unlockedCounter items unlocked" } } $script :counter++ if ( $script :counter % 500 -eq 0) { Write-Host " $script :counter items revie...

Workaround for - SSL certificate problem: Unable to get local issuer certificate

Image
  Problem The following is seen on the command line when pushing or pulling: SSL Certificate problem: unable to get local issuer Cause This error occurs when a self-signed certificate cannot be verified.  Workaround Tell git to not perform the validation of the certificate using the global option: git config --global http.sslVerify false   Please be advised disabling SSL verification globally  might be considered a security risk  and should be implemented only temporarily