alohadin
asked on
Convert (short) Powershell script to VBS
Hi,
I am not that bad in Powershell scripting, but I really suck in VBS.
I need a custom detection method in SCCM which checks for a version number in the registry and check if a file DOES NOT exist.
If version number = X AND file does not exist Echo Installed
The file and the registry keys might be in different places depending on OS bit.
Can someone help with converting this Powershell Script to VBS?
Reason why I don't use the Powershell script for the detection method is because it needs to be signed. I would rather work with a VBS.
I am not that bad in Powershell scripting, but I really suck in VBS.
I need a custom detection method in SCCM which checks for a version number in the registry and check if a file DOES NOT exist.
If version number = X AND file does not exist Echo Installed
The file and the registry keys might be in different places depending on OS bit.
Can someone help with converting this Powershell Script to VBS?
Reason why I don't use the Powershell script for the detection method is because it needs to be signed. I would rather work with a VBS.
[boolean]$Is64Bit = [boolean]((Get-WmiObject -Class 'Win32_Processor' -ErrorAction 'SilentlyContinue' | Where-Object { $_.DeviceID -eq 'CPU0' } | Select-Object -ExpandProperty 'AddressWidth') -eq 64)
If ($Is64Bit -eq $True)
{
[string]$appInstalledVersion = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Citrix\PluginPackages\XenAppSuite\ICA_Client' -ErrorAction SilentlyContinue | select -ExpandProperty Version
[boolean]$ssonsvr = Test-Path ("${env:ProgramFiles(x86)}\Citrix\ICA Client\ssonsvr.exe")
}
Elseif ($Is64Bit -ne $True)
{
[string]$appInstalledVersion = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Citrix\PluginPackages\XenAppSuite\ICA_Client' -ErrorAction SilentlyContinue | select -ExpandProperty Version
[boolean]$ssonsvr = Test-Path ("$env:ProgramFiles\Citrix\ICA Client\ssonsvr.exe")
}
if (($ssonsvr -eq $False) -and ($appInstalledVersion -eq "14.7.0.13011"))
{
Write-Host "installed"
}
else
{
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Took me all my time to remember that much VbScript. Nice work Bill, very tidy.
Sadly(?) I still spend too much time in VBScript, although I still like it as a scripting tool language. Just don't tell Qlemo :-).
»bp
»bp
ASKER
Thank you both very much.
Bill, that script does exactly what it should. Thank you so much. You have saved me one day!
Chris,
I know about the variable $env:PROCESSOR_ARCHITECTUR E but that line I use for a couple of years now.
Found it somewhere a long time ago when I just started with PS and I use it every time I need it.
Bill, that script does exactly what it should. Thank you so much. You have saved me one day!
Chris,
I know about the variable $env:PROCESSOR_ARCHITECTUR
Found it somewhere a long time ago when I just started with PS and I use it every time I need it.
Welcome, glad that was helpful...
»bp
»bp
ASKER
Hi Bill,
Forgot to mention...
There is a tiny mistake in the TestPath function.
Can you change it to this in your original post so others who stumble on this topic have correct answer:
You had this:
Function TestPath(strPath)
TestPath = objFSO.FileExists(strDataFile)
End Function
Forgot to mention...
There is a tiny mistake in the TestPath function.
Can you change it to this in your original post so others who stumble on this topic have correct answer:
Function TestPath(strPath)
TestPath = objFSO.FileExists(strPath)
End Function
You had this:
Function TestPath(strPath)
TestPath = objFSO.FileExists(strDataFile)
End Function
Done.
»bp
»bp
Open in new window
By the way, in PowerShell you can use the environment variable $env:PROCESSOR_ARCHITECTUROpen in new window