You never know when you’re going to have to plagiarize yourself.
Seriously, I just repurposed the “migrate databases to new drives” script to be a “migrate databases to a new server” script. Rather than starting from scratch, I changed a couple of lines on the existing script and it’s percolating away right now. (I got the list of databases from sys.databases, of course.