Saturday, September 13, 2014

Create SQL Server Alias using PowerShell

As per SharePoint best practices for SQL Server, SQL Alias needs to be created on all SharePoint Servers in the farm. Creating SQL Alias for SharePoint through UI, is already explained in my another post: Create SQL Server Alias for SharePoint , and here is the PowerShell version of creating SQL Server Alias.

#Name of your SQL Server Alias
$AliasName = "SP13_PROD_SQL"

# Actual SQL Server Name
$SQLServerName = "G1VSP13-SQLC001" 

#These are the two Registry locations for the SQL Alias 
$x86 = "HKLM:\Software\Microsoft\MSSQLServer\Client\ConnectTo"
$x64 = "HKLM:\Software\Wow6432Node\Microsoft\MSSQLServer\Client\ConnectTo"

#if the ConnectTo key doesn't exists, create it.
if ((test-path -path $x86) -ne $True)
{
    New-Item $x86
}

if ((test-path -path $x64) -ne $True)
{
    New-Item $x64
}

#Define SQL Alias 
$TCPAliasName = ("DBMSSOCN," + $SQLServerName)

#Create TCP/IP Aliases
New-ItemProperty -Path $x86 -Name $AliasName -PropertyType String -Value $TCPAliasName
New-ItemProperty -Path $x64 -Name $AliasName -PropertyType String -Value $TCPAliasName
finally, open these two executables to verify:
  • C:\Windows\System32\cliconfg.exe
  • C:\Windows\SysWOW64\cliconfg.exe



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...