There could be multiple issues here as I'm running into them as well running SQL Server 2014 Express.
1. What version of MSSQL are you running?
2. My version required a hotfix because performance counters were not working, you can look in your SQL server logs and look for performance counters errors or you can run the SQL query below on the server:
If that is empty you may be hitting the bug I was.
3. If it does have data in there then the version you may be using might not support those, here are the ones that don't work on my SQL Server 2014 Express edition:
MSSQL Deadlocks Per Sec
MSSQL Free Pages
MSSQL Lazy Writes Per Sec
MSSQL Lock Requests Per Sec
MSSQL Stolen Pages
What's happening is that the database is returning nothing and the script is failing because of that.