The script is available for download from https://gallery.technet.microsoft.com//How-to-attach-a-user-28a47521. You can also use Microsoft Script Browser for Windows PowerShell ISE to download the sample with one button click from within your scripting environment.
This PowerShell script will demonstrate how to attach a user database in SQL Server.
This script will demonstrate how to attach a user database in SQL Server. As some people asked how to do this in TechNet, it will be much more convenient if we provide a script for them.
You can find more All-In-One Script Framework script samples at https://aka.ms/onescriptingallery