Last active
August 14, 2020 20:57
-
-
Save michaellwest/731e750d5dc6b12436a7dca2fa2d548c to your computer and use it in GitHub Desktop.
Demonstrates adding environment variables for Sitecore.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Michael West | |
# Example adding environment variables for use with Sitecore XP 9.3+ and the Publishing Service. | |
# Be sure to restart IIS every time you make changes. | |
$appsettingsPrefix = "SITECORE_APPSETTINGS_" | |
$connectionPrefix = "SITECORE_CONNECTIONSTRINGS_" | |
$publishingConnectionPrefix = "SITECORE_SITECORE__PUBLISHING__CONNECTIONSTRINGS__" | |
$databaseServerName = "{REPLACE_WITH_DATABASE_SERVER_NAME}" | |
$searchServerName = "{REPLACE_WITH_SEARCH_SERVER_NAME}" | |
$connectionStringFormat = "Data Source={0};Initial Catalog=Sitecore.{1};Integrated Security=SSPI;MultipleActiveResultSets=True;" | |
$connectionStrings = @{ | |
"core" = [string]::Format($connectionStringFormat, $databaseServerName, "core") | |
"security" = [string]::Format($connectionStringFormat, $databaseServerName, "core") | |
"experienceforms" = [string]::Format($connectionStringFormat, $databaseServerName, "experienceforms") | |
"master" = [string]::Format($connectionStringFormat, $databaseServerName, "master") | |
"web" = [string]::Format($connectionStringFormat, $databaseServerName, "web") | |
"solr.search" = "http://$($searchServerName)/solr" | |
} | |
foreach($key in $connectionStrings.Keys) { | |
$name = "$($connectionPrefix)$($key.ToUpper())" | |
$value = $connectionStrings[$key] | |
[Environment]::SetEnvironmentVariable($name, $value, "Machine") | |
} | |
$settings = @{ | |
"role:define" = "Standalone" | |
"sxaxm:define" = "sxaxmonly" | |
"exmEnabled:define" = "no" | |
} | |
foreach($key in $settings.Keys) { | |
$name = "$($appsettingsPrefix)$($key.ToUpper())" | |
$value = $settings[$key] | |
[Environment]::SetEnvironmentVariable($name, $value, "Machine") | |
} | |
$publishingConnectionStrings = @{ | |
"core" = [string]::Format($connectionStringFormat, $databaseServerName, "core") | |
"master" = [string]::Format($connectionStringFormat, $databaseServerName, "master") | |
"web" = [string]::Format($connectionStringFormat, $databaseServerName, "web") | |
} | |
foreach($key in $publishingConnectionStrings.Keys) { | |
$name = "$($publishingConnectionPrefix)$($key.ToUpper())" | |
$value = $publishingConnectionStrings[$key] | |
[Environment]::SetEnvironmentVariable($name, $value, "Machine") | |
} | |
iisreset |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment