Lync MVP Pat Richard has written the script over at ehloworld.com.
The script and all its previous version can be found
http://www.ehloworld.com/255To run the script you must have the PowerShell execution policy to RemoteSigned or Unrestricted
[Update] The Set-ExecutionPolicy command must be run from the Windows PowerShell that has been "Run As Administrator" otherwise the command will fail
Set-ExecutionPolicy -ExecutionPolicy {RemoteSigned | Unrestricted}