• The ability to script out all linked servers can be done now using dbatools PowerShell module.

    Copy-DbaLinkedServer will let you migrate the linked server to another instance, and will attempt to decrypt the password.

    Get-DbaLinkedServer can be used to pull all the linked servers on a given instance, and then piped to Export-DbaScript. This used the same scripting method as SSMS so it will not pull the password out either.

    Shawn Melton
    Twitter: @wsmelton
    Blog: wsmelton.github.com
    Github: wsmelton