Quick Tip: Access to SQL Express Locally From Lync

This is a silly one, and you might not have run into it.  But, if you’ve ever built a PowerShell script that queries a local Lync 2013 database and tried to just double click it in the desktop it might fail on you with an error similar to mine:

Exception calling “ExecuteReader” with “0” argument(s): “The SELECT permission was denied on the object ‘Resource’,
database ‘rtc’, schema ‘dbo’.”
At C:\Users\cac-a\Desktop\MyQuery.ps1:19 char:1
+ $result = $command.ExecuteReader()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo         : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : SqlException
Exception calling “Load” with “1” argument(s): “Value cannot be null.Parameter name: dataReader”

The funny thing is, it works just fine from another server.  Solution? Run it as Administrator.