Sometimes you have a need to capture the informational messages generated in sql server, for example sp_help_revlogin only prints the user information to the messages tab.
Import-Module SqlServer -DisableNameChecking
cls
try {

Code more for me than you. Backup a database and restore it to an availability group (picks the AG that has the least number of databases). If the server isn’t clustered or doesn’t have HADR enabled, just restores it. Not thoroughly tested.