I got the code below from the following website:
https://web.archive.org/web/20180204011318/http://michaelhalpin.azurewebsites.net:80/use-powershell-to-get-numbers-of-sli