Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jhorsman
jhorsman / item-sync-publications.ps1
Last active January 6, 2022 22:44
Synchronize SDL Web components (by publication) with schemas using PowerShell
#WARNING this script is set to run component-sync with the -Update flag, meaning it will commit and save the changed components
#Usage examples
# .\item-sync-publications.ps1
# .\item-sync-publications.ps1 | Tee-Object sync.log
# Prerequisite: Install the tridion-powershell-modules https://github.com/pkjaer/tridion-powershell-modules
Import-Module Tridion-CoreService -Verbose:$false
Set-TridionCoreServiceSettings -Version "2013-SP1"
@jhorsman
jhorsman / create-admin-user.ps1
Last active January 6, 2022 22:43
Make an administrator user in SDL Web with PowerShell. Using the Tridion CoreService module (https://github.com/pkjaer/tridion-powershell-modules).
Import-Module Tridion-CoreService
Set-TridionCoreServiceSettings -HostName "my-cm-server" -Version Web-8.5 -ConnectionType Basic-SSL -Persist
New-TridionUser -UserName "domain\username" -Description "Person Name" -MakeAdministrator
# For Web 8.5 the -MakeAdministrator option does not work, you have to add the user to the System Administrator group instead
# New-TridionUser -UserName "domain\username" -Description "Person Name" -MemberOf "System Administrator"
@jhorsman
jhorsman / add-user-to-group.ps1
Last active January 6, 2022 22:43
Add a user to a local Windows user group with PowerShell. Inspired by https://mcpmag.com/articles/2015/05/28/managing-local-groups-in-powershell.aspx
$Computer = $env:COMPUTERNAME
$GroupName = 'Topology Manager Administrators'
$ADSI = [ADSI]("WinNT://$Computer")
$Group = $ADSI.Children.Find($GroupName, 'group')
Write-Host ("Found group '{0}'" -f $Group.Name.Value)
#$User = $env:USERNAME
#$Group.Add(("WinNT://$Computer/$User"))
$User = "domain\username"
@jhorsman
jhorsman / test-cd-microservices.ps1
Last active January 6, 2022 22:42
Test SDL Web 8.5 micro services with PowerShell
<#
https://gist.github.com/jhorsman/6f253941cdd0caec6bbba26a2cb26345
.SYNOPSIS
Verifies the SDL Web Content Delivery micro services which are listed in the discovery service
.PARAMETER DiscoveryEndpointUrl
Endpoint to the discovery service. By default it is on port 8082 and it always ends with /discovery.svc
.PARAMETER Local
@jhorsman
jhorsman / installService.ps1
Created March 1, 2018 14:13
Install SDL Web Content Delivery mico service with Windows service dependency
....
# $dependsOn should not just contain the name of the service, but the full command line parameter like so:
$dependsOn='--DependsOn="SDLWebDiscoveryService"'
...
@jhorsman
jhorsman / start-CD-microservices.ps1
Last active January 6, 2022 22:41
Scripted start SDL Web 8.5 microservices
# This script can be used to manually start Tridion Sites micro-services
#
# On some all-in-one Tridion machines I use this script as a scheduled task to have a
# delayed start of the CD micro-services. The transcript creates a log file.
Start-Transcript -Path (Join-Path $PSScriptRoot "start-CD-services.log") -Append
Start-Service SDLWeb*DiscoveryService -Verbose
Start-Service SDLWeb*DeployerService -Verbose
Start-Service SDLWeb*ContentService -Verbose
@jhorsman
jhorsman / TcmUri.cs
Last active January 6, 2022 22:40
TcmUri object for .NET
using System;
using System.Text.RegularExpressions;
using Tridion.ContentManager.CoreService.Client;
namespace TridionUtils
{
/// <summary>
/// Creates TcmUri class from a string. Makes it easy to retrieve TcmUri properties like PublicationId, ItemId, ItemTypeId and Version.
/// Usage: var PubliationId = new TcmUri("tcm:45-3456-64").PublicationId;
/// </summary>
@jhorsman
jhorsman / purge-publishing-queue
Created January 4, 2019 14:05
Purge old Tridion Sites publishing transactions
# https://docs.sdl.com/LiveContent/content/en-US/SDL%20Web-v5/GUID-7BE8773F-B1AE-46D0-946E-CDD6F7C01DC7
Remove-TcmPublishTransactions -Succesful -Before (Get-Date).AddDays(-14)
@jhorsman
jhorsman / Web.xml
Last active December 30, 2020 12:16
Proxy configuration in .NET Web.config. See https://gist.github.com/jhorsman/bb2863ae2779c46982b79dc016d7ff49 for .NET Core
<system.net>
<defaultProxy>
<proxy
usesystemdefault="true"
proxyaddress="http://localhost:8500"
bypassonlocal="False"
/>
</defaultProxy>
</system.net>
@jhorsman
jhorsman / install-update-nuget.ps1
Created March 8, 2017 10:29
Install and update NuGet with PowerShell
IF (-NOT (Test-Path ".nuget\nuget.exe"))
{
Write-Verbose "Install NuGet"
New-Item -ItemType Directory ".nuget" | Out-Null
Invoke-WebRequest "https://www.nuget.org/nuget.exe" -OutFile ".nuget\nuget.exe" -UseBasicParsing
}
Write-Verbose "Update NuGet"
& ".\.nuget\nuget.exe" update -self