-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathWIN_get_SQL_cluster_info.ps1
65 lines (47 loc) · 2.43 KB
/
WIN_get_SQL_cluster_info.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
add-pssnapin mvpsi.jams
#Set-PSDebug -Trace 1
# had to do this once on each server to import the module that allows for cluster commands execution
#Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools
#Import-Module FailoverClusters
# OK, so this portion gets the SQL cluster information from the all servers in the SQL cluster at SAMC. It then stores
# this info into the variables clustername_INFO. Info in these variables are the SQL server\instances that are currently
# running on the node in the cluster. Once that data has been stored in the variables, then the actual backup for
# the databases in the instances are kicked off
$ccluster="x"
$bigstring="x"
get-clusternode | foreach {
switch ($ccluster)
{
PINTSQLCLSTR1 { Set-JAMSVariable -Name PINTSQLCLSTR1_INFO -Value "$bigstring"}
PINTSQLCLSTR2 { Set-JAMSVariable -Name PINTSQLCLSTR2_INFO -Value "$bigstring"}
PINTSQLCLSTR5 { Set-JAMSVariable -Name PINTSQLCLSTR5_INFO -Value "$bigstring"}
}
$bigstring = "CLUSTER,$_|"
$ccluster="$_"
get-clusternode "$_" | get-clusterresource | Where-Object {$_.Name -like "*SQL Network Name*"} | Format-Table -Wrap -AutoSize | out-string -stream | foreach {
if ($_ -Match "SQL Network Name")
{
while ($_.Contains(" ")){
$_ = $_ -replace " "," "
}
$server=$_.Split(" ")[3]
$server = $server -replace "\(",""
$server = $server -replace "\)",""
$instance=$_.Split(" ")[7]
$instance = $instance -replace "\(",""
$instance = $instance -replace "\)",""
$bigstring += "SERVER,$server|INSTANCE,$instance|"
write-host "BIGSTRING: $bigstring"
}
}
}
switch ($ccluster)
{
PINTSQLCLSTR1 { Set-JAMSVariable -Name PINTSQLCLSTR1_INFO -Value "$bigstring"}
PINTSQLCLSTR2 { Set-JAMSVariable -Name PINTSQLCLSTR2_INFO -Value "$bigstring"}
PINTSQLCLSTR5 { Set-JAMSVariable -Name PINTSQLCLSTR5_INFO -Value "$bigstring"}
}
# SO... the data has been stored, now kick off the jams job that will perform the actual backups.
Submit-JAMSEntry -Agent PINTSQLCLSTR1 -Name DB_BACKUPS\WIN_SQLCLUSTER_dynamic_backup -UserName jamsmo
Submit-JAMSEntry -Agent PINTSQLCLSTR2 -Name DB_BACKUPS\WIN_SQLCLUSTER_dynamic_backup -UserName jamsmo
Submit-JAMSEntry -Agent PINTSQLCLSTR5 -Name DB_BACKUPS\WIN_SQLCLUSTER_dynamic_backup -UserName jamsmo