Prereq check Powershell 3.0 OR 4.0 installed

Hi,

As a prereq for App-V 5.0 SP3, I have Powershell 3.0 as a prereq. However, if Powershell version 4.0 is installed, it should also consider the prereq as ok.

This vbscript which checks if Powershell version 3 is installed but would like to add the detection if version 4 is installed.
Powershell instead of vbscript  would be also ok.

Please advise.
J.

'Returns info if Windows Management Framework 3 in installed
' ----------------------------------------------------------'
Option Explicit

Dim objWMIService, strComputer
strComputer = "."

'Run the query
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & strComputer & "\root\cimv2")
    
Dim QFEs
Dim QFE
Set QFEs = objWMIService.ExecQuery ("Select * from win32_QuickFixEngineering where HotFixID like 'KB2506143'")
For Each QFE in QFEs
    Wscript.echo "Update KB2506143 was installed by " & QFE.InstalledBy & " on " & QFE.InstalledOn
Next
WScrip

May 22nd, 2015 4:34am

Are you using the application model to install the App-V client? If so you can add the different PowerShell versions in one dependency group. Either one will be sufficient then.
Free Windows Admin Tool Kit Click here and download it now
May 22nd, 2015 5:14am

Yes, indeed. Thanks, that would be the goal but for now we don't have this 4.0 package and would like to make it work.

if ($psversiontable.psversion.Major -contains '4.0'){Return $True} is ok for version 4, but how to add an 4.0 OR 3.0 here?

May 22nd, 2015 5:16am

Do something like this:

if ($psversiontable.psversion.Major -eq 3 -or $psversiontable.psversion.Major -eq 4){Return $True} 

Free Windows Admin Tool Kit Click here and download it now
May 22nd, 2015 5:22am

Wouldn't this be a good solution for every version above 3.0?

if ($psversiontable.psversion.Major -ge '3.0') {Return $True}

May 22nd, 2015 5:24am

You could use Greater than or equal to.

If($PSVersionTable.PSVersion.Major -ge 3)

  • Marked as answer by janhoedt 22 hours 15 minutes ago
Free Windows Admin Tool Kit Click here and download it now
May 22nd, 2015 5:26am

You could use Greater than or equal to.

If($PSVersionTable.PSVersion.Major -ge 3)

  • Marked as answer by janhoedt Friday, May 22, 2015 9:31 AM
May 22nd, 2015 9:24am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics