When working with Powershell and Active Directory dependent software like Microsoft Exchange, or Microsoft Lync and others, you can sometimes get inconsistent result. If your running multiple commands after each other, which depends on the previous command it sometimes fails. There is a simple solution to solve this problem.
Recently I’ve been working with Lync and problems with desktop/application sharing for a customer of my. After a lot of troubleshooting, we found together with Microsoft, that Citrix Edgesight is the cause or trigger of this problem.