Script to run when you're on Citrix or Terminal Server but not on-premises (or vice versa)

Although it may seem a bit simple, I'm forced to have to post this, since many people have asked me for it and to put it here… How is it free… 😉 Well, is as simple as a script that will be executed at the login login of the users of our Active Directory, through policies or GPOs. There are many times that we want users to run a certain script when they're on Citrix but not when they're on-premises, or the other way around 😉 when they are in the local that they execute a certain script, but when they are in Citrix or Terminal Services they are not.