Skip to content

Instantly share code, notes, and snippets.

@peplau
Last active September 23, 2016 21:57
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 peplau/6d1588821675c2dda15c18fabbd94eb8 to your computer and use it in GitHub Desktop.
Save peplau/6d1588821675c2dda15c18fabbd94eb8 to your computer and use it in GitHub Desktop.
Powershell: SitecoreRoleConfigurator - Diffs.ps1
<#
.SYNOPSIS
The following script prompts the user for a Sitecore server role, then shows the files that are not matching the spreadsheet.
Based on Michael West's "SitecoreRoleConfigurator.ps1" - https://gist.github.com/michaellwest/d1124a459cb1fb47486f87d488ecfab8
Important: you will need the CSV file provided by Michael at https://gist.github.com/michaellwest/d1124a459cb1fb47486f87d488ecfab8#file-config_enable-disable_sitecore_8-1_upd3-csv
Now it supports multiple Env Roles separated by comma thanks to @mhwelander feedback
.NOTES
Rodrigo Peplau
2016-09-23
#>
$VerbosePreference = "Silentlycontinue"
$configOptions = Import-Csv -Path C:\temp\Config_Enable-Disable_Sitecore_8.1_upd3.csv
$role = Read-Host -Prompt "Which server role would you like to use? (i.e. CD, CM, CMP, PRC, RPT) - Multiple roles can be added comma seperated"
$role = $role -replace ", ",","
$arrRoles = $role.Split(",")
$apppath = "C:\temp"
foreach($option in $configOptions) {
$configPath = Join-Path -Path $apppath -ChildPath $option.Filepath
$configFile = Join-Path -Path $configPath -ChildPath ($option.Filename)
$configFile = $configFile -replace ".disabled",""
$mustEnable = $FALSE
$mustDisable = $FALSE
foreach($role in $arrRoles) {
switch($option.$role) {
"Enable" {
$mustEnable = (-not (Test-Path -Path $configFile))
}
"Disable" {
if ((Test-Path -Path $configFile)){
$mustDisable = $TRUE
}
}
default {
continue
}
}
# According to Martina (@mhwelander) in multiple-roles installation rule of the thumb is:
# If something must be enabled somewhere, it should be enabled!
if ($mustEnable){
break
}
}
if ($mustEnable){
Write-Host "Must be ENABLED - $($configFile)"
} elseif ($mustDisable){
Write-Host "Must be DISABLED - $($configFile)"
}
}
@michaellwest
Copy link

Like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment