janikvonrotz
12/6/2013 - 1:12 PM

PowerShell: Check Compatibilty #PowerShell

PowerShell: Check Compatibilty #PowerShell

# Check for executeable
if ((Get-Command "cmdkey.exe") -and (Get-Command "mstsc.exe"))  { }

# Execute with Powershell version 2 instead of version 3 and higher
if($Host.Version.Major -gt 2){
  powershell -Version 2 $MyInvocation.MyCommand.Definition
	exit
}

# only powershell 2 and higher
if($Host.Version.Major -lt 2){
    throw "Only compatible with Powershell version 2 and higher"
}else{
}