vagrant-uplift 0.2.1902.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/console +13 -0
- data/bin/setup +8 -0
- data/lib/scripts/vagrant/uplift.vagrant.core/uplift.fix-second-network.ps1 +59 -0
- data/lib/scripts/vagrant/uplift.vagrant.dc12/dc.dsc.ps1 +128 -0
- data/lib/scripts/vagrant/uplift.vagrant.dc12/dc.replica.dsc.ps1 +117 -0
- data/lib/scripts/vagrant/uplift.vagrant.dc12/dc.users.dsc.ps1 +147 -0
- data/lib/scripts/vagrant/uplift.vagrant.dc12/tests/dc.dsc.Tests.ps1 +165 -0
- data/lib/scripts/vagrant/uplift.vagrant.dcjoin/dc.join.dsc.ps1 +125 -0
- data/lib/scripts/vagrant/uplift.vagrant.dcjoin/dc.join.hostname.ps1 +13 -0
- data/lib/scripts/vagrant/uplift.vagrant.dcjoin/tests/dc.join.dsc.Tests.ps1 +12 -0
- data/lib/scripts/vagrant/uplift.vagrant.sharepoint/shared/sp.helpers.ps1 +155 -0
- data/lib/scripts/vagrant/uplift.vagrant.sharepoint/sp2013.dsc.ps1 +248 -0
- data/lib/scripts/vagrant/uplift.vagrant.sharepoint/sp2013.post_setup.dsc.ps1 +117 -0
- data/lib/scripts/vagrant/uplift.vagrant.sharepoint/sp2016.dsc.ps1 +246 -0
- data/lib/scripts/vagrant/uplift.vagrant.sharepoint/sp2016.farm-only.dsc.ps1 +281 -0
- data/lib/scripts/vagrant/uplift.vagrant.sharepoint/sp2016.info.ps1 +36 -0
- data/lib/scripts/vagrant/uplift.vagrant.sharepoint/sp2016.post_setup.dsc.ps1 +125 -0
- data/lib/scripts/vagrant/uplift.vagrant.sharepoint/sp2016.pre_setup1.dsc.ps1 +28 -0
- data/lib/scripts/vagrant/uplift.vagrant.sharepoint/sp2016.pre_setup2.dsc.ps1 +75 -0
- data/lib/scripts/vagrant/uplift.vagrant.sharepoint/tests/sp2013.dsc.wfe.Tests.ps1 +68 -0
- data/lib/scripts/vagrant/uplift.vagrant.sharepoint/tests/sp2016.dsc.wfe.Tests.ps1 +68 -0
- data/lib/scripts/vagrant/uplift.vagrant.sql12/sql.complete.dsc.ps1 +186 -0
- data/lib/scripts/vagrant/uplift.vagrant.sql12/sql.dsc.ps1 +66 -0
- data/lib/scripts/vagrant/uplift.vagrant.sql12/sql.optimize.dsc.ps1 +50 -0
- data/lib/scripts/vagrant/uplift.vagrant.sql12/sql.prepare.dsc.ps1 +60 -0
- data/lib/scripts/vagrant/uplift.vagrant.sql12/tests/sql.dsc.Tests.ps1 +23 -0
- data/lib/scripts/vagrant/uplift.vagrant.sql12/tests/sql12.dsc.Tests.ps1 +45 -0
- data/lib/scripts/vagrant/uplift.vagrant.sql12/tests/sql16.dsc.Tests.ps1 +22 -0
- data/lib/scripts/vagrant/uplift.vagrant.visual_studio13/tests/vs13.dsc.Tests.ps1 +61 -0
- data/lib/scripts/vagrant/uplift.vagrant.visual_studio13/vs13.dsc.post_deploy.ps1 +32 -0
- data/lib/scripts/vagrant/uplift.vagrant.visual_studio13/vs13.dsc.ps1 +69 -0
- data/lib/scripts/vagrant/uplift.vagrant.visual_studio17/tests/vs17.dsc.Tests.ps1 +61 -0
- data/lib/scripts/vagrant/uplift.vagrant.visual_studio17/vs17.dsc.post_deploy.ps1 +34 -0
- data/lib/scripts/vagrant/uplift.vagrant.visual_studio17/vs17.dsc.ps1 +134 -0
- data/lib/scripts/vagrant/uplift.vagrant.win12soe/soe.dsc.ps1 +115 -0
- data/lib/scripts/vagrant/uplift.vagrant.win12soe/soe.shortcuts.dsc.ps1 +41 -0
- data/lib/scripts/vagrant/uplift.vagrant.win12soe/tests/soe.dsc.modules.Tests.ps1 +71 -0
- data/lib/scripts/vagrant/uplift.vagrant.win12soe/tests/soe.dsc.os.Tests.ps1 +89 -0
- data/lib/vagrant-uplift.rb +8 -0
- data/lib/vagrant-uplift/config_builder.rb +819 -0
- data/lib/vagrant-uplift/log.rb +146 -0
- data/lib/vagrant-uplift/plugin-vagrant-uplift-checkpoint.rb +41 -0
- data/lib/vagrant-uplift/plugin.rb +16 -0
- data/lib/vagrant-uplift/version.rb +10 -0
- metadata +131 -0
@@ -0,0 +1,165 @@
|
|
1
|
+
# avoiding: Attempting to perform the InitializeDefaultDrives operation on the ‘ActiveDirectory’ provider failed.
|
2
|
+
# https://mikefrobbins.com/2011/02/17/managed-service-accounts/
|
3
|
+
|
4
|
+
try {
|
5
|
+
Import-Module ActiveDirectory -ErrorAction SilentlyContinue
|
6
|
+
|
7
|
+
} catch {
|
8
|
+
try {
|
9
|
+
Import-Module ActiveDirectory
|
10
|
+
} catch {
|
11
|
+
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
|
16
|
+
Describe 'Domain Controller' {
|
17
|
+
|
18
|
+
Context "Network" {
|
19
|
+
|
20
|
+
It 'ipconfig like "192.168.*.*"' {
|
21
|
+
((Get-NetIpAddress) `
|
22
|
+
| where-object { $_.IPAddress -like "192.168.*.*" }) `
|
23
|
+
| Should Not Be $null
|
24
|
+
}
|
25
|
+
|
26
|
+
}
|
27
|
+
|
28
|
+
Context "Features" {
|
29
|
+
It 'AD-Domain-Services' {
|
30
|
+
(Get-WindowsFeature AD-Domain-Services).InstallState | Should BeLike "Installed"
|
31
|
+
}
|
32
|
+
|
33
|
+
It 'DNS' {
|
34
|
+
(Get-WindowsFeature DNS).InstallState | Should BeLike "Installed"
|
35
|
+
}
|
36
|
+
|
37
|
+
}
|
38
|
+
|
39
|
+
Context "Services" {
|
40
|
+
|
41
|
+
It 'DNS Server' {
|
42
|
+
(Get-Service "DNS Server").Status | Should BeLike "Running"
|
43
|
+
}
|
44
|
+
|
45
|
+
It 'Active Directory Domain Services' {
|
46
|
+
(Get-Service "Active Directory Domain Services").Status | Should BeLike "Running"
|
47
|
+
}
|
48
|
+
|
49
|
+
It 'Active Directory Web Services' {
|
50
|
+
(Get-Service "Active Directory Web Services").Status | Should BeLike "Running"
|
51
|
+
}
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
Context "AD Module warm up" {
|
56
|
+
|
57
|
+
# warning up AD
|
58
|
+
# looks like it would always fails for the first run
|
59
|
+
# https://social.msdn.microsoft.com/Forums/en-US/60fed6d1-e5ab-4a0f-8c45-c08eccf29cb7/custom-script-extension-importmodule-attempting-to-perform-the-initializedefaultdrives-operation?forum=azurescripting
|
60
|
+
BeforeAll {
|
61
|
+
try {
|
62
|
+
Import-Module ActiveDirectory
|
63
|
+
|
64
|
+
} catch {
|
65
|
+
|
66
|
+
}
|
67
|
+
|
68
|
+
try {
|
69
|
+
props = get-ADComputer $env:computername -properties *
|
70
|
+
|
71
|
+
} catch {
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
try {
|
76
|
+
$user = Get-ADUser "vagrant"
|
77
|
+
|
78
|
+
} catch {
|
79
|
+
|
80
|
+
}
|
81
|
+
|
82
|
+
}
|
83
|
+
|
84
|
+
It 'AD module warn up' {
|
85
|
+
|
86
|
+
try {
|
87
|
+
Import-Module ActiveDirectory
|
88
|
+
|
89
|
+
} catch {
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
try {
|
94
|
+
props = get-ADComputer $env:computername -properties *
|
95
|
+
|
96
|
+
} catch {
|
97
|
+
|
98
|
+
}
|
99
|
+
|
100
|
+
try {
|
101
|
+
$user = Get-ADUser "vagrant"
|
102
|
+
|
103
|
+
} catch {
|
104
|
+
|
105
|
+
}
|
106
|
+
}
|
107
|
+
|
108
|
+
}
|
109
|
+
|
110
|
+
|
111
|
+
Context "Users" {
|
112
|
+
|
113
|
+
# warning up AD
|
114
|
+
# looks like it would always fails for the first run
|
115
|
+
# https://social.msdn.microsoft.com/Forums/en-US/60fed6d1-e5ab-4a0f-8c45-c08eccf29cb7/custom-script-extension-importmodule-attempting-to-perform-the-initializedefaultdrives-operation?forum=azurescripting
|
116
|
+
BeforeAll {
|
117
|
+
try {
|
118
|
+
Import-Module ActiveDirectory
|
119
|
+
|
120
|
+
} catch {
|
121
|
+
|
122
|
+
}
|
123
|
+
|
124
|
+
try {
|
125
|
+
props = get-ADComputer $env:computername -properties *
|
126
|
+
|
127
|
+
} catch {
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
try {
|
132
|
+
$user = Get-ADUser "vagrant"
|
133
|
+
|
134
|
+
} catch {
|
135
|
+
|
136
|
+
}
|
137
|
+
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
Context "Domain Controller" {
|
142
|
+
|
143
|
+
# It 'PrimaryGroupID: 516' {
|
144
|
+
|
145
|
+
# Import-Module ActiveDirectory
|
146
|
+
# $props = get-ADComputer $env:computername -properties *
|
147
|
+
# $id = $props.PrimaryGroupID
|
148
|
+
|
149
|
+
# $id | Should Be 516
|
150
|
+
# }
|
151
|
+
|
152
|
+
It 'domain: *.local' {
|
153
|
+
|
154
|
+
$env:USERDNSDOMAIN | Should BeLike "*.local"
|
155
|
+
}
|
156
|
+
|
157
|
+
It 'vm name: *.local' {
|
158
|
+
$name = (Get-WmiObject win32_computersystem).DNSHostName+"."+(Get-WmiObject win32_computersystem).Domain
|
159
|
+
|
160
|
+
$name | Should BeLike "*.local"
|
161
|
+
}
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
}
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# fail on errors and include uplift helpers
|
2
|
+
$ErrorActionPreference = "Stop"
|
3
|
+
|
4
|
+
Import-Module Uplift.Core
|
5
|
+
|
6
|
+
Write-UpliftMessage "Running windows SOE config..."
|
7
|
+
Write-UpliftEnv
|
8
|
+
|
9
|
+
$computerName = $env:computername
|
10
|
+
|
11
|
+
$domainName = Get-UpliftEnvVariable "UPLF_DC_DOMAIN_NAME"
|
12
|
+
$domainJoinUserName = Get-UpliftEnvVariable "UPLF_DC_JOIN_USER_NAME"
|
13
|
+
$domainJoinUserPassword = Get-UpliftEnvVariable "UPLF_DC_JOIN_USER_PASSWORD"
|
14
|
+
$domainIpAddr = Get-UpliftEnvVariable "UPLF_DC_DOMAIN_HOST_IP"
|
15
|
+
|
16
|
+
Write-UpliftMessage "Joining computer [$computerName] to domain [$domainName] under user [$domainJoinUserName]"
|
17
|
+
Write-UpliftMessage "Running as :[$($env:UserDomain)/$($env:UserName)] on $($env:ComputerName)"
|
18
|
+
|
19
|
+
$securePassword = ConvertTo-SecureString $domainJoinUserPassword -AsPlainText -Force
|
20
|
+
$domainJoinUserCreds = New-Object System.Management.Automation.PSCredential($domainJoinUserName, $securePassword)
|
21
|
+
|
22
|
+
# helpers
|
23
|
+
Write-UpliftMessage "Importing ActiveDirectory module..."
|
24
|
+
Import-Module ActiveDirectory
|
25
|
+
|
26
|
+
function Helper-RemoveADComputer
|
27
|
+
{
|
28
|
+
Param(
|
29
|
+
[Parameter(Mandatory=$True)]
|
30
|
+
$computerName,
|
31
|
+
|
32
|
+
[Parameter(Mandatory=$True)]
|
33
|
+
$domainJoinUserCreds,
|
34
|
+
|
35
|
+
[Parameter(Mandatory=$True)]
|
36
|
+
$domainIpAddr
|
37
|
+
)
|
38
|
+
|
39
|
+
$computer = $null
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
try {
|
44
|
+
Write-UpliftMessage "Fetching computer from Active Directory: $computerName"
|
45
|
+
|
46
|
+
$computer = get-adcomputer $computerName `
|
47
|
+
-ErrorAction SilentlyContinue `
|
48
|
+
-Credential $domainJoinUserCreds `
|
49
|
+
-Server $domainIpAddr
|
50
|
+
} catch {
|
51
|
+
|
52
|
+
Write-UpliftMessage "There was an error while fetching computer from Active Directory:[$computerName]"
|
53
|
+
Write-UpliftMessage "Mostlikely, computer $computerName has never been added to Active Directory yet"
|
54
|
+
|
55
|
+
Write-UpliftMessage $_
|
56
|
+
Write-UpliftMessage $_.Exception
|
57
|
+
|
58
|
+
$computer = $null
|
59
|
+
}
|
60
|
+
|
61
|
+
if($null -ne $computer ) {
|
62
|
+
Write-UpliftMessage "Removing computer from Active Directory: $computerName"
|
63
|
+
|
64
|
+
Remove-ADComputer -identity $computerName `
|
65
|
+
-Confirm:$false `
|
66
|
+
-Credential $domainJoinUserCreds `
|
67
|
+
-Server $domainIpAddr
|
68
|
+
|
69
|
+
Write-UpliftMessage "Removed computer from Active Directory: $computerName"
|
70
|
+
|
71
|
+
} else {
|
72
|
+
Write-UpliftMessage "No need to remove computer $computerName from Active Directory"
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
Write-UpliftMessage "Joining current computer to domain..."
|
77
|
+
|
78
|
+
if((Get-CimInstance -Class Win32_ComputerSystem).PartOfDomain) {
|
79
|
+
Write-UpliftMessage "This computer, $computerName, is already part of domain. No domain join or reboot is required"
|
80
|
+
}
|
81
|
+
else {
|
82
|
+
|
83
|
+
Write-UpliftMessage "ipconfig /flushdns"
|
84
|
+
ipconfig /flushdns
|
85
|
+
|
86
|
+
Write-UpliftMessage "pinging dc: $domainIpAddr"
|
87
|
+
ping $domainIpAddr
|
88
|
+
|
89
|
+
# TODO, add error handling if dc isn't pingable
|
90
|
+
|
91
|
+
Write-UpliftMessage "Deleting old computer from the domain..."
|
92
|
+
Helper-RemoveADComputer $computerName $domainJoinUserCreds $domainIpAddr
|
93
|
+
|
94
|
+
Write-UpliftMessage "Joining computer to the domain..."
|
95
|
+
|
96
|
+
try {
|
97
|
+
if($computerName -ne $env:computername) {
|
98
|
+
Write-UpliftMessage "Joining computer with name [$($env:computername)] as [$computerName] to domain:[$domainName]"
|
99
|
+
|
100
|
+
Add-Computer -DomainName $domainName `
|
101
|
+
-NewName $computerName `
|
102
|
+
-Credential $domainJoinUserCreds
|
103
|
+
} else {
|
104
|
+
Write-UpliftMessage "Joining computer [$computerName] to domain [$domainName]"
|
105
|
+
|
106
|
+
Add-Computer -DomainName $domainName `
|
107
|
+
-Credential $domainJoinUserCreds
|
108
|
+
}
|
109
|
+
} catch {
|
110
|
+
$errorMessage = $_.ToString()
|
111
|
+
|
112
|
+
Write-UpliftMessage "Error while adding ccomputer [$computerName] to domain [$domainName]"
|
113
|
+
Write-UpliftMessage $errorMessage
|
114
|
+
|
115
|
+
if($errorMessage.Contains("0x21c4") -eq $true) {
|
116
|
+
Write-UpliftMessage "!!! - Mostlikely, this image wasn't sysprep-ed: DC and client VMs have the same SID and won't even be joined. Run provision with syspreped image to join VMs to domain."
|
117
|
+
}
|
118
|
+
|
119
|
+
throw $_
|
120
|
+
}
|
121
|
+
|
122
|
+
Write-UpliftMessage "Joining completed, a reboot is required"
|
123
|
+
}
|
124
|
+
|
125
|
+
exit 0
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# fail on errors and include uplift helpers
|
2
|
+
$ErrorActionPreference = "Stop"
|
3
|
+
|
4
|
+
Import-Module Uplift.Core
|
5
|
+
|
6
|
+
$fullComputerName = ( Get-CimInstance win32_computersystem ).DNSHostName `
|
7
|
+
+ "." `
|
8
|
+
+ (Get-CimInstance win32_computersystem).Domain
|
9
|
+
|
10
|
+
Write-UpliftMessage "`thost name: $(hostname)"
|
11
|
+
Write-UpliftMessage "`tfull name: $fullComputerName"
|
12
|
+
|
13
|
+
exit 0
|
@@ -0,0 +1,155 @@
|
|
1
|
+
|
2
|
+
function global:Import-UpAssembly {
|
3
|
+
|
4
|
+
Param(
|
5
|
+
[Parameter(Mandatory=$True)]
|
6
|
+
[String]$assemblyName
|
7
|
+
)
|
8
|
+
|
9
|
+
$assembly = [System.Reflection.Assembly]::LoadWithPartialName($assemblyName)
|
10
|
+
|
11
|
+
if ($null -eq $assembly) {
|
12
|
+
$errorMessage = "Cannot load assembly by its name: $assemblyName"
|
13
|
+
|
14
|
+
Write-UpliftMessage $errorMessage
|
15
|
+
throw $errorMessage
|
16
|
+
} else {
|
17
|
+
$errorMessage = "Loaded assembly by name: $assemblyName"
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
function global:Import-UpAssemblies {
|
22
|
+
|
23
|
+
Param(
|
24
|
+
[Parameter(Mandatory=$True)]
|
25
|
+
[String[]]$assemblyNames
|
26
|
+
)
|
27
|
+
|
28
|
+
foreach($assemblyName in $assemblyNames) {
|
29
|
+
Import-UpAssembly $assemblyName
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
function global:Get-UpSPConfigDbDNS($majorVersion) {
|
34
|
+
|
35
|
+
if($null -eq $majorVersion) {
|
36
|
+
$majorVersion = "15"
|
37
|
+
}
|
38
|
+
|
39
|
+
$regPath = "HKLM:\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\$majorVersion.0\Secure\ConfigDB"
|
40
|
+
$item = Get-ItemProperty $regPath -ErrorAction SilentlyContinue
|
41
|
+
|
42
|
+
if($null -eq $item) {
|
43
|
+
return $null
|
44
|
+
}
|
45
|
+
|
46
|
+
return $item.dsn
|
47
|
+
}
|
48
|
+
|
49
|
+
function global:Invoke-UpSqlQuery($server, $query) {
|
50
|
+
Write-UpliftMessage "Annoying SQL server [$server] with query [$query]"
|
51
|
+
|
52
|
+
$connection = New-Object "System.Data.SqlClient.SqlConnection" `
|
53
|
+
-ArgumentList @("Server = $server; Database = master; Integrated Security = True;")
|
54
|
+
|
55
|
+
|
56
|
+
$connection.Open()
|
57
|
+
|
58
|
+
$sqlCommand = New-Object "System.Data.SqlClient.SqlCommand" -ArgumentList @($query, $connection);
|
59
|
+
$sqlCommand.ExecuteNonQuery() | Out-Null
|
60
|
+
|
61
|
+
$connection.Close()
|
62
|
+
}
|
63
|
+
|
64
|
+
function global:Invoke-UpSqlReaderQuery($server, $query) {
|
65
|
+
Write-UpliftMessage "Annoying SQL server [$server] with query [$query]"
|
66
|
+
|
67
|
+
$result = @()
|
68
|
+
|
69
|
+
$connection = New-Object "System.Data.SqlClient.SqlConnection" `
|
70
|
+
-ArgumentList @("Server = $server; Database = master; Integrated Security = True;")
|
71
|
+
|
72
|
+
|
73
|
+
#$sqlCommandText = $query;
|
74
|
+
$connection.Open()
|
75
|
+
|
76
|
+
$sqlCommand = New-Object "System.Data.SqlClient.SqlCommand" -ArgumentList @($query, $connection);
|
77
|
+
$reader = $sqlCommand.ExecuteReader()
|
78
|
+
|
79
|
+
while( $reader.Read() -eq $true) {
|
80
|
+
$result += $reader.GetValue(0)
|
81
|
+
#Write-UpliftMessage "Result: [$($reader.GetValue(0))]"
|
82
|
+
}
|
83
|
+
|
84
|
+
$connection.Close()
|
85
|
+
|
86
|
+
return $result
|
87
|
+
}
|
88
|
+
|
89
|
+
function global:Remove-UpSqlDb($name) {
|
90
|
+
$sqlCommandText = "DROP DATABASE $name";
|
91
|
+
$sqlCommand = New-Object System.DateSqlCommand -arguments ($sqlCommandText, $connection);
|
92
|
+
$sqlCommand.ExecuteNonQuery();
|
93
|
+
}
|
94
|
+
|
95
|
+
function global:Confirm-UpSPInstalled {
|
96
|
+
# assuming SharePoint 2013 by default
|
97
|
+
$configDbDns = Get-UpSPConfigDbDNS 15
|
98
|
+
|
99
|
+
# checking if SharePoint 2016 is here
|
100
|
+
if($null -eq $configDbDns) {
|
101
|
+
$configDbDns = Get-UpSPConfigDbDNS 16
|
102
|
+
}
|
103
|
+
|
104
|
+
Write-UpliftMessage "Detected config Db DNS:[$configDbDns]"
|
105
|
+
$isSharePointInstalled = ($null -ne $configDbDns)
|
106
|
+
|
107
|
+
return $isSharePointInstalled
|
108
|
+
}
|
109
|
+
|
110
|
+
function global:Initialize-UpSPSqlServer {
|
111
|
+
Param(
|
112
|
+
[Parameter(Mandatory=$True)]
|
113
|
+
[String]$spSqlServerName,
|
114
|
+
|
115
|
+
[Parameter(Mandatory=$True)]
|
116
|
+
[String]$spSqlDbPrefix
|
117
|
+
)
|
118
|
+
|
119
|
+
Write-UpliftMessage "Preparing SQL Server [$spSqlServerName] for SharePoint deployment. DBs prefix: $spSqlDbPrefix"
|
120
|
+
|
121
|
+
# prepare SQL Server for SharePoint deployment
|
122
|
+
$isSharePointInstalled = Confirm-UpSPInstalled
|
123
|
+
|
124
|
+
if($isSharePointInstalled) {
|
125
|
+
Write-UpliftMessage "Detected that SharePoint is already installed. No need to create Farm or Join to farm"
|
126
|
+
} else {
|
127
|
+
Remove-UpSPSqldatabases $spSqlServerName $spSqlDbPrefix
|
128
|
+
}
|
129
|
+
}
|
130
|
+
|
131
|
+
function global:Remove-UpSPSqldatabases {
|
132
|
+
|
133
|
+
Param(
|
134
|
+
[Parameter(Mandatory=$True)]
|
135
|
+
[String]$spSqlServerName,
|
136
|
+
|
137
|
+
[Parameter(Mandatory=$True)]
|
138
|
+
[String]$spSqlDbPrefix
|
139
|
+
)
|
140
|
+
|
141
|
+
Import-UpAssemblies @(
|
142
|
+
"System.Data"
|
143
|
+
)
|
144
|
+
|
145
|
+
Write-UpliftMessage "`t - cleaning up SQL databases with prefix: $spSqlDbPrefix"
|
146
|
+
|
147
|
+
$dbs = Invoke-UpSqlReaderQuery $spSqlServerName "select name from dbo.sysdatabases"
|
148
|
+
|
149
|
+
foreach($dbName in $dbs) {
|
150
|
+
if($dbName.ToLower().StartsWith($spSqlDbPrefix.ToLower()) -eq $true) {
|
151
|
+
Invoke-UpSqlQuery $spSqlServerName "alter database [$dbName] set single_user with rollback immediate"
|
152
|
+
Invoke-UpSqlQuery $spSqlServerName "drop database [$dbName]"
|
153
|
+
}
|
154
|
+
}
|
155
|
+
}
|