• Your script will also fail on any named instances. The -S parameter is the SQL Server instance and you need to specify the correct instance name.

    For clusters, you don't have a LOCALHOST - you need to specify the SQL VIP of the clustered SQL instance. That SQL VIP will be whatever name was defined in the cluster.

    You can find the instance name in the variable @@SERVERNAME. Modify your script to build the -S parameter using this variable and it should work.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs