Skip to content

Instantly share code, notes, and snippets.

View SoulOfUniverse's full-sized avatar
🤖

Sergejs Kravcenko SoulOfUniverse

🤖
View GitHub Profile
@SoulOfUniverse
SoulOfUniverse / anexample.ps1
Created January 11, 2018 12:56 — forked from kamsar/anexample.ps1
Generate trusted local SSL cert for Solr
# Usage:
# This script is designed to be run after you have Solr running locally without SSL
# It will generate a trusted, self-signed certificate for LOCAL DEV (this must be modified for production)
# Notes: The keystore must be under server/etc on Solr root, and MUST be named solr-ssl.keystore.jks
# The cert will be added to locally trusted certs, so no security warnings in browsers
# You must still reconfigure Solr to use the keystore and restart it after running this script
#
# THIS SCRIPT REQUIRES WINDOWS 10 (for the SSL trust); without 10 remove the lines around trusting the cert.
@SoulOfUniverse
SoulOfUniverse / SitecoreMigrateRenderings8to10.ps1
Created July 13, 2021 18:57
Convert renderings from Sitecore 8 to 9+ version
# specify your path here. It is most likely be page templates and page content
$startPath = "/sitecore/content"
Get-ChildItem -Path $startPath -Recurse | ForEach-Object {
$item = $_;
Get-Rendering -Item $_ -FinalLayout | ForEach-Object {
$rendering = $_;
$matches = [regex]::Matches($_.Placeholder,'(?<guid>_[\d\w]{8}\-(?:[\d\w]{4}\-){3}[\d\w]{12})(?<seed>_?\d?)')
if ($matches.Success) {
Write-Host "Match found in item - [$($item.Paths.FullPath)]"
Write-Host "Old Placeholder - [$($rendering.Placeholder)]"
@SoulOfUniverse
SoulOfUniverse / RunPseRemotely.ps1
Created July 13, 2021 19:00
Visual Studio Remote Sitecore Powershell Extension
<#
Set-ExecutionPolicy RemoteSigned
#>
Import-Module -Name SPE
$session = New-ScriptSession -Username remoteadmin -Password test -ConnectionUri https://sitecoreinstance.local
$jobId = Invoke-RemoteScript -ScriptBlock {
Write-Verbose ("Started at " + [System.DateTime]::Now)
$files = Get-ChildItem $SitecoreLogFolder
@SoulOfUniverse
SoulOfUniverse / PingingWebsite.ps1
Created July 13, 2021 19:01
Pinging any target url
# First we create the request.
$HTTP_Request = [System.Net.WebRequest]::Create('https://google.com')
$HTTP_Request.Timeout = 60000
# We then get a response from the site.
$HTTP_Response = $HTTP_Request.GetResponse()
# We then get the HTTP code as an integer.
$HTTP_Status = [int]$HTTP_Response.StatusCode
If ($HTTP_Status -eq 200) {
@SoulOfUniverse
SoulOfUniverse / ExtendSelfSignedCertificate.ps1
Created July 13, 2021 19:06
Sitecore Trusted Self Signed Certificated Extension
#Requires -RunAsAdministrator
#Author: Sergejs Kravcenko
#Date: 12/07/2018
#Description: RenewCertificate module, which allows to safely generate and issue new Sitecore Self-Signed certificates both Root and Personal in order to have Sitecore instance function correctly with its xConnect services
#Usage: Import-Module .\RenewCertificate.psm1
Write-Host "Importing RenewCertificateModule"
function New-RootCertificateFn{
param (
@SoulOfUniverse
SoulOfUniverse / SPE-GetItemUrlReferrer.ps1
Created July 13, 2021 19:08
Sitecore Powershell Get Item Url Referrer
$inputProps = @{
Prompt = "Enter the targeted item ID (Guid):"
Validation = [Sitecore.Configuration.Settings]::ItemNameValidation
ErrorMessage = "'`$Input' is not a valid item ID."
}
$itemId = Show-Input @inputProps
[Sitecore.Context]::SetActiveSite("website")
$urlop = [Sitecore.Links.LinkManager]::GetDefaultUrlOptions()
@SoulOfUniverse
SoulOfUniverse / AddUserToCertificate.ps1
Created July 13, 2021 19:12
Sitecore Powershell Add User To A Certificate
param(
[string]$userName,
[string]$permission,
[string]$certStoreLocation,
[string]$certThumbprint
);
# check if certificate is already installed
$certificateInstalled = Get-ChildItem cert:$certStoreLocation | Where thumbprint -eq $certThumbprint
# download & install only if certificate is not already installed on machine
@SoulOfUniverse
SoulOfUniverse / CleaningDirectory.ps1
Created July 13, 2021 19:12
Powershell Cleaning Directory
param
(
[ValidateScript( {Test-Path $_})]
[string]$path,
[switch] $force = $false
)
if (Test-Path $path) {
if ($path -like "*C:*" -and -not $force) {
Write-Error "$path is system path cannot be used"
}
@SoulOfUniverse
SoulOfUniverse / StopIIS.ps1
Created July 13, 2021 19:15
Stop IIS Application Pool using WebAdministration
# Load IIS module:
Import-Module WebAdministration
# Get AppPool Name
$appPoolName = $OctopusParameters['appPoolName']
# Get the number of retries
$retries = $OctopusParameters['appPoolCheckRetries']
# Get the number of attempts
$delay = $OctopusParameters['appPoolCheckDelay']
@SoulOfUniverse
SoulOfUniverse / StartIIS.ps1
Created July 13, 2021 19:15
Start IIS Application Pool using WebAdministration
# Load IIS module:
Import-Module WebAdministration
# Get AppPool Name
$appPoolName = $OctopusParameters['appPoolName']
Write-Output "Starting IIS app pool $appPoolName"
Start-WebAppPool $appPoolName