Need a PowerShell Script to determine if the current box is running Server 2008 or 2012 and run a specific function based on result


I have two scripts to perform the same function. One runs smoothly on Server 2008 R2, the other smoothly on 2012 R2. I want to have the script first check to see which OS is running and perform either the 2008 tasks, or the 2012 tasks.

I've spun my wheels on trying to get this to work. Any help? :D

This was as far as I got and this didn't work.

Try it like this:

Try it like this:

Thanks for your help! That did the trick. Very good to know about "contains!"

Share this

Related Posts