forked from Sitecore/Habitat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall-xp0.ps1
110 lines (94 loc) · 4.83 KB
/
uninstall-xp0.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#####################################################
#
# Uninstall Sitecore
#
#####################################################
$ErrorActionPreference = "Stop"
. $PSScriptRoot\settings.ps1
Write-Host "*******************************************************" -ForegroundColor Green
Write-Host " UN Installing Sitecore $SitecoreVersion" -ForegroundColor Green
Write-Host " Sitecore: $SitecoreSiteName" -ForegroundColor Green
Write-Host " xConnect: $XConnectSiteName" -ForegroundColor Green
Write-Host "*******************************************************" -ForegroundColor Green
Import-Module "$PSScriptRoot\build\uninstall\uninstall.psm1" -Force
$carbon = Get-Module Carbon
if (-not $carbon) {
$carbon = Get-InstalledModule Carbon -ErrorAction SilentlyContinue
if (-not $carbon) {
write-host "Installing Carbon..." -ForegroundColor Green
Install-Module -Name 'Carbon' -AllowClobber -Scope CurrentUser -Repository PSGallery
}
Import-Module Carbon
}
$database = Get-SitecoreDatabase -SqlServer $SqlServer -SqlAdminUser $SqlAdminUser -SqlAdminPassword $SqlAdminPassword
# Unregister xconnect services
Remove-SitecoreWindowsService "$XConnectSiteName-MarketingAutomationService"
Remove-SitecoreWindowsService "$XConnectSiteName-IndexWorker"
# Delete xconnect site
Remove-SitecoreIisSite $XConnectSiteName
# Drop xconnect databases
Remove-SitecoreDatabase -Name "${SolutionPrefix}_Xdb.Collection.Shard0" -Server $database
Remove-SitecoreDatabase -Name "${SolutionPrefix}_Xdb.Collection.Shard1" -Server $database
Remove-SitecoreDatabase -Name "${SolutionPrefix}_Xdb.Collection.ShardMapManager" -Server $database
Remove-SitecoreDatabase -Name "${SolutionPrefix}_MarketingAutomation" -Server $database
Remove-SitecoreDatabase -Name "${SolutionPrefix}_Processing.Pools" -Server $database
Remove-SitecoreDatabase -Name "${SolutionPrefix}_Processing.Tasks" -Server $database
Remove-SitecoreDatabase -Name "${SolutionPrefix}_ReferenceData" -Server $database
Remove-SitecoreDatabase -Name "${SolutionPrefix}_Reporting" -Server $database
# Delete xconnect files
Remove-SitecoreFiles $XConnectSiteRoot
# Delete xconnect cores
Stop-Service $SolrService
Remove-SitecoreSolrCore "${SolutionPrefix}_xdb" -Root $SolrRoot
Remove-SitecoreSolrCore "${SolutionPrefix}_xdb_rebuild" -Root $SolrRoot
Start-Service $SolrService
# Delete xconnect server certificate
Remove-SitecoreCertificate $XConnectSiteName
# Delete xconnect client certificate
Remove-SitecoreCertificate $XConnectCert
# Delete sitecore site
Remove-SitecoreIisSite $SitecoreSiteName
# Drop sitecore databases
Remove-SitecoreDatabase -Name "${SolutionPrefix}_Core" -Server $database
Remove-SitecoreDatabase -Name "${SolutionPrefix}_ExperienceForms" -Server $database
Remove-SitecoreDatabase -Name "${SolutionPrefix}_EXM.Master" -Server $database
Remove-SitecoreDatabase -Name "${SolutionPrefix}_Master" -Server $database
Remove-SitecoreDatabase -Name "${SolutionPrefix}_Web" -Server $database
Remove-SitecoreDatabase -Name "${SolutionPrefix}_Messaging" -Server $database
# Delete sitecore files
Remove-SitecoreFiles $SitecoreSiteRoot
# Delete sitecore cores
Stop-Service $SolrService
Remove-SitecoreSolrCore "${SolutionPrefix}_core_index" -Root $SolrRoot
Remove-SitecoreSolrCore "${SolutionPrefix}_master_index" -Root $SolrRoot
Remove-SitecoreSolrCore "${SolutionPrefix}_web_index" -Root $SolrRoot
Remove-SitecoreSolrCore "${SolutionPrefix}_marketingdefinitions_master" -Root $SolrRoot
Remove-SitecoreSolrCore "${SolutionPrefix}_marketingdefinitions_web" -Root $SolrRoot
Remove-SitecoreSolrCore "${SolutionPrefix}_marketing_asset_index_master" -Root $SolrRoot
Remove-SitecoreSolrCore "${SolutionPrefix}_marketing_asset_index_web" -Root $SolrRoot
Remove-SitecoreSolrCore "${SolutionPrefix}_testing_index" -Root $SolrRoot
Remove-SitecoreSolrCore "${SolutionPrefix}_suggested_test_index" -Root $SolrRoot
Remove-SitecoreSolrCore "${SolutionPrefix}_fxm_master_index" -Root $SolrRoot
Remove-SitecoreSolrCore "${SolutionPrefix}_fxm_web_index" -Root $SolrRoot
Start-Service $SolrService
# Delete sitecore certificate
Remove-SitecoreCertificate $SitecoreSiteName
# Remove App Pool membership
try
{
Remove-LocalGroupMember "Performance Log Users" "IIS AppPool\$SitecoreSiteName"
Write-Host "Removed IIS AppPool\$SitecoreSiteName from Performance Log Users" -ForegroundColor Green
}
catch
{
Write-Host "Could not find IIS AppPool\$SitecoreSiteName in Performance Log Users" -ForegroundColor Yellow
}
try
{
Remove-LocalGroupMember "Performance Monitor Users" "IIS AppPool\$SitecoreSiteName"
Write-Host "Removed IIS AppPool\$SitecoreSiteName from Performance Monitor Users" -ForegroundColor Green
}
catch
{
Write-Host "Could not find IIS AppPool\$SitecoreSiteName to Performance Monitor Users" -ForegroundColor Yellow
}