Simplifying SQL Server Migrations using PowerShell

Recently, I did a webcast for the PowerShell Virtual Chapter of PASS on Simplifying SQL Server Migrations using PowerShell. If you’re planning for a SQL Server migration, I wrote a bunch of scripts that can help, and put them all on github.

Check out the sqlmigration repository, and the accompanying PowerPoint Slides.

If you use the scripts and run into any issues, or have any feature requests, let me know. I can be contacted on Twitter at @cl or by email.

Chrissy is a PowerShell MVP who has worked in IT for nearly 20 years, and currently serves as a Sr. Database Engineer in Belgium. Always an avid scripter, she attended the Monad session at Microsoft’s Professional Developers Conference in Los Angeles back in 2005 and has worked and played with PowerShell ever since. Chrissy is currently pursuing an MS in Systems Engineering at Regis University and helps maintain RealCajunRecipes.com in her spare time. She holds a number of certifications, including those relating to SQL Server, SuSE Linux, SharePoint and network security. She recently became co-lead of the SQL PASS PowerShell Virtual Chapter. You can follow her on Twitter at @cl.

Posted in PowerShell, SQL Server
2 comments on “Simplifying SQL Server Migrations using PowerShell
  1. Eduardo E Mardini says:

    Hi Chrissy, thank you for the script, it is a lot of work!!!

    I’m trying to execute it, but I’m always having issues, if I run the diagnostic

    $username = “myuser”
    $password = cat C:\securestring.txt | convertto-securestring
    $SqlCredential = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
    Test-SqlConnection -SqlServer myserver -SqlCredential $SqlCredential

    I get
    ServerName : oniloyalty.cloudapp.net
    BaseName : oniloyalty.cloudapp.net
    InstanceName : (Default)
    AuthType : SQL Authentication
    ConnectingAsUser : myuser
    ConnectSuccess : True
    SqlServerVersion : 10.50.2550
    AddlConnectInfo : N/A
    RemoteServer : True
    IPAddress : {MyIp}
    NetBIOSname : Unknown
    RemotingAccessible : False
    Pingable : False
    DefaultSQLPortOpen : True
    RemotingPortOpen : False

    But if I run

    $username = “myuser”
    $password = cat C:\securestring.txt | convertto-securestring
    $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
    Start-SqlMigration -Verbose -Source mysource.cloudapp.net -Destination mydestcloudapp.net -SourceSqlCredential $cred -ReuseFolderstructure -DestinationSqlCredential $cred -Force -NetworkShare \\myshare.file.core.windows.net\data001 -BackupRestore

    I get a connection error in both ends (credentials are the same in each server), this is the error:
    Start-SqlMigration : Credential migration reported the following error Can’t connect to mysource.cloudapp.net:
    System.Data.SqlClient.SqlException (0x80131904): Login failed. The login is from an untrusted domain and cannot be
    used with Windows authentication.

    The servers are azure virtual machines in different domains, but I’m using a file share.

    What I’m doing wrong here?

    Thank you!

  2. Eduardo E Mardini says:

    Sorry for repeating my question, but my email was wrong …

    Hi Chrissy, thank you for the script, it is a lot of work!!!

    I’m trying to execute it, but I’m always having issues, if I run the diagnostic

    $username = “myuser”
    $password = cat C:\securestring.txt | convertto-securestring
    $SqlCredential = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
    Test-SqlConnection -SqlServer myserver -SqlCredential $SqlCredential

    I get
    ServerName : oniloyalty.cloudapp.net
    BaseName : oniloyalty.cloudapp.net
    InstanceName : (Default)
    AuthType : SQL Authentication
    ConnectingAsUser : myuser
    ConnectSuccess : True
    SqlServerVersion : 10.50.2550
    AddlConnectInfo : N/A
    RemoteServer : True
    IPAddress : {MyIp}
    NetBIOSname : Unknown
    RemotingAccessible : False
    Pingable : False
    DefaultSQLPortOpen : True
    RemotingPortOpen : False

    But if I run

    $username = “myuser”
    $password = cat C:\securestring.txt | convertto-securestring
    $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
    Start-SqlMigration -Verbose -Source mysource.cloudapp.net -Destination mydestcloudapp.net -SourceSqlCredential $cred -ReuseFolderstructure -DestinationSqlCredential $cred -Force -NetworkShare \\myshare.file.core.windows.net\data001 -BackupRestore

    I get a connection error in both ends (credentials are the same in each server), this is the error:
    Start-SqlMigration : Credential migration reported the following error Can’t connect to mysource.cloudapp.net:
    System.Data.SqlClient.SqlException (0x80131904): Login failed. The login is from an untrusted domain and cannot be
    used with Windows authentication.

    The servers are azure virtual machines in different domains, but I’m using a file share.

    What I’m doing wrong here?

    Thank you!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

*