How can we help you today? How can we help you today?

Powershell compare script

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.
Omar Shaarawi
0

Comments

1 comment

  • Mark J
    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.
    Mark J
    0

Add comment

Please sign in to leave a comment.