Script Download: CheckSQLServerFragmentation.ziphttp://gallery.technet.microsoft.com/scriptcenter/Check-SQL-Server-average-f96a1088
By default, we can use New-OSCSqlConnection to create a SqlConnection and then use Get-OSCFragmentationInfo to get fragmented tables. Also, you can use Windows Authentication or SQL Server Authentication to connect your SQL Server. If you want to use SQL Server Authentication, just need to uncomment some code in this script.
You can find more All-In-One Script Framework script samples at http://aka.ms/onescriptingallery