JMan Posted July 11, 2017 Report post Posted July 11, 2017 Hi, I've been having problems with an install for a looong time. I need to install the latest Salesforce plugin for outlook on my companies computer but many different versions are installed which I need to uninstall prior to installing the newer version.To do so, I have found a Powershell script that if I run from PS ISE works correctly however, if I do it from a task sequence it says it has run but it doesn't do anything.This is how I did it: Created a package with the .ps1 file with no program. Added a Run powershell script step where I invoke the package and specified the script name. After many troubleshooting I think it could have to do with the account the task sequence is executed.The PS script is the following: $uninstall32 = gci "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | foreach { gp $_.PSPath } | ? { $_ -match "Salesforce*" } | select UninstallString $uninstall64 = gci "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" | foreach { gp $_.PSPath } | ? { $_ -match "Salesforce*" } | select UninstallString if ($uninstall64) { $uninstall64 = $uninstall64.UninstallString -Replace "msiexec.exe","" -Replace "/I","" -Replace "/X","" $uninstall64 = $uninstall64.Trim() Write "Uninstalling..." start-process "msiexec.exe" -arg "/X $uninstall64 /q" -Wait} if ($uninstall32) { $uninstall32 = $uninstall32.UninstallString -Replace "msiexec.exe","" -Replace "/I","" -Replace "/X","" $uninstall32 = $uninstall32.Trim() Write "Uninstalling..." start-process "msiexec.exe" -arg "/X $uninstall32 /q" -Wait} it should find the uninstall string for the app and execute it. Also, the app I'm trying to find is installed on the user profile, and if the uninstall string is run from another account it wont find it.... this is why I think it might have to do with the account Quote Share this post Link to post Share on other sites More sharing options...
keilamym Posted July 11, 2017 Report post Posted July 11, 2017 did you try to "disable 64bit file redirection" also. you try testing outside the task sequence. you can run this command as a package. it will kick off powershell and run the script. powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File .\filename.ps1 good luck and let us know if it works. Quote Share this post Link to post Share on other sites More sharing options...
JMan Posted July 12, 2017 Report post Posted July 12, 2017 THIS IS BRILLIANT!!!!! it worked as a package with a program..... I forgot that the program had an option to run as user!!! Excellent. Can't tell you how much I appreciate it! Quote Share this post Link to post Share on other sites More sharing options...
keilamym Posted July 12, 2017 Report post Posted July 12, 2017 glad i could help. Quote Share this post Link to post Share on other sites More sharing options...
wkies Posted August 3, 2017 Report post Posted August 3, 2017 Hi, Came upon this recently was trying to get it to work for me. I ran "powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File .\filename.ps1" at the command line but have trouble running it from sccm 2007. The package consists of 2 programs one being the uninstall of Symnatec Endpoint and an installation of Checkpoint endpoint. Checkpoint Endpoint has been check to "run another program first" being the uninstallation of Symantec. I have entered the following in the command line field for the uninstall program: powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File .\RemoveSoftware.ps1 and I place the the RemoveSoftware.ps1 in the package source directory. I pretty new to sccm so I must have done something wrong. The error log file at the client is: <![LOG[Successfully selected content location C:\Windows\system32\CCM\Cache\001005C3.9.System]LOG]!><time="14:09:35.735+240" date="08-03-2017" component="execmgr" context="" type="1" thread="2908" file="executioncontext.cpp:1703"> <![LOG[GetFileVersionInfoSize failed for file C:\Windows\system32\CCM\Cache\001005C3.9.System\powershell.exe, error 2]LOG]!><time="14:09:35.751+240" date="08-03-2017" component="execmgr" context="" type="2" thread="2908" file="executioncontext.cpp:119"> <![LOG[CProgramExecution::CProgramExecution]LOG]!><time="14:09:35.751+240" date="08-03-2017" component="execmgr" context="" type="1" thread="2908" file="programexecution.cpp:24"> <![LOG[Executing program as a script]LOG]!><time="14:09:35.751+240" date="08-03-2017" component="execmgr" context="" type="1" thread="2908" file="executionengine.cpp:103"> <![LOG[File C:\Windows\system32\CCM\Cache\001005C3.9.System\powershell.exe is not a valid executable file]LOG]!><time="14:09:35.751+240" date="08-03-2017" component="execmgr" context="" type="3" thread="2908" file="execengnutility.cpp:173"> <![LOG[File C:\Windows\system32\CCM\Cache\001005C3.9.System\powershell.exe is not a valid executable file]LOG]!><time="14:09:35.751+240" date="08-03-2017" component="execmgr" context="" type="3" thread="2908" file="execengnutility.cpp:173"> <![LOG[Found executable file powershell.exe with complete path C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe]LOG]!><time="14:09:35.751+240" date="08-03-2017" component="execmgr" context="" type="1" thread="2908" file="execengnutility.cpp:264"> <![LOG[Successfully prepared command line "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File .\RemovSoftware.ps1]LOG]!><time="14:09:35.751+240" date="08-03-2017" component="execmgr" context="" type="1" thread="2908" file="scriptexecution.cpp:523"> <![LOG[Command line = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File .\RemovSoftware.ps1, Working Directory = C:\Windows\system32\CCM\Cache\001005C3.9.System\]LOG]!><time="14:09:35.751+240" date="08-03-2017" component="execmgr" context="" type="1" thread="2908" file="scriptexecution.cpp:284"> <![LOG[Cached CCM (user, session) is: (S-1-5-21-1942423493-1642472500-1446904402-58211,1).]LOG]!><time="14:09:35.751+240" date="08-03-2017" component="execmgr" context="" type="1" thread="2908" file="usertoken.cpp:1138"> <![LOG[Created Process for the passed command line]LOG]!><time="14:09:35.829+240" date="08-03-2017" component="execmgr" context="" type="1" thread="2908" file="scriptexecution.cpp:407"> <![LOG[Raising event: [SMS_CodePage(850), SMS_LocaleID(3084)] instance of SoftDistProgramStartedEvent { AdvertisementId = "001203ED"; ClientID = "GUID:4A4BB982-2FFA-4317-80EB-15FD1B32D7C1"; CommandLine = "\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File .\\RemovSoftware.ps1"; DateTime = "20170803180935.844000+000"; MachineName = "50FZYN2"; PackageName = "001005C3"; ProcessID = 116; ProgramName = "Uninstall Symantec"; SiteCode = "001"; ThreadID = 2908; UserContext = "AUTORITE NT\\Système"; WorkingDirectory = "C:\\Windows\\system32\\CCM\\Cache\\001005C3.9.System\\"; }; ]LOG]!><time="14:09:35.844+240" date="08-03-2017" component="execmgr" context="" type="1" thread="2908" file="event.cpp:525"> <![LOG[Raised Program Started Event for Ad:001203ED, Package:001005C3, Program: Uninstall Symantec]LOG]!><time="14:09:35.844+240" date="08-03-2017" component="execmgr" context="" type="1" thread="2908" file="executioncontext.cpp:523"> <![LOG[GetProcessInfo - Process creation time high = 30608515, low = 2853387312]LOG]!><time="14:09:35.844+240" date="08-03-2017" component="execmgr" context="" type="1" thread="2908" file="executioncontext.cpp:2381"> I suspect that my command line is incorrect or the file location? Your help is appreciated. Thanks, Quote Share this post Link to post Share on other sites More sharing options...