In the below example, the <drive> parameter is set to RC (for Root Cluster) Download the hotfix for KB2619256 and place it at c:\deploy
Example (Save as InstallRoot.ps1):
Import-Module ServerManager
If (Get-WindowsFeature | Where {$_.Name -eq "ADRMS-Server"} | Where {!($_.installed)}){
Add-WindowsFeature ADRMS-Server -restart
}
#(Install hotfix KB2619256 - it should install after the ADRMS Role was added above)
If (!(Get-Hotfix | Where {$_.hotfixid -eq "KB2619256"}))
{
Write-Host "`n`n`n`n`n`n`n`nInstall hotfix KB2619256 if needed"
c:\deploy\Windows6.1-KB2619256-x64.msu
Write-Host "Pause until hotfix is installed. You may need to restart after hotfix if directed to. (any key to continue)"
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Write-Host "`n`n`n`n`n`n`n`nYou will now be prompted to supply the Service Account, then the Cluster Key Password. (any key to continue)"
$svcacct = Get-Credential
$password = Read-Host -AsSecureString -Prompt “ClusterPassword”
Write-Host "You will now be prompted to supply the SQL server FQDN, the instance name, the Cluster URL, and the SLC. (any key to continue)"
$sqlserver = Read-Host -Prompt "Enter SQL server FQDN (eg. sql.fabrikam.com)"
$instance = Read-Host -Prompt "Enter SQL server instance name (Press Enter for a default instance)"
if ($instance -eq ""){
$instance = "MSSQLSERVER"
$clusWeb = Read-Host -Prompt "Enter AD RMS Website name (Press Enter for the default website)"
$clusURL = Read-Host -Prompt "Enter the cluster URL (eg. http://adrms.fabrikam.com/)"
if ($clusURL.Split("/")[0] -eq "https:"){
$clusURL += ":443"
}else{
$clusURL += ":80"
$SLC = Read-Host -Prompt "Enter the SLC name (eg. ADRMS)"
$SCP = Read-Host -Prompt "Register SCP: [y] or [n]. Default is [y]"
if ($SCP -eq "y"){
$SCP = $true
if ($SCP -eq ""){
if ($SCP -eq "n"){
$SCP = $false
Import-Module ADRMS
New-PSDrive -Name RC -PsProvider AdRmsInstall -Root RootCluster
Set-Location RC:\
Set-ItemProperty -Path RC:\ClusterDatabase -Name UseWindowsInternalDatabase -Value $false
Set-ItemProperty -Path RC:\ClusterDatabase -Name ServerName -Value $sqlserver
Set-ItemProperty -Path RC:\ClusterDatabase -Name InstanceName -Value $instance
Set-ItemProperty -Path RC:\ -Name ServiceAccount -Value $svcacct
Set-ItemProperty -Path RC:\ClusterKey -Name UseCentrallyManaged -Value $true
Set-ItemProperty -Path RC:\ClusterKey -Name CentrallyManagedPassword -Value $password
Set-ItemProperty -Path RC:\ -Name ClusterURL -Value $clusURL
Set-ItemProperty -Path RC:\ -Name SLCName -Value $SLC
Set-ItemProperty -Path RC:\ -Name RegisterSCP -Value $SCP
Install-ADRMS -Path RC:\
Open up PowerShell using Run as Administrator. Set-ExecutionPolicy Unrestricted Run InstallRoot.ps1 If you are joining additional nodes to the cluster, you can use the code below to perform the join. Feel free to hard-code the values rather than typing them in during the install. Note that I have made several assumptions regarding a standard install/join. Please make sure that you have tested this in your environment before using in production.
Import-Module Servermanager
If (Get-WindowsFeature | Where {$_.Name -eq "ADRMS-Server"} | Where {!($_.installed)})
#All the Write-Host lines are to avoid the status banner
Write-Host "You will now be prompted to supply the SQL server FQDN, the instance name, and the Configuration database name. (any key to continue)"
$configdb = Read-Host -Prompt "Enter Config database name (eg. DRMS_Config_adrms_fabrikam_com_80)"
if ($instance -eq "")
$connstr="data source=$sqlserver;integrated security=SSPI;persist security info=False;packet size=4096;database=$configdb"
$connstr="data source=$sqlserver\$instance;integrated security=SSPI;persist security info=False;packet size=4096;database=$configdb"
#---AdRmsFileVersion Check----
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection
$sqlCommand = New-Object System.Data.SqlClient.SqlCommand
$sqlConnection.ConnectionString = $connStr
$sqlConnection.Open()
$sqlCommand.CommandText = "SELECT * FROM dbo.drms_clusterpolicies"
$sqlCommand.Connection = $sqlConnection
$da = New-Object System.Data.SqlClient.SqlDataAdapter
$da.SelectCommand = $sqlCommand
$dt = New-Object System.Data.DataTable
$da.fill($dt) | Out-null
$FileVersion = $dt | Where{$_.PolicyName -eq "AdRmsFileVersion"} | Select PolicyData
if (!($FileVersion.PolicyData -eq "6.1.7601.17514"))
$cmd = $sqlConnection.CreateCommand()
$cmd.CommandText ="UPDATE DRMS_ClusterPolicies set PolicyData = '6.1.7601.17514' Where PolicyName = 'AdRmsFileVersion'"
$cmd.ExecuteNonQuery()
$sqlConnection.Close()
#---/AdRmsFileVersion Check----
Write-Host "`n`n`n`n`n`n`n`n"
New-PSDrive -PSProvider ADRMSInstall -Name CM -Root JoinCluster -Scope global
Set-Location CM:
#Configure Database
Set-ItemProperty -Path CM:\ClusterDatabase -Name UseWindowsInternalDatabase -Value $false
Write-Host "Set ServerName and Instance"
Set-ItemProperty -Path CM:\ClusterDatabase -Name ServerName -Value $sqlserver\$instance
Write-Host "Set Config Database"
Set-ItemProperty -Path CM:\ClusterDatabase -Name DatabaseName -Value $configdb
#Configure Service Account
Set-ItemProperty -Path CM:\ -Name ServiceAccount -Value $svcacct
#Setting Cluster Password
Set-ItemProperty -Path CM:\ClusterKey -Name CentrallyManagedPassword -Value $password
get-location
Install-ADRMS -Path CM:\
Write-Host "End of install script"
Richard Mueller edited Revision 5. Comment: Modified title, removed tag "SQL2012" (we already have tag "SQL Server 2012")
Richard Mueller edited Revision 4. Comment: Replaced RGB values with color names in HTML to restore colors
Richard Mueller edited Revision 3. Comment: Modified title casing, added tag