There was this .ps1 file that I needed to run from the Power Shell console. See script below.
1. When I attempted to do that by navigating to the location of the script file in the PS console and typing in the name of the file I got an error message that running a PS script is disabled on my environment.
In PS window type in "Get-ExecutionPolicy" and hit enter. You might see 'restricted'.
set-executionpolicy unrestricted
2. After then I typed in the name of the script file agan and got a different error "not recognized comman". I was prompted to type it differently: ".\Setup.ps1"
3.
$ErrorActionPreference = "Stop"
. "$PSScriptRoot\Common.ps1"
$simUrl = "http://dl.sitecore.net/updater/sim/"
$simUrlDownload = "http://dl.sitecore.net/updater/sim/SIM.Tool.application"
$sitecoreVersion = "8.1"
$sitecoreRevision = "151207"
$sitecoreFullVersion = "Sitecore CMS $sitecoreVersion rev.$sitecoreRevision"
$localUrl = "sitecore.loc.geisinger.edu"
$frameorkVersion = "4.0"
$deploySubDirectory = "\Deploy"
$mongoUrl = "https://www.mongodb.com/download-center?jmp=homepage#community"
$mongoUrlDownload = "https://www.mongodb.com/dr/fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-3.2.8-signed.msi/download"
$solrUrl = "http://archive.apache.org/dist/lucene/solr/"
$solrUrlDownload = "http://archive.apache.org/dist/lucene/solr/4.10.3/solr-4.10.3.zip"
$solrVersion = "4.10.3"
$javaUrl = "http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html"
$javaVersion = "8u101"
$defaultMongoPath = "C:\Program Files\MongoDB\Server\3.2\bin"
$defaultMongoDataPath = "C:\data\db"
$defaultMongoLogPath = "C:\data\logs"
$mongoLogFile = "log.txt"
$mongodFile = "mongod.exe"
$mongoService = "Mongodb"
$javaVersion ="8u101"
$downloadsPath = "$($env:userprofile)\Downloads"
$defaultSolrDownloadPath = "$downloadsPath\solr-$solrVersion.zip"
$defaultSolrInstallPath = "C:\Apps\Solr\"
$solrtask = "Solr"
$repoRoot = (Get-Item (Get-Location)).parent
$gitRoot = $repoRoot.parent.FullName
$repoRoot = $repoRoot.FullName
Function Greet() {
Write-Host @"
This script will help Setup your local Dev environment for running Sitecore.
Please note that this should not be run in production under any circumstance.
All the configuration steps are required for a fresh environment so be sure to
answer Y to all questions if this is your first time.
"@ -foregroundcolor Blue
RequireAdmin
Write-Host @"
Note: Please remember that some of the configuration in this script is
generated on the fly to be environment specific. As such it is not transferable
to other environments without modification.
"@ -foregroundcolor Yellow
Pause
}
Function RequireAdmin() {
$principle = [Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()
If (!($principle.IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))) {
throw "This script must be run with Administrator permissions!"
}
}
Function CreateDirectory($path) {
if(!(Test-Path $path)) {
New-Item $path -type directory
}
}
Function CheckService($serviceName) {
return Get-WmiObject -Class Win32_Service -Filter "Name='$serviceName'"
}
Function DeleteService($name) {
Stop-Service $name
$command = @"
sc.exe delete "$name"
"@
iex $command
}
Function Unzip($source, $destination) {
$shell = new-object -com shell.application
$zip = $shell.NameSpace("$source")
foreach($item in $zip.items()) {
$shell.Namespace($destination).copyhere($item)
}
}
Function SetupSitecore() {
Write-Host @"
First you will want to download, install, and configure the newest version of
Sitecore Instance Manager (SIM) from $simUrl
"@ -foregroundcolor Blue
Ask "Would you like to download and install SIM? (Y/N)" $function:DownloadSIM
Write-Host @"
Now we can configure SIM.
It should have automatically opened after install. If not you should be able
to search your installed programs for SIM.
Once SIM is open, you should navigate to Home > Settings
and configure as follows:
Instance Root Folder: $gitRoot
SQL Server Connection String: Data Source=localhost;Initial Catalog=master;Integrated Security=True;Connect Timeout=1
Sitecore License File: $($env:AppData)\Sitecore\Sitecore Instance Manager\license.xml
Local Repository: $($env:AppData)\Sitecore\Sitecore Instance Manager\Repository
"@ -foregroundcolor Blue
Write-Host @"
Note: Feel free to change these as needed as these are just recommendations.
Also if you haven't already acquired a Sitecore license file, please contact
your lead for more information.
"@ -foreground Yellow
Pause
Write-Host @"
Now we can download the Sitecore installer locally.
Navigate to Home > Bundled Tools > Download Sitecore 8.x
Follow the onscreen prompts and when it asks for a version select:
$sitecoreFullVersion
"@ -foregroundcolor Blue
Write-Host @"
Warning: Other versions of Sitecore will likely not work correctly due to API
and feature changes!
"@ -foregroundcolor Red
Write-Host "When asked enter your SDN credentials." -foregroundcolor blue
Write-Host @"
For GHP employees this will likely be a @thehealthplan.com email account
If you don't know them ask your lead.
"@ -foregroundcolor Yellow
Pause
Write-Host @"
Now we can begin installing Sitecore locally.
Navigate to Home > Install Instance and configure as follows:
Product: Sitecore CMS
Version:$sitecoreVersion
Revision: $sitecoreRevision
Site Name: $localUrl
Host Name: $localUrl
SQL Prefix: $localUrl
Location: $repoRoot$deploySubDirectory
Framework: v$frameorkVersion
Pool Mode: Integrated
"@ -foregroundcolor blue
Write-Host @"
Note: Be sure to fill to double check this and fill it out in order as SIM
automatically replaces a lot of settings after you select a version.
"@ -foreground Yellow
Pause
Write-Host @"
Continue through the remaining screens accepting the default settings:
Instance Details: (all checked)
Modules list: (none)
Custom Packages: (none)
Configuration Presets: (none)
Click Install and wait for the installation to finish.
When it is complete be sure to visit http://$localUrl and verify it is
accessible.
"@ -foreground Blue
}
Function DownloadSIM() {
start $simUrlDownload
}
Function SetupMongo() {
$mongoBasePath = AskDefault "Where would you like to install Mongo?" $defaultMongoPath
if(Test-Path $mongoBasePath) {
$func = $function:InstallMongo
Ask "Mongo appears to already be installed. Would you like to reinstall? (Y/N)" {& $func $mongoBasePath}.GetNewClosure()
} else {
InstallMongo $mongoBasePath
}
if(CheckService $mongoService) {
Ask "Mongo service already exists. Would you like to reinstall? (Y/N)" $function:ReinstallMongoService
} else {
Ask "Would you like to create a Windows Service for Mongo now? (Y/N)" $function:CreateMongoService
}
}
Function InstallMongo($mongoBasePath) {
Write-Host @"
The Mongo installer can be downloaded from:
$mongoUrl
At the time of writing this is version $mongoVersion but later versions
should work.
"@ -foregroundcolor blue
Ask "Would you like to download Mongo $mongoVersion? (Y/N)" DownloadMongo
Write-Host @"
Once Mongo is downloaded, you should be able to install it using the default
installation options.
"@ -foregroundcolor blue
}
Function DownloadMongo() {
start $mongoUrlDownload
}
Function ReinstallMongoService() {
DeleteService $mongoService
CreateMongoService
}
Function CreateMongoService() {
Write-Host "Mongo requires a data directory and a logging directory to run." -foregroundcolor Blue
$mongoFullPath = "$mongoBasePath\$mongodFile"
if(!(Test-Path $mongoFullPath)) {
throw "$mongoFullPath does not exist."
}
$dataPath = AskDefault "What directory do you want to store the db in?" $defaultMongoDataPath
$logPath = AskDefault "What directory do you want to store logging in?" $defaultMongoLogPath
CreateDirectory $dataPath
CreateDirectory $logPath
$logFile = "$logPath\$mongoLogFile"
$command = @"
& "$mongoFullPath" --dbpath=$dataPath --logpath=$logFile --install
"@
Write-Host $command
iex $command
$command = "net start MongoDB"
iex $command
}
Function GetJavaVersion() {
try {
$ErrorActionPreference = "Continue"
$result = &"java.exe" -version 2>&1
$ErrorActionPreference = "Stop"
return $result[0].Exception.Message -replace "java version " -replace """"
}
catch {
return ""
}
return $result
}
Function SetupJava() {
$version = GetJavaVersion
if($version -ne '') {
Ask "Java appears to be already installed. Would like grab the latest? (Y/N)" InstallJava
} else {
InstallJava
}
}
Function InstallJava() {
Write-Host @"
The Java JRE installer can be downloaded from:
$javaUrl
At the time of writing this is version $javaVersion but later versions
should work.
"@ -foregroundcolor blue
Ask "Would you like to download Java $javaVersion? (Y/N)" $function:DownloadJava
Write-Host @"
Once Java is downloaded, you should be able to install it using the default
installation options.
"@ -foregroundcolor blue
}
Function DownloadJava() {
start $javaUrl
}
Function SetupSolr() {
$solrInstallPath = AskDefault "Where would you like to install Solr?" $defaultSolrInstallPath
if(Test-Path $solrInstallPath) {
$func = $function:CleanSolr
Ask "Solr appears to be already installed. Would you like to reinstall? (Y/N)" {& $func $solrInstallPath}.GetNewClosure()
} else {
InstallSolr $solrInstallPath
}
$func = $function:ConfigureSolr
Ask "Would you like to configure Solr? (Y/N)" {& $func $solrInstallPath}.GetNewClosure()
if(CheckTask $solrTask) {
$func = $function:ReinstallSolrTask
Ask "The Solr scheduled task appears to already be installed. Would you like to reinstall? (Y/N)" {& $func $solrInstallPath}.GetNewClosure()
} else {
CreateSolrTask $solrInstallPath
}
}
Function ConfigureSolr($solrInstallPath) {
Write-Host "Copying configuration files to Solr"
$solrConfigPath = $solrInstallPath + "example\solr"
Write-Host $solrConfigPath
Remove-Item -r $solrConfigPath
New-Item $solrConfigPath -type directory
Copy-Item "SolrConfig\solr.xml" $solrConfigPath
$cores = (Get-Item "SolrConfig\solr-cores.zip").FullName
Unzip $cores $solrConfigPath
}
Function ReinstallSolrTask($solrInstallPath) {
DeleteTask $solrTask
CreateSolrTask $solrInstallPath
}
Function CheckTask($name) {
$command = @"
schtasks /query /tn "$name"
"@
iex $command
return $false
}
Function CreateSolrTask($solrInstallPath) {
$startIn = (Get-Location).Path
$task = "powershell -file $startIn\TaskShim.ps1 -command $($solrInstallPath)bin\solr.cmd -argz start"
$command = @"
schtasks /Create /tn $solrTask /SC ONSTART /tr '$task' /ru "NT AUTHORITY\LOCALSERVICE"
"@
iex $command
RunTask $solrTask
}
Function RunTask($name) {
$command = @"
schtasks /run /tn $name
"@
iex $command
}
Function DeleteTask($name) {
$command = @"
schtasks /delete /tn "$name" /f
"@
iex $command
}
Function CleanSolr($solrInstallPath) {
Remove-Item -r $solrInstallPath
InstallSolr $solrInstallPath
}
Function InstallSolr($solrInstallPath) {
Write-Host @"
Now we can download the Solr installer locally from:
$solrUrl
"@ -foregroundcolor blue
Write-Host "At the time of writing this must be version $solrVersion" -foregroundcolor Red
Ask "Would you like to download Solr $solrVersion? (Y/N)" DownloadSolr
Write-Host @"
Once Solr is downloaded we can install it.
"@ -foregroundcolor blue
$solrDownloadPath = AskDefault "Where did you download Solr to?" $defaultSolrDownloadPath
if(!(Test-Path $solrDownloadPath)) {
throw "Unable to find $solrDownloadPath"
}
CreateDirectory $solrInstallPath
Unzip "$solrDownloadPath\solr-$solrVersion" $solrInstallPath
}
Function DownloadSolr() {
start $solrUrlDownload
}
Function SetupSQL() {
Write-Host @"
Please login to your local SQL server and navigate to:
$($env:computername) > Security > Logins
Add a new Login named: IIS AppPool\$localUrl
as Windows Authentication
Under Server Roles select all roles.
Please be aware this account will have more permissions than it needs
and should not be used in production. However at the time of writing
we have not yet identified a reduced permission set.
"@ -foregroundcolor blue
Write-Host @"
Note: IIS AppPool accounts are virtual and will not show up in a search.
This will also only work if the corresponding AppPool has already been
created.
"@ -foregroundcolor Yellow
Write-Host "You will need to restart IIS to make these changes take effect."
Ask "Would you like to restart IIS now?" $function:RestartIIS
}
Function RestartIIS() {
& iisreset.exe
}
Function SetupSSL() {
Write-Host @"
Please open MMC, run the security snap-in and request a self signed cert for
CN=*.loc.geisinger.edu
and give it a friendly name of *.loc.geisinger.edu
This cert can then be installed from
C:\Windows\System32\inetsrv
by running
appcmd set site /site.name:"$localUrl" /+bindings.[protocol='https',bindingInformation='*:443:$localUrl']
Then run
Import-Module WebAdministration
cd IIS:\SslBindings
ls cert:\LocalMachine\My\
And add the binding with
Get-Item cert:\LocalMachine\My\<thumbprint> |New-Item 0.0.0.0!443
These instruction will be automated at a later date.
"@
}
Function SetupIIS() {
Write-Host @"
You will want to make sure that your AppPool is using the
ApplicationPoolIdentity.
Next you'll want to make sure that virtual account has Modify access to
$repoRoot
You can add it by adding the user IIS AppPool\$localUrl under the security
tab and having all descendents inherit permissions. Please note that this
will be a $($env:computername) user and not a GHS_NTDOMAIN user.
"@ -foregroundcolor Yellow
}
Function SetupSitecorePackages() {
Write-Host @"
You will need to manually install the following modules into Sitecore
|Required Modules | Version |
|----------------------------|---------------------------|
| Web Forms For Marketers | 8.1 rev 151217 |
"@ -foregroundcolor Yellow
}
Greet
Ask "Do you need to setup Sitecore? (Y/N)" $function:SetupSitecore
Ask "Do you need to setup Mongo? (Y/N)" $function:SetupMongo
Ask "Do you need to setup Java? (Y/N)" $function:SetupJava
Ask "Do you need to setup Solr? (Y/N)" $function:SetupSolr
Ask "Do you need to setup SQL security (Y/N)" $function:SetupSQL
Ask "Do you need to setup IIS security (Y/N)" $function:SetupIIS
Ask "Do you need to setup SSL? (Y/N)" $function:SetupSSL
Ask "Do you need to setup Sitecore packages? (Y/N)" $function:SetupSitecorePackages
Write-Host "Warning: Fixing configuration will rewrite all content in Website\App_Config" -foregroundcolor red
$func = $function:FixConfiguration
Ask "Do you need to fix configuration settings? (Y/N)" {& $func $repoRoot $deploySubDirectory}.GetNewClosure()
Write-Host @"
You should now be able to access http://$localUrl
Once you have verified your local instance is running sync the TDS assets to the DB
and build the application.
"@ -foregroundcolor Blue
Write-Host @"
If you have any problems with an index please reconfigure solr and the fix
configuration step.
If you have any problems accessing the database or reading the license file
please rerun the Fix configuration steps.
"@ -foregroundcolor Yellow
Pause
No comments:
Post a Comment