locked
Running the MS Data Migration Assistant in Powershell RRS feed

  • Question

  • Hello,

    I am attempting to run the Microsoft Data Migration Assistant in Powershell. The main site for running DMA from the command prompt is here (this page contains the parameters, but does not express how to run in Powershell): https://blogs.msdn.microsoft.com/datamigration/2016/11/08/data-migration-assistant-how-to-run-from-command-line/

    In Powershell, I am trying to run DmaCmd.exe as follows:

    $CMD = "C:\Program Files\Microsoft Data Migration Assistant\DmaCmd.exe"
    $arg1 = "TestAssessment"
    $arg2 = "Server=MyServer;Initial Catalog=Test_Database;Integrated Security=true"
    $arg3 = "AzureSqlDatabaseV12"
    $arg4 = "AssessmentEvaluateCompatibilityIssues"
    $arg5 = "AssessmentEvaluateFeatureParity"
    $arg6 = "AssessmentOverwriteResult"
    $arg7 = "C:\Output Folder\AssessmentTest1CmdJson.json"
    & $CMD $arg1 $arg2 $arg3 $arg4 $arg5 $arg6 $arg7

    When run this, I receive an error message back that $arg1 (which the error identifies as Assesmentname) is invalid, and that only non-empty values are allowed.

    So I guess that I'm not doing the assignment of the parameters correctly. What am I doing wrong?

    Thank you for your help.

    Wednesday, July 12, 2017 5:55 PM

