Collecting VLF information on all versions of SQL server
The first problem goes away if you solve the second with a Signed Stored Procedure installed in Master.  If there are any version differences required, you can have different versions of the procedure for different SQL Server versions.
Then the script is a just a call to the procedure.
exec sp_GatherVLFStats