findstr causing script failure

Topics: Archive - General
Oct 9, 2014 at 12:50 PM
Hi All,

I am currently deploying a Cisco Anyconnect upgrade using the toolkit via SCCM 2007. It works well for the majority of installations but around 10% are failing returning error code 255 to SCCM.

The toolkit calls a .cmd supplied by Cisco that references findstr and returns the following error to the toolkit log file:

"'findstr' is not recognized as an internal or external command,
operable program or batch file.
1==0 was unexpected at this time."

First of all I checked that C:\windows\system32 is in the Env Variables path on the laptop, and it is already.

I then ran the toolkit from the laptop running as my admin user, without using SCCM . The toolkit runs fine and upgrade succeeds. So its only when I use the toolkit via SCCM that the failures occur.

I am using version 3.2.0.

Any suggestions please ?

Thanks.
Oct 10, 2014 at 4:39 PM
Hasi,

Are you deploying the updated AnyConnect client as an MSI? Have you checked the logs on C:\Windows\Logs\Software\"APP Name"? I have deployed an updated AnyConnect client to my workstations, using an MSI and Transform and have not experienced this issue.

This is my Installation code - pretty simple and straight forward.
#*===============================================
#* 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"   
Oct 13, 2014 at 12:19 PM
Hi,

Yes the error I posted is from that log file.

The .cmd script supplied by Cisco, is calling that MSI.
:: 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 
Oct 13, 2014 at 2:19 PM
Can you post the log file in here, from C:\Windows\Logs\Software, looking through it might help. Also if you run the Deploy-Application.exe locally does it work fine or does it ever give that error as well?
Oct 13, 2014 at 4:21 PM
the only relevant lines are the ones are these:

"'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: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.
Oct 13, 2014 at 4:49 PM
Edited Oct 13, 2014 at 4:50 PM
Its been a while since I have used SCCM 2007 so bear with me but are you configuring the PKG to download locally or to run from Distribution Point?
[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.
Oct 14, 2014 at 8:34 AM
Hi,

I have it set to run directly from the DP on fast connections and as cached on slow ones. I get the same warning message in the logs re UNC paths on successful installations as well. Additionally there is no correlation between failed vs successul installations running in cached vs direct mode. When I remote onto failed installations and run it manually, I'm running it from the DP and not downloading it locally first. So far, none have failed doing it that way.

I'm going to look at abandoning the Cisco script and just putting Execute-MSI into the toolkit script as per your method. Thinking about it, the .cmd from Cisco is doing the same checks for version and chassis detection that I'm already doing using SCCM collections, so I'm duplicating it by continuing to use the Cisco script.

Many thanks for the suggestions and pointers, just curious as why I'm getting this small percentage of failures.