All replies

  • Start-Process $cmd-ArgumentList $arg1,$arg2,$arg3,$arg4,$arg5,$arg6,$arg7

    Your args make no sense.  Go back and read the article carefully to see how to use the arguments.


    \_(ツ)_/

    Wednesday, July 12, 2017 6:15 PM
  • Here is a full example using the blog parameters.

    $arglist = @(
    	'/AssessmentName=TestAssessment',
    	'/AssessmentDatabases="Server=MyServer;Initial Catalog=Test_Database;Integrated Security=true"',
    	'/AzureSqlDatabaseV12',
    	'/AssessmentEvaluateCompatibilityIssues',
    	'/AssessmentEvaluateFeatureParity',
    	'/AssessmentOverwriteResult',
    	'/AssessmentResultJson="C:\Output Folder\AssessmentTest1CmdJson.json"'
    )
    Start-Process -FilePath 'C:\Program Files\Microsoft Data Migration Assistant\DmaCmd.exe' -ArgumentList $arglist


    \_(ツ)_/

    Wednesday, July 12, 2017 6:20 PM
  • Here is a full example using the blog parameters.

    $arglist = @(
    	'/AssessmentName=TestAssessment',
    	'/AssessmentDatabases="Server=MyServer;Initial Catalog=Test_Database;Integrated Security=true"',
    	'/AzureSqlDatabaseV12',
    	'/AssessmentEvaluateCompatibilityIssues',
    	'/AssessmentEvaluateFeatureParity',
    	'/AssessmentOverwriteResult',
    	'/AssessmentResultJson="C:\Output Folder\AssessmentTest1CmdJson.json"'
    )
    Start-Process -FilePath 'C:\Program Files\Microsoft Data Migration Assistant\DmaCmd.exe' -ArgumentList $arglist


    \_(ツ)_/

    Thanks for providing this. I tried this both in Powershell and Powershell ISE, and the process did not produce an output file. In Powershell ISE, a cmd window opened long enough for the process to run, then quickly closed so that I could not see the error(s). One think I noticed is that there is no label provided for the third parameter, so I added that. It still didn't fully execute.
    Wednesday, July 12, 2017 7:03 PM
  • Here is a full example using the blog parameters.

    $arglist = @(
    	'/AssessmentName=TestAssessment',
    	'/AssessmentDatabases="Server=MyServer;Initial Catalog=Test_Database;Integrated Security=true"',
    	'/AzureSqlDatabaseV12',
    	'/AssessmentEvaluateCompatibilityIssues',
    	'/AssessmentEvaluateFeatureParity',
    	'/AssessmentOverwriteResult',
    	'/AssessmentResultJson="C:\Output Folder\AssessmentTest1CmdJson.json"'
    )
    Start-Process -FilePath 'C:\Program Files\Microsoft Data Migration Assistant\DmaCmd.exe' -ArgumentList $arglist


    \_(ツ)_/

    Thanks for providing this. I tried this both in Powershell and Powershell ISE, and the process did not produce an output file. In Powershell ISE, a cmd window opened long enough for the process to run, then quickly closed so that I could not see the error(s). One think I noticed is that there is no label provided for the third parameter, so I added that. It still didn't fully execute.

    That is, the parameter name for the third parameter is AssessmentTargetPlatform.

    Wednesday, July 12, 2017 7:04 PM
  • Add "-NoNewWindow" to the CmdLet.


    \_(ツ)_/

    Wednesday, July 12, 2017 7:08 PM
  • Thanks. I tried this, and the process still does not create an output file, and there are no error messages / log to look at.
    Wednesday, July 12, 2017 7:22 PM
  • Where did you add this?


    \_(ツ)_/

    Wednesday, July 12, 2017 7:42 PM
  • Where did you add this?


    \_(ツ)_/

    I added this at the end. The following is my full, 'production' script:

    $arglist = @(
    '/AssessmentName=TestAssessment',
    '/AssessmentDatabases="Server=CDUNNPC1\MSSQLSERVER14;Initial Catalog=Optum_DataMart;Integrated Security=true"',
    '/AssessmentTargetPlatform=AzureSqlDatabaseV12',
    '/AssessmentEvaluateCompatibilityIssues',
    '/AssessmentEvaluateFeatureParity',
    '/AssessmentOverwriteResult',
    '/AssessmentResultJson="C:\Clients\Provisions_Group\NFIB\Azure_Migration\DMA\Testing\AssessmentTest1CmdJson.json"'
    )
    Start-Process -FilePath 'C:\Program Files\Microsoft Data Migration Assistant\DmaCmd.exe' -ArgumentList $arglist -NoNewWindow

    Wednesday, July 12, 2017 7:50 PM
  • And you say there is no output.  No errors.  Nothing.  Impossible except if it is running.  What is in the Json file?

    Before you attempt to automate this I recommend that you learn to use the command by just typing it at a command prompt.  Until you understand how it works you will just be constantly guessing and we cannot reproduce your environment.


    \_(ツ)_/

    Wednesday, July 12, 2017 7:54 PM
  • And you say there is no output.  No errors.  Nothing.  Impossible except if it is running.  What is in the Json file?

    Before you attempt to automate this I recommend that you learn to use the command by just typing it at a command prompt.  Until you understand how it works you will just be constantly guessing and we cannot reproduce your environment.


    \_(ツ)_/

    The .json file I expect in the output (the AssesmentResultJson parameter) is named AssessmentTest1CmdJson.json. Is there a way to capture the output that appears when I run the script?
    Wednesday, July 12, 2017 8:03 PM
  • Hello,

    I'm new to Powershell, so please bear with me. I have a script that, when it runs, a CMD window with output opens for a moment, then closes. The output in this CMD window reveals errors in the script. I can't see what those errors are before the CMD window closes.

    Is there something I can add to my current script that will allow me to capture the contents of the CMD window to a file, or will allow the CMD to remain open until I manually close it?

    Thank you for your help.

    • Merged by jrv Thursday, July 13, 2017 8:37 PM DUPLICATE
    Thursday, July 13, 2017 7:40 PM
  • Without knowing what is in your script it is not possible to know what is happening.

    If you didn't write this script I suggest that you should contact the author for help.


    \_(ツ)_/

    Thursday, July 13, 2017 7:58 PM
  • Without knowing what is in your script it is not possible to know what is happening.

    If you didn't write this script I suggest that you should contact the author for help.


    \_(ツ)_/

    Here is the script:

    $arglist = @(
    '/AssessmentName=TestAssessment', 
    '/AssessmentDatabases="Server=CDUNNPC1\MSSQLSERVER14;Initial Catalog=Optum_DataMart;Integrated Security=true"', 
    '/AssessmentTargetPlatform=AzureSqlDatabaseV12', 
    '/AssessmentEvaluateFeatureParity',
    '/AssessmentEvaluateCompatibilityIssues', 
    '/AssessmentOverwriteResult',
    '/AssessmentResultJson="C:\Clients\Provisions_Group\NFIB\Azure_Migration\DMA\Testing\Optum_DataMart_CMD_Output.json"'
    )
    Start-Process -FilePath 'C:\Program Files\Microsoft Data Migration Assistant\DmaCmd.exe' -ArgumentList $arglist

    Thursday, July 13, 2017 8:01 PM
  • You have to use ?NoNewWindow" to see the error messages.  As I noted before you need to make this work first by typing the command at a CMD.EXE prompt until you get to know how to set the parameters.  Once you understand how the utility works you can then automate it with PowerShell.

    The command will run in the background so it will not produce any output when it works correctly.


    \_(ツ)_/

    Thursday, July 13, 2017 8:33 PM
  • You have to use ?NoNewWindow" to see the error messages.  As I noted before you need to make this work first by typing the command at a CMD.EXE prompt until you get to know how to set the parameters.  Once you understand how the utility works you can then automate it with PowerShell.

    The command will run in the background so it will not produce any output when it works correctly.


    \_(ツ)_/

    Okay, thanks.
    Thursday, July 13, 2017 9:06 PM
  • If there is an exception it will display on screen.  The command line utility has some bugs as it will fail on some versions of SQLServer and yet the GUI works.  Post to the blog of the creators for this kind of issue.  The command line is correct and I have run it successfully.  Read the information posted to the screen carefully.


    \_(ツ)_/

    Thursday, July 13, 2017 9:15 PM
  • I was able to finally get this to work via the 64 bit command prompt:

    DmaCmd.exe /AssessmentName="TestAssessment"  /AssessmentDatabases="Server=CDUNNPC1\MSSQLSERVER14;Initial Catalog=AdventureWorksDW2014;Integrated Security=true" 

    /AssessmentTargetPlatform="AzureSqlDatabaseV12" /AssessmentEvaluateCompatibilityIssues /AssessmentEvaluateFeatureParity /AssessmentOverwriteResult  /AssessmentResultJson="C:\Clients

    \Provisions_Group\NFIB\Azure_Migration\DMA\Testing\AdventureWorks_Output_07132017b.json"

    --**************

    I had to change the database from 'Optum_Datamart' to AdventureWorksDW2014. I tried to run the script via command prompt against 'Optum_Datamart' and I received an error message stating that the metadata could not be read.

    After successfully running the script against AdventureWorksDW2014, I tried it with my Powershell script, and the script failed on an error.

    BTW, the machine I am running Powershell on is Windows 7 Pro 64 bit. 

    Thanks again.

    Thursday, July 13, 2017 9:40 PM
  • You must be running PowerShell 64 bit for this to work correctly.

    \_(ツ)_/

    Thursday, July 13, 2017 9:44 PM
  • Hi cdun2

    Just checking in to see if the information provided was helpful.

    Please let us know if you would like further assistance.

    Best Regards,

    Candy


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, August 21, 2017 8:41 AM