Skip to content

Instantly share code, notes, and snippets.

@derekcorreia
Last active January 23, 2020 15:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derekcorreia/ea16c1090072ff387678553646e32574 to your computer and use it in GitHub Desktop.
Save derekcorreia/ea16c1090072ff387678553646e32574 to your computer and use it in GitHub Desktop.
Fixes Sitecore Support Package generator config sets when generated with multiple servers. Replace $source with a "Configs" directory containing ".link" files after un-archiving the SSP. Run from Powershell console.
# Change source to match path of folder from support package with .link files that won't build in config builder
# Source folder should have a web.config or web.config.link, and the app_config folder below it.
$source = "C:\SupportPackage\INSTANCE-Sitecore-prd-cd\Configs"
Write-Host "Fix Sitecore Support Package Links"
Write-Host "Source Directory defined in .ps1: " -NoNewline
Write-Host $source -ForegroundColor Yellow
Write-Host "Confirm path and press any key to begin. Press Ctrl-C to exit"
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
$replaced = 0
if (Test-Path $source){
Get-ChildItem -Path $source -Recurse -Filter *.link |
ForEach-Object {
$sourceFilePath = Get-Content -Path $_.FullName
if (!$sourceFilePath.StartsWith("[link]")){
Write-Host ("File does not appear to be a valid link: {0}" -f $_.FullName)
break
}
$sourceFilePath = $sourceFilePath.Substring(7, $sourceFilePath.Length - 7 )
#switch url encoded strings
$sourceFilePath = $sourceFilePath.Replace("/", "\")
$sourceFilePath = $sourceFilePath.Replace("%20", " ")
Copy-Item ("{0}\{1}" -f $_.Directory.FullName,$sourceFilePath) -Destination $_.Directory.FullName
Remove-Item $_.FullName
$replaced++
}
Write-Host ("Replaced {0} link files with configs" -f $replaced) -ForegroundColor Green
} else {
Write-Host ("Path not found: {0}" -f $source) -ForegroundColor Red
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment