I'm new to powershell and not very proficient at scripting as it is, but eager to learn more; that being said I apologize in advance if I frustrate scripting veterans with my lack of knowledge on the topic.
I don't know how much more hair I can lose over trying to figure this out so hoping someone can give me some ideas or point me in the right direction.
Goal:
to create a powershell script (that is to be deployed via group policy) that solves the problem below
The Problem:
I have to (silently) install a newer version of an application (v. 0.2.2) and then copy an xml file to the C:\PF(x86)\ directory after the application is installed.
There may already be an older version (v. 0.2.1) of this application installed. If a version older than 0.2.2 is installed, it has to be uninstalled before the new version (0.2.2) gets installed.
If the system has the latest version installed 0.2.2 do nothing
There are both x86 and x64 systems in the environment of which some have the old version, some have the new version and some don't have any version installed.
In plain english again this is what i need to happen:
If an application named PowerAgent is installed and version >=0.2.2 do nothing
If an application named PowerAgent is installed and version <0.2.2 uninstall current version then
install PowerAgent.2.2.exe silently, then copy xml file to the PF(x86) directory
If an application named PowerAgent is not installed,
install PowerAgent.2.2.exe silently, then copy xml file to the PF(x86) directory
Additional Details:
I know it's not a powershell script but so far I know that this batch file does what I need it to do if I run it on a windows 7 x64 or x86 computer that currently has the older version (0.2.1) installed.
However, it does not do well if the application is not installed at all or if the new version is already installed (0.2.2)
______________
msiexec /qb /x {75F8D41E-A77D-C052-8B3C-C03407F26F49}
\\server\inContact\PowerAgent.2.2.exe -silent
copy /y "\\server\inContact\PowerAgentConfig.xml" "C:\Program Files (x86)\inContact\PowerAgent\assets"
quit
______________
More details that may help with identifying possibilities of accomplishing this more effectively via a powershell script:
Reg Key of old version (0.2.1) on Win7 x64:
______________
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\PowerAgent]
"DisplayIcon"="C:\\Program Files (x86)\\inContact\\PowerAgent\\PowerAgent.exe"
"DisplayName"="PowerAgent"
"DisplayVersion"="0.2.1"
"VersionMajor"="0"
"VersionMinor"="2"
"InstallLocation"="C:\\Program Files (x86)\\inContact\\PowerAgent\\"
"NoModify"=dword:00000001
"NoRepair"=dword:00000001
"Publisher"="InContact, Inc."
"UninstallString"="msiexec /qb /x {75F8D41E-A77D-C052-8B3C-C03407F26F49}"
______________
reg Key of old version (0.2.1) on Win7 x86:
______________
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\PowerAgent]
"DisplayIcon"="C:\\Program Files\\inContact\\PowerAgent\\PowerAgent.exe"
"DisplayName"="PowerAgent"
"DisplayVersion"="0.2.1"
"VersionMajor"="0"
"VersionMinor"="2"
"InstallLocation"="C:\\Program Files\\inContact\\PowerAgent\\"
"NoModify"=dword:00000001
"NoRepair"=dword:00000001
"Publisher"="InContact, Inc."
"UninstallString"="msiexec /qb /x {75F8D41E-A77D-C052-8B3C-C03407F26F49}"
______________
reg key of new version (0.2.2) on win 7X64
______________
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\PowerAgent]
"DisplayIcon"="C:\\Program Files (x86)\\inContact\\PowerAgent\\PowerAgent.exe"
"DisplayName"="PowerAgent"
"DisplayVersion"="0.2.2"
"VersionMajor"="0"
"VersionMinor"="2"
"InstallLocation"="C:\\Program Files (x86)\\inContact\\PowerAgent\\"
"NoModify"=dword:00000001
"NoRepair"=dword:00000001
"Publisher"="InContact, Inc."
"UninstallString"="msiexec /qb /x {EE5C8A18-CB4A-52BD-50AD-94EAC789FF52}"
______________
reg key of new version (0.2.2) on Win7 x86
______________
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\PowerAgent]
"DisplayIcon"="C:\\Program Files\\inContact\\PowerAgent\\PowerAgent.exe"
"DisplayName"="PowerAgent"
"DisplayVersion"="0.2.2"
"VersionMajor"="0"
"VersionMinor"="2"
"InstallLocation"="C:\\Program Files\\inContact\\PowerAgent\\"
"NoModify"=dword:00000001
"NoRepair"=dword:00000001
"Publisher"="InContact, Inc."
"UninstallString"="msiexec /qb /x {EE5C8A18-CB4A-52BD-50AD-94EAC789FF52}"
______________
any help would be greatly appreciated