hi,
what about this solution:
Query you CMS for the instance names.
Paste the result into a text-file
Make a batch file using the text-file as input for a for %%a in textfile do sqlcmd.exe -S%%a ...
and run sqlcmd with sql script containing the login changes.
you can also log the output into an extra file.
And for sure you could also use powershell to do this.
BR
Gerald