Has anyone had any success with removing a file if it is present before trying to install an application with the tool? If so how did you proceed?
Thanks
Thanks
Function Get-MSIProperty {
<#
.SYNOPSIS
Retrieves the value of a property defined in target MSI file Property Table
.DESCRIPTION
Specify the full path to the MSI and the property name that stores the value to retrieve. Function will return the value if property is found in the MSI.
.EXAMPLE
Get-MSIProperty "C:\windows\installer\abc123.msi" "ProductCode"
Returns the ProductCode value from abc123.msi file.
.EXAMPLE
$MyProductCode = Get-MSIProperty "C:\windows\installer\abc123.msi" "ProductCode"
Returns the ProductCode value from abc123.msi file and then stores it in $MyProductCode variable.
.PARAMETER MSIFileName
The full path to the target MSI file.
.PARAMETER MSIPropertyName
The name of the property to retrieve.
.NOTES
.LINK
Http://psappdeploytoolkit.codeplex.com
#>
Param(
[Parameter(Mandatory = $true)]
[string] $MSIFileName,
[string] $MSIPropertyName
)
$WindowsInstaller = New-Object -com WindowsInstaller.Installer
$Database = $WindowsInstaller.GetType().InvokeMember(“OpenDatabase”, “InvokeMethod”, $Null, $WindowsInstaller, @($MSIFileName,0))
$View = $Database.GetType().InvokeMember(“OpenView”, “InvokeMethod”, $Null, $Database, (“SELECT * FROM Property”))
$View.GetType().InvokeMember(“Execute”, “InvokeMethod”, $Null, $View, $Null) | Out-Null
$Record = $View.GetType().InvokeMember(“Fetch”, “InvokeMethod”, $Null, $View, $Null)
while($Record -ne $Null)
{
$PropertyName = $Record.GetType().InvokeMember(“StringData”, “GetProperty”, $Null, $Record, 1)
if ($PropertyName -eq $MSIPropertyName)
{
$PropertyValue = $Record.GetType().InvokeMember(“StringData”, “GetProperty”, $Null, $Record, 2)
$PropertyValue
}
$Record = $View.GetType().InvokeMember(“Fetch”, “InvokeMethod”, $Null, $View, $Null)
}
$View.GetType().InvokeMember(“Close”, “InvokeMethod”, $Null, $View, $Null) | Out-Null
}
#*===============================================
#* INSTALLATION
$installPhase = "Installation"
#*===============================================
# Install the updated Cisco AnyConnect VPN client
Execute-MSI -Action Install -Path "anyconnect-win-3.1.05170-pre-deploy-k9.msi" -Transform "anyconnect-win-3.1.05170-pre-deploy-k9.mst" -Parameters "/QN /norestart"
:: version 0.9
@echo off
setlocal
:: *** Please configure these variables ***
set SOURCE=0
set LOCKDOWN=1
set HIDE_UNINSTALL=1
set LOG_PATH=%TEMP%
set LOG_NAME_PREFIX=%COMPUTERNAME%
set DELAY=0
set DELAY_TIMER=10
set UPGRADE_REBOOT_SUPPRESS=1
set FORCE_SERVICE_PROFILE=0
set SILENT=0
set VPN_DISABLE=0
set ENABLE_DETECT_LAPTOP=0
set TEST_MODE=0
:: *** Do NOT change these last two variables! ***
set DESTINATION=%ALLUSERSPROFILE%\Application Data\Cisco\Cisco AnyConnect Secure Mobility Client
set UPGRADE_TRUE=0
if %SOURCE% == 0 goto :setsource
:sourcelocal
for /f "delims=" %%a in ('dir /B "%SOURCE%\anyconnect-websecurity-win-*"') do @set VERSION=%%a
set VERSION=%VERSION:~27,9%
set VERSION=%VERSION:-=%
if %TEST_MODE%==1 (
echo. *** Test Mode Enabled ***
echo.
echo. Source path=%SOURCE%
echo. Log path=%LOG_PATH%
echo. Log name prefix=%LOG_NAME_PREFIX%
echo. Source version=%VERSION%
if %LOCKDOWN%==1 echo. Lockdown mode enabled
if %HIDE_UNINSTALL%==1 echo. Hide Uninstall mode enabled
if %VPN_DISABLE%==0 echo. VPN client enabled
if %ENABLE_DETECT_LAPTOP%==1 echo. Detect laptop enabled
)
if %ENABLE_DETECT_LAPTOP% == 1 (
"%SOURCE%\DetectLaptop.vbs"
if NOT EXIST "%temp%\GetIsLaptop.txt" goto :eof
del "%temp%\GetIsLaptop.txt"
)
if exist "%DESTINATION%\update.txt" (
goto :upgrade
) else (
if NOT exist "%DESTINATION%\Web Security\" md "%DESTINATION%\Web Security\"
)
:install
if %DELAY% LSS 1 goto :continue
set /A COUNTER=%DELAY_TIMER% + 1
if %TEST_MODE%==1 (
echo. Delay enabled=%DELAY_TIMER% seconds
) else (
ping 127.0.0.1 -n %COUNTER% -w 1000 > NUL
)
:continue
set DISPLAY=/passive
if %SILENT%==1 (
if %TEST_MODE%==1 echo. Silent mode enabled
set DISPLAY=/quiet
)
)
set RESTART=/norestart
if %UPGRADE_TRUE%==1 (
if %UPGRADE_REBOOT_SUPPRESS%==0 (
set RESTART=/forcerestart
if %TEST_MODE%==1 echo. Upgrade reboot enabled
)
)
if %TEST_MODE%==0 (
if NOT exist "%DESTINATION%\Web Security\WebSecurity_ServiceProfile.wso" copy "%SOURCE%\Profiles\websecurity\WebSecurity_ServiceProfile.wso" "%DESTINATION%\Web Security\WebSecurity_ServiceProfile.wso" /Y
)
if %TEST_MODE%==1 (
echo. Installing AnyConnect...
) else (
msiexec /package "%SOURCE%\anyconnect-win-%VERSION%-pre-deploy-k9.msi" /norestart %DISPLAY% LOCKDOWN=%LOCKDOWN% ARPSYSTEMCOMPONENT=%HIDE_UNINSTALL% PRE_DEPLOY_DISABLE_VPN=%VPN_DISABLE% /lvx* "%LOG_PATH%\%LOG_NAME_PREFIX%_AnyConnectInstall_BASE.log"
msiexec /package "%SOURCE%\anyconnect-websecurity-win-%VERSION%-pre-deploy-k9.msi" /norestart %DISPLAY% LOCKDOWN=%LOCKDOWN% ARPSYSTEMCOMPONENT=%HIDE_UNINSTALL% /lvx* "%LOG_PATH%\%LOG_NAME_PREFIX%_AnyConnectInstall_WS.log"
msiexec /package "%SOURCE%\anyconnect-dart-win-%VERSION%-k9.msi" %RESTART% %DISPLAY% ARPSYSTEMCOMPONENT=%HIDE_UNINSTALL% /lvx* "%LOG_PATH%\%LOG_NAME_PREFIX%_AnyConnectInstall_DART.log"
)
goto :eof
:upgrade
for /f "delims=" %%a in ('findstr"," "%DESTINATION%\update.txt"') do @set CURVER=%%a
set CURVER=%CURVER:,=.%
if %TEST_MODE%==1 echo. Local version=%CURVER%
for /f "tokens=1,2,3 delims=. " %%a in ("%VERSION%") do set MGRVER=%%a&set MNRVER=%%b&set BLDNUM=%%c
for /f "tokens=1,2,3 delims=. " %%a in ("%CURVER%") do set LMGRVER=%%a&set LMNRVER=%%b&set LBLDNUM=%%c
set TEMPBLDNUM=%BLDNUM:~0,1%
set TEMPLBLDNUM=%LBLDNUM:~0,1%
if %TEMPBLDNUM%==0 (
set BLDNUM=%BLDNUM:~1,4%
)
if %TEMPLBLDNUM%==0 (
set LBLDNUM=%LBLDNUM:~1,4%
) else (
set LBLDNUM=%LBLDNUM:-=%
)
if /i %LMGRVER% LSS %MGRVER% goto :doupgrade
if /i %LMNRVER% LSS %MNRVER% goto :doupgrade
if /i %LBLDNUM% LSS %BLDNUM% goto :doupgrade
goto :eof
:doupgrade
if %TEST_MODE%==1 (
if %FORCE_SERVICE_PROFILE%==1 echo. Local service profile will be replaced with source version
if %UPGRADE_REBOOT_SUPPRESS%==1 echo. Upgrade reboot suppressed
echo. Perform upgrade
)
set UPGRADE_TRUE=1
if %TEST_MODE%==0 (
if %FORCE_SERVICE_PROFILE% EQU 1 copy "%SOURCE%\Profiles\websecurity\WebSecurity_ServiceProfile.wso" "%DESTINATION%\Web Security\WebSecurity_ServiceProfile.wso" /Y
)
goto :install
:setsource
set SOURCE=%~dp0
set SOURCE=%SOURCE:~0,-1%
goto :sourcelocal
:eof
endlocal
I know I could have transferred most of the .cmd script into the toolkit, but as we didnt have any problems using the .cmd script I decided to leave it as was. So the toolkit just calls it with this command: Execute-Process -FilePath "AnyConnectInstallationScript.cmd" -WindowStyle Hidden
[13-10-2014 16:03:29] [Initialization] _VPNSoftwareUpgrade_3.1.04072__ setup started.
[13-10-2014 16:03:29] [Initialization] Script [\\.......\SMSPKGE$\UK100124\DeploymentToolkit\AppDeployToolkit\AppDeployToolkitExtensions.ps1] dot-source invoked by [\\........\SMSPKGE$\UK100124\DeploymentToolkit\AppDeployToolkit\AppDeployToolkitMain.ps1]
[13-10-2014 16:03:29] [Initialization] _VPNSoftwareUpgrade_3.1.04072__ script version is [1.1.0]
[13-10-2014 16:03:29] [Initialization] Deploy Application script version is [3.1.4]
[13-10-2014 16:03:29] [Initialization] App Deploy Toolkit Main script version is [3.2.0]
[13-10-2014 16:03:29] [Initialization] App Deploy Toolkit Extensions version is [1.0.0]
[13-10-2014 16:03:29] [Initialization] PowerShell version is [2.0 x86]
[13-10-2014 16:03:29] [Initialization] PowerShell host is [ConsoleHost version 2.0]
[13-10-2014 16:03:29] [Initialization] OS version is [Microsoft Windows 7 Enterprise 32-bit 6.1.7601]
[13-10-2014 16:03:29] [Initialization] Hardware platform is [Physical]
[13-10-2014 16:03:29] [Initialization] Computer name is [UKLP0517]
[13-10-2014 16:03:29] [Initialization] Current user is [SXSUK\UKLP0517$]
[13-10-2014 16:03:29] [Initialization] Current Culture is [en-GB] and UI language is [EN]
[13-10-2014 16:03:29] [Initialization] Deployment type is [Installation]
[13-10-2014 16:03:29] [Initialization] Script [\\......\SMSPKGE$\UK100124\DeploymentToolkit\AppDeployToolkit\AppDeployToolkitMain.ps1] dot-source invoked by [\\........\SMSPKGE$\UK100124\DeploymentToolkit\Deploy-Application.ps1]
[13-10-2014 16:03:29] [Initialization] The following users are logged on to the system: SXSUK\kiran
[13-10-2014 16:03:30] [Initialization] Session 0 not detected.
[13-10-2014 16:03:30] [Initialization] Installation is running in [Interactive] mode.
[13-10-2014 16:03:30] [Pre-Installation] Getting information for installed Application Name [Cisco AnyConnect Secure Mobility Client ]...
[13-10-2014 16:03:30] [Pre-Installation] Found installed application [Cisco AnyConnect Secure Mobility Client ] version [3.0.08057] matching application name [Cisco AnyConnect Secure Mobility Client ]
[13-10-2014 16:03:32] [Pre-Installation] Displaying custom installation prompt with the non-default parameters: [(Title=VPN Software Upgrade) (Message=Your VPN software needs to be upgraded.
Please save all work and close any open applications as the laptop will restart on completion.
If it is not convenient to upgrade at this time, you may defer the installation at the next screen.
Click the OK button to proceed to next screen) (ButtonMiddleText=OK)]...
[13-10-2014 16:09:10] [Pre-Installation] Evaluating disk space requirements...
[13-10-2014 16:09:10] [Pre-Installation] Disk space requirements are met.
[13-10-2014 16:09:10] [Pre-Installation] Getting deferral history...
[13-10-2014 16:09:10] [Pre-Installation] Getting Registry key [Registry::\HKEY_LOCAL_MACHINE\SOFTWARE\PSAppDeployToolkit\DeferHistory\_SpiraxSarcoVPNSoftwareUpgrade_3.1.04072__] ...
[13-10-2014 16:09:10] [Pre-Installation] Registry key does not exist: [Registry::\HKEY_LOCAL_MACHINE\SOFTWARE\PSAppDeployToolkit\DeferHistory\_SpiraxSarcoVPNSoftwareUpgrade_3.1.04072__]
[13-10-2014 16:09:10] [Pre-Installation] User now has [4] deferrals remaining.
[13-10-2014 16:09:10] [Pre-Installation] Checking for running applications [iexplore,outlook.exe,winword.exe]...
[13-10-2014 16:09:10] [Pre-Installation] The following processes are running: []
[13-10-2014 16:09:10] [Pre-Installation] Resolving process descriptions...
[13-10-2014 16:09:10] [Pre-Installation] Finished checking running applications.
[13-10-2014 16:09:10] [Pre-Installation] Prompting user to close application(s) [Internet Explorer]...
[13-10-2014 16:09:10] [Pre-Installation] User has the option to defer.
[13-10-2014 16:09:15] [Pre-Installation] User selected to continue...
[13-10-2014 16:09:17] [Pre-Installation] Checking for running applications [iexplore,outlook.exe,winword.exe]...
[13-10-2014 16:09:17] [Pre-Installation] The following processes are running: []
[13-10-2014 16:09:17] [Pre-Installation] Resolving process descriptions...
[13-10-2014 16:09:17] [Pre-Installation] Finished checking running applications.
[13-10-2014 16:09:17] [Pre-Installation] Prompting user to close application(s) [Internet Explorer]...
[13-10-2014 16:09:17] [Pre-Installation] User has the option to defer.
[13-10-2014 16:09:24] [Pre-Installation] User selected to continue...
[13-10-2014 16:09:26] [Pre-Installation] Checking for running applications [iexplore,outlook.exe,winword.exe]...
[13-10-2014 16:09:26] [Pre-Installation] Applications are not running.
[13-10-2014 16:09:26] [Pre-Installation] Finished checking running applications.
[13-10-2014 16:09:26] [Pre-Installation] User has the option to defer.
[13-10-2014 16:09:31] [Pre-Installation] User selected to continue...
[13-10-2014 16:09:33] [Pre-Installation] Spinning up Progress Dialog in a separate thread with message: [Installation in progress. Please wait...]
[13-10-2014 16:09:34] [Installation] Working Directory is [\\....\SMSPKGE$\UK100124\DeploymentToolkit\Files]
[13-10-2014 16:09:34] [Installation] Executing [\\.....\SMSPKGE$\UK100124\DeploymentToolkit\Files\AnyConnectInstallationScript.cmd ]...
[13-10-2014 16:09:34] [Installation] Standard error output from the process []: '\\....\SMSPKGE$\UK100124\DeploymentToolkit\Files'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
'findstr' is not recognized as an internal or external command,
operable program or batch file.
1==0 was unexpected at this time.
[13-10-2014 16:09:34] [Installation] Execution failed with exit code [255]
[13-10-2014 16:09:34] [Installation] _VPNSoftwareUpgrade_3.1.04072__ Installation completed with exit code [255].
[13-10-2014 16:09:34] [Installation] ----------------------------------------------------------------------------------------------------------
Yes it works fine everytime running Deploy-Application.exe locally with an admin account.[13-10-2014 16:09:34] [Installation] Executing [\\.....\SMSPKGE$\UK100124\DeploymentToolkit\Files\AnyConnectInstallationScript.cmd ]...
[13-10-2014 16:09:34] [Installation] Standard error output from the process []: '\\....\SMSPKGE$\UK100124\DeploymentToolkit\Files'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
'findstr' is not recognized as an internal or external command,
Reason I ask is, you can see that CMD.EXE starts in the UNC location above but shortly after it informs you that UNC paths are not supported it defaults to Windows directory and that is when it craps out. Perhaps you can modify the PKG to download content locally to the workstation and then run.Remove-MSIApplications "Application"
Remove-RegistryKey -Key 'HKCU:\Software\App' -Recurse
Remove-RegistryKey -Key 'HKLM:\Software\App' -Recurse
Remove-RegistryKey -Key 'HKLM:\Software\Wow6432Node\App' -Recurse