The SQL Alias part of the script currently doesn't create an alias in the 64-Bit hive. I have amended the SQL Function as below that would allow it to set the 64-bit alias:
```
Function Add-SQLAlias()
{
<#
.Synopsis
Add a new SQL server Alias
.Description
Adds a new SQL server Alias with the provided parameters.
.Example
Add-SQLAlias -AliasName "SharePointDB" -SQLInstance $env:COMPUTERNAME
.Example
Add-SQLAlias -AliasName "SharePointDB" -SQLInstance $env:COMPUTERNAME -Port '1433'
.Parameter AliasName
The new alias Name.
.Parameter SQLInstance
The SQL server Name os Instance Name
.Parameter Port
Port number of SQL server instance. This is an optional parameter.
#>
[CmdletBinding(DefaultParameterSetName="BuildPath+SetupInfo")]
param
(
[Parameter(Mandatory=$false, ParameterSetName="BuildPath+SetupInfo")][ValidateNotNullOrEmpty()]
[String]$aliasName = "SharePointDB",
[Parameter(Mandatory=$false, ParameterSetName="BuildPath+SetupInfo")][ValidateNotNullOrEmpty()]
[String]$SQLInstance = $env:COMPUTERNAME,
[Parameter(Mandatory=$false, ParameterSetName="BuildPath+SetupInfo")][ValidateNotNullOrEmpty()]
[String]$port = ""
)
If ((MatchComputerName $SQLInstance $env:COMPUTERNAME) -or ($SQLInstance.StartsWith($env:ComputerName +"\"))) {
$protocol = "dbmslpcn" # Shared Memory
}
else {
$protocol = "DBMSSOCN" # TCP/IP
}
$serverAliasConnection="$protocol,$SQLInstance"
If ($port -ne "")
{
$serverAliasConnection += ",$port"
}
$notExist = $true
$client = Get-Item 'HKLM:\SOFTWARE\Microsoft\MSSQLServer\Client' -ErrorAction SilentlyContinue
# Create the key in case it doesn't yet exist
If (!$client32) {$client32 = New-Item 'HKLM:\SOFTWARE\Microsoft\MSSQLServer\Client' -Force}
$client32.GetSubKeyNames() | ForEach-Object -Process { If ( $_ -eq 'ConnectTo') { $notExist=$false }}
If ($notExist)
{
$data32 = New-Item 'HKLM:\SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo'
}
# Create the key (64-bit) in case it doesn't yet exist - Added by James Murray @ Ridgian
If (!$client64) {$client64 = New-Item 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\MSSQLServer\Client' -Force}
$client64.GetSubKeyNames() | ForEach-Object -Process { If ( $_ -eq 'ConnectTo') { $notExist=$false }}
If ($notExist)
{
$data64 = New-Item 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\MSSQLServer\Client\ConnectTo'
}
# Add Alias
$data32 = New-ItemProperty HKLM:\SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo -Name $aliasName -Value $serverAliasConnection -PropertyType "String" -Force -ErrorAction SilentlyContinue
$data64 = New-ItemProperty HKLM:\SOFTWARE\Wow6432Node\Microsoft\MSSQLServer\Client\ConnectTo -Name $aliasName -Value $serverAliasConnection -PropertyType "String" -Force -ErrorAction SilentlyContinue
}
```
Comments: ** Comment from web user: brianlala **
```
Function Add-SQLAlias()
{
<#
.Synopsis
Add a new SQL server Alias
.Description
Adds a new SQL server Alias with the provided parameters.
.Example
Add-SQLAlias -AliasName "SharePointDB" -SQLInstance $env:COMPUTERNAME
.Example
Add-SQLAlias -AliasName "SharePointDB" -SQLInstance $env:COMPUTERNAME -Port '1433'
.Parameter AliasName
The new alias Name.
.Parameter SQLInstance
The SQL server Name os Instance Name
.Parameter Port
Port number of SQL server instance. This is an optional parameter.
#>
[CmdletBinding(DefaultParameterSetName="BuildPath+SetupInfo")]
param
(
[Parameter(Mandatory=$false, ParameterSetName="BuildPath+SetupInfo")][ValidateNotNullOrEmpty()]
[String]$aliasName = "SharePointDB",
[Parameter(Mandatory=$false, ParameterSetName="BuildPath+SetupInfo")][ValidateNotNullOrEmpty()]
[String]$SQLInstance = $env:COMPUTERNAME,
[Parameter(Mandatory=$false, ParameterSetName="BuildPath+SetupInfo")][ValidateNotNullOrEmpty()]
[String]$port = ""
)
If ((MatchComputerName $SQLInstance $env:COMPUTERNAME) -or ($SQLInstance.StartsWith($env:ComputerName +"\"))) {
$protocol = "dbmslpcn" # Shared Memory
}
else {
$protocol = "DBMSSOCN" # TCP/IP
}
$serverAliasConnection="$protocol,$SQLInstance"
If ($port -ne "")
{
$serverAliasConnection += ",$port"
}
$notExist = $true
$client = Get-Item 'HKLM:\SOFTWARE\Microsoft\MSSQLServer\Client' -ErrorAction SilentlyContinue
# Create the key in case it doesn't yet exist
If (!$client32) {$client32 = New-Item 'HKLM:\SOFTWARE\Microsoft\MSSQLServer\Client' -Force}
$client32.GetSubKeyNames() | ForEach-Object -Process { If ( $_ -eq 'ConnectTo') { $notExist=$false }}
If ($notExist)
{
$data32 = New-Item 'HKLM:\SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo'
}
# Create the key (64-bit) in case it doesn't yet exist - Added by James Murray @ Ridgian
If (!$client64) {$client64 = New-Item 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\MSSQLServer\Client' -Force}
$client64.GetSubKeyNames() | ForEach-Object -Process { If ( $_ -eq 'ConnectTo') { $notExist=$false }}
If ($notExist)
{
$data64 = New-Item 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\MSSQLServer\Client\ConnectTo'
}
# Add Alias
$data32 = New-ItemProperty HKLM:\SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo -Name $aliasName -Value $serverAliasConnection -PropertyType "String" -Force -ErrorAction SilentlyContinue
$data64 = New-ItemProperty HKLM:\SOFTWARE\Wow6432Node\Microsoft\MSSQLServer\Client\ConnectTo -Name $aliasName -Value $serverAliasConnection -PropertyType "String" -Force -ErrorAction SilentlyContinue
}
```
Comments: ** Comment from web user: brianlala **
Sorry but I believe you have it backwards :) The new node you're referring to is (on a 64-bit computer) actually the 32-bit node. The original script already correctly creates a 64-bit alias (otherwise, 64-bit applications such as SharePoint wouldn't be able to use it - which it does, successfully). The changes you proposed would only create a 32-bit alias which would only be of use for a 32-bit application. See http://msdn.microsoft.com/en-us/library/windows/desktop/ms724072(v=vs.85).aspx for more info.