Ron, I like your script a lot, and tried to adjust it for SQL server backup., I load [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") and then try the following:
# Declare SQL objects with strongly typed variables
[Microsoft.SqlServer.SMO.Server]$SQLserver = New-Object ([Microsoft.SqlServer.SMO.Server])
# Connect to SQL Server with specified instance
$SQLserver.Connect($Servername)
but am getting a error:
Unable to find type [Microsoft.SqlServer.SMO.Server]:
or if I try to load just LoadWithPartialName("Microsoft.SqlServer"] that errors out too.
I attach my script here as SQLCMD_v4.ps1.txt