1+ <#
2+ . SYNOPSIS
3+ Install the Rubrik Backup Service on a remote machine
4+
5+ . DESCRIPTION
6+ Script will download the Rubrik Backup Service from the RubrikCluster provided. The script will then push the msi, perform a quiet install
7+ and then configure the service to start under a specific service account.
8+
9+ . PARAMETER RubrikCluster
10+ Represents the IP Address or Name of the Rubrik Cluster
11+
12+ . PARAMETER OutFile
13+ Download location of the RubrikBackupService.zip from the RubrikCluster
14+
15+ . PARAMETER ComputerName
16+ Server to install the Rubrik Backup Service On
17+
18+ . EXAMPLE
19+ .\Install-RubrikBackupService.ps1 -RubrikCluster 172.21.8.51 -computername cl-sql2012-1a
20+
21+ . NOTES
22+ Name: Install Rubrik Backup Service
23+ Created: 1/03/2019
24+ Author: Chris Lumnah
25+
26+ #>
27+ # requires -modules RubrikSecurityCloud , PSDscResources
28+ param (
29+ # Rubrik Cluster name or ip address
30+ [Parameter (Mandatory = $true )]
31+ [string ]$RubrikCluster ,
32+
33+ # Computer(s) that should have the Rubrik Backup Service installed onto and then added into Rubrik
34+ [Parameter (Mandatory = $true )]
35+ [String []]$ComputerName ,
36+
37+ # Credential to run the Rubrik Backup Service on the Computer
38+ [Parameter (Mandatory = $false )]
39+ [pscredential ]$RBSCredential ,
40+
41+ # Parameter help description
42+ [Parameter (Mandatory = $false )]
43+ [string ]$OutFile = " c:\temp\RubrikBackupService.zip"
44+ )
45+ $OutputPath = " .\MOF\"
46+ Import-Module RubrikSecurityCloud
47+ Import-Module PSDscResources
48+ Connect-Rsc
49+
50+ # region Download the Rubrik Connector
51+ $RscCluster = Get-RscCluster - Name $RubrikCluster
52+ $query = New-RscQueryCluster - Operation Cluster - AddField ClusterNodeConnection, ClusterNodeConnection.Nodes.ipAddress
53+ $query.var.clusterUuid = $RscCluster.id
54+ $RscClusterNodeConnection = ($query.invoke ()).ClusterNodeConnection.Nodes | Where-Object {$_.Status -eq " OK" } | Select-Object - First 1
55+
56+ $url = " https://$ ( $RscClusterNodeConnection.IpAddress ) /connector/RubrikBackupService.zip"
57+
58+ Invoke-WebRequest - Uri $url - OutFile $OutFile - SkipCertificateCheck
59+ # endregion
60+
61+ configuration RubrikService {
62+ param (
63+ [Parameter (Mandatory = $true )]
64+ [String ]$Server
65+ )
66+ Import-DscResource - ModuleName " PSDscResources"
67+ Node $Server {
68+ ServiceSet Rubrik{
69+ Name = " Rubrik Backup Service"
70+ StartupType = " Automatic"
71+ State = " Running"
72+ Credential = $Node.RubrikServiceAccount
73+ }
74+ }
75+ }
76+
77+ configuration LocalAdministrators {
78+ param (
79+ [Parameter (Mandatory = $true )]
80+ [String ]$Server ,
81+ [String ]$UserName
82+ )
83+ Import-DscResource - ModuleName " PSDscResources"
84+ Node $Server {
85+ GroupSet LocalAdministrators
86+ {
87+ GroupName = @ ( " Administrators" )
88+ Ensure = " Present"
89+ MembersToInclude = @ ( " $ ( $UserName ) " )
90+ }
91+ }
92+ }
93+
94+ # validating the Servername and if it is online
95+ $ValidComputerList = @ ()
96+ foreach ($Computer in $ComputerName ){
97+ $isValidComputer = (Test-Connection - ComputerName $Computer - Count 1 - ErrorAction SilentlyContinue)
98+ if ($isValidComputer ){
99+ Write-Verbose " $Computer , is up"
100+ # $ValidComputerList +=$isValidComputer | ForEach-Object{ [System.Net.Dns]::Resolve($($_.ProtocolAddress)).HostName}
101+ $ValidComputerList += $Computer
102+ }
103+ else {
104+ Write-Warning " Could not connect to server $Computer , the RBS will not be installed on this server!"
105+ }
106+ }
107+
108+ foreach ($Computer in $ValidComputerList ){
109+ # region Push the RubrikBackupService.zip to remote computer
110+ if (Test-Path - Path $OutFile )
111+ {
112+ $Destination = " \\$ ( $Computer ) \C$\Temp\" # RubrikBackupService.zip"
113+ if (! (test-path - path $Destination ))
114+ {
115+ New-Item - Path $Destination - ItemType Directory
116+ }
117+ $Destination = " \\$ ( $Computer ) \C$\Temp\RubrikBackupService.zip"
118+ Copy-Item - Path $OutFile - Destination $Destination - Force
119+ }
120+ # endregion
121+
122+ # region Unzip the RubrikBackupService on the remote computer
123+ $Session = New-PSSession - ComputerName $Computer
124+ Enter-PSSession - Session $Session
125+
126+ Install-Module PSDscResources
127+
128+ Expand-Archive - LiteralPath $OutFile - DestinationPath " \\$ ( $Computer ) \C$\Temp\RubrikBackupService" - Force
129+
130+ Exit-PSSession
131+ # endregion
132+
133+ # region Install the RBS on the Remote Computer
134+ Invoke-Command - ComputerName $Computer - ScriptBlock {
135+ Start-Process - FilePath " C:\Temp\RubrikBackupService\RubrikBackupService.msi" - ArgumentList " /quiet" - Wait
136+ }
137+ # endregion
138+
139+ $ConfigurationData = @ {
140+ AllNodes = @ (
141+ @ {
142+ NodeName = $Computer
143+ PSDscAllowPlainTextPassword = $true
144+ PSDscAllowDomainUser = $true
145+ RubrikServiceAccount = $RBSCredential
146+ }
147+ )
148+ }
149+
150+ # Configure the Local Administrators
151+ LocalAdministrators - Server $Computer - UserName $RBSCredential.UserName - ConfigurationData $ConfigurationData - OutputPath $OutputPath
152+ Start-DscConfiguration - ComputerName $Computer - Path $OutputPath - Verbose - Wait - Force
153+
154+ # Configure the Rubrik Backup Service
155+ $RBSCredential
156+ RubrikService - Server $Computer - ConfigurationData $ConfigurationData - OutputPath $OutputPath
157+ Start-DscConfiguration - ComputerName $Computer - Path $OutputPath - Verbose - Wait - Force
158+
159+ Invoke-Command - ComputerName $Computer - Scriptblock {Get-Service - Name " Rubrik Backup Service" | Stop-Service } - Verbose
160+ Invoke-Command - ComputerName $Computer - Scriptblock {Get-Service - Name " Rubrik Backup Service" | Start-Service } - Verbose
161+
162+ # Add the host to Rubrik
163+ $query = New-RscMutation - GqlMutation bulkRegisterHost - AddField Data , Data .HostSummary
164+ $query.Var.input = New-Object - TypeName RubrikSecurityCloud.Types.BulkRegisterHostInput
165+ $query.Var.input.clusterUuid = $RscCluster.Id
166+ $query.Var.input.hosts = @ ()
167+ $hostInput = New-Object - TypeName RubrikSecurityCloud.Types.HostRegisterInput
168+ $hostInput.Hostname = $ComputerName
169+ $query.Var.input.hosts += $hostInput
170+
171+ ($query.Invoke ()).data.HostSummary
172+
173+ }
0 commit comments