Better error handling when it comes to publishsettings files (Get-WDPublishSettings with a try/catch perhaps)