Powershell compare script

shaarmarshaarmar Posts: 3
edited June 29, 2017 4:00PM in SQL Compare
I seem to be having issues with a powershell script I modified. I just want it to compare the path of scripts to a target source so it generates a script. this is what I have so far:
$SQLCompare="${env:ProgramFiles(x86)}\Red Gate\SQL Compare 11\sqlcompare.exe"# full path
$MyServerInstance='NAME OF SERVER' #The SQL Server instance
$EmptyPath ="/empty2"
$MyScriptsPath =
"PATH TO SCRIPTS"

$AllArgs = @("/server1:$MyServerInstance", "/Scripts1:$MyScriptsPath ",
"/empty2:$EmptyPath")
&$SQLCompare $AllArgs
if ($?) {'updated successfully'}
else {if ($LASTEXITCODE=63) {'Database and scripts were identical'}
else {"we had an error! (code $LASTEXITCODE)"}}

I'm getting "database and scripts were identical" after every build.
Tagged:

Comments

  • Mark JMark J Posts: 125 Bronze 5
    edited June 30, 2017 11:32AM
    I think the problem is around the if ($LASTEXITCODE=63) line - this is actually assigning 63 to the $LASTEXITCODE variable. You probably want to say if ($LASTEXITCODE -eq 63) instead.
Sign In or Register to comment.