Skip to content

Latest commit

 

History

History
94 lines (37 loc) · 3.4 KB

README.md

File metadata and controls

94 lines (37 loc) · 3.4 KB

CheckorUpdateSQLAlias.ps1

This script will read a list of servers and check, update, create, delete or "delete all" new SQL Alias(s) registry keys from within the 32bit and 64bit hives.

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\MSSQLServer\Client\ConnectTo

This is useful when migrating SharePoint servers to a new SQL server, where the SQL instance will change but the alias will remain the same.

How to run:

  1. Create a list of servers in the "Servers.txt" file.

    Note: Make sure your path is correct

    image

  2. Modify the "$sqlalias" and the "$sqlServer" parameters to match your environment.

    Note: These settings can a new entry or a current setting you want to update.

    image

    Please note: When using TCP/IP, "DBMSSOCN, will be added to the string in the registry and a Port number maybe required.

  3. Run the script from a server with an elevated PowerShell ISE or PowerShell.

    image

  4. The "Check" option will read the current key(s) across your list of servers and output all alias's and the configurations to a file in the Temp location.

    Example:

    image

    image

    image

  5. The "Update" option will change the keys according to the names you specified in the inputs:

    Example:

    image

    image

  6. The "Create" option will add a new entry in both the 32bit and 64bit hives if one does not exists.

    Example:

    image

    image

  7. The "Delete" option will delete the specified value in both the 32bit and 64bit "Connect to" keys.

    Example:

    image

    image

  8. The "DeleteAll" option will delete all values in both the 32bit and 64bit "Connect to" keys.

    Note: Use this option with caution as it will delete all current SQL Alias's and could impact your service if this action is not totally understood.

    Example:

    image

    image