When trying to run SQL Compare as part of a PowerShell script, you receive the following error:
“Login failed. The login is from an untrusted domain and cannot be used with Windows authentication”
Sometimes the account can be locked out, or the password has changed or expired within SQL Server.
This can also be caused by a loopback check taking place which causes trusted connections via the loopback adapter to fail.
If the issue is not with the SQL Server login account or password mismatch, then the following registry change can be used to remove the check:
- Edit the registry using regedit. (Start > Run > Regedit)
- Navigate to: HKLM\System\CurrentControlSet\Control\LSA
- Add a DWORD value called “DisableLoopbackCheck”
- Set this value to 1
For additional information and an alternative using a Microsoft tool, please see the following article: