FriendsOfMDT / PSD

PowerShell Deployment
MIT License
525 stars 83 forks source link

"Run Command Line" never stops executing after (ver 0.2.3.0) update - Win11 #185

Closed Skydea777 closed 1 month ago

Skydea777 commented 1 month ago

Hi there,

After updating from version 2.2.8 to 2.3.0, I am encountering an issue with running a custom install script. The script never completes and just hangs indefinitely. Even when using “exit /b” or other commands within the script, it does not proceed to the next task in the task sequence, a restart with "shutdown -r -f -t 0" will also lead to a failed deployment.

I have logged the entire installation process with my script and checking manually each component installs successfully. However, the script does not advance to the next task. If I manually close the running “cmd.exe” using Task Manager, the whole deployment fails. The remaining tasks in the sequence rush by in the status bar, and then the Client restarts, presenting an empty error screen after finishing.

The error logs are not helpful as they do not show any "real" errors, only that the process where executed corretly, well and that is a fact. Exit Code: 3221225477 Return Code: 0xC0000005 The script installs multiple software components for the client using the following command:

%windir%\system32\cmd.exe /c %SCRIPTROOT%\Install\PSTools\PsExec.exe \\%COMPUTERNAME% /accepteula -u enter.yourdomain.here\ServiceUserWithAccessRights -p HereIsAMightyComplicatedPassword -i -h "%windir%\system32\cmd.exe" " /c call \\enter.yourdomain.here\storage$\PathToTheBatch\Deploy\deploy-konstruct-everything.bat" I also tried a PowerShell variation:

powershell.exe -ExecutionPolicy Bypass -NoProfile -command "& %SCRIPTROOT%\Install\PSTools\PsExec.exe \\%COMPUTERNAME% /accepteula -u enter.yourdomain.here\ServiceUserWithAccessRights -p HereIsAMightyComplicatedPassword -i -h "%windir%\system32\cmd.exe" " /c call \\enter.yourdomain.here\storage$\PathToTheBatch\Deploy\deploy-konstruct-everything.bat"


As an additional Note, there is a previous Task that also calls a .bat File, this one just fails with the Error Code 1 and gets logged:

![LOG[Expand a string: powershell.exe -ExecutionPolicy Bypass -WindowStyle Maximized -NoProfile -command "& %SCRIPTROOT%\Install\PSTools\PsExec.exe \\%COMPUTERNAME% /accepteula -u enter.yourdomain.here\ServiceUserWithAccessRights -p HereIsAMightyComplicatedPassword -i -h -s %windir%\system32\cmd.exe ' /c call %SCRIPTROOT%\Install\DisableAV\DisableAV.bat'"]LOG]!><time="14:37:57.580-120" date="10-09-2024" component="TSManager" context="" type="0" thread="6480" file="executionenv.cxx:776">
<![LOG[Expand a string: ]LOG]!><time="14:37:57.580-120" date="10-09-2024" component="TSManager" context="" type="0" thread="6480" file="executionenv.cxx:776">
<![LOG[Start executing the command line: powershell.exe -ExecutionPolicy Bypass -WindowStyle Maximized -NoProfile -command "& %SCRIPTROOT%\Install\PSTools\PsExec.exe \\%COMPUTERNAME% /accepteula -u enter.yourdomain.here\ServiceUserWithAccessRights -p HereIsAMightyComplicatedPassword -i -h -s %windir%\system32\cmd.exe ' /c call %SCRIPTROOT%\Install\DisableAV\DisableAV.bat'"]LOG]!><time="14:37:57.585-120" date="10-09-2024" component="TSManager" context="" type="1" thread="6480" file="instruction.cxx:732">
<![LOG[!--------------------------------------------------------------------------------------------!]LOG]!><time="14:37:57.585-120" date="10-09-2024" component="TSManager" context="" type="1" thread="6480" file="instruction.cxx:761">
<![LOG[Expand a string: WinPEandFullOS]LOG]!><time="14:37:57.585-120" date="10-09-2024" component="TSManager" context="" type="0" thread="6480" file="executionenv.cxx:776">
<![LOG[Executing command line: powershell.exe -ExecutionPolicy Bypass -WindowStyle Maximized -NoProfile -command "& %SCRIPTROOT%\Install\PSTools\PsExec.exe \\%COMPUTERNAME% /accepteula -u enter.yourdomain.here\ServiceUserWithAccessRights -p HereIsAMightyComplicatedPassword -i -h -s %windir%\system32\cmd.exe ' /c call %SCRIPTROOT%\Install\DisableAV\DisableAV.bat'"]LOG]!><time="14:37:57.586-120" date="10-09-2024" component="TSManager" context="" type="1" thread="6480" file="CommandLine.cpp:819">
<![LOG[Process completed with exit code 1]LOG]!><time="14:38:01.831-120" date="10-09-2024" component="TSManager" context="" type="1" thread="6480" file="CommandLine.cpp:1115">
<![LOG[!--------------------------------------------------------------------------------------------!]LOG]!><time="14:38:01.833-120" date="10-09-2024" component="TSManager" context="" type="1" thread="6480" file="instruction.cxx:816">
<![LOG[Could not find CCM install folder. Don't use ccmerrors.dll]LOG]!><time="14:38:01.845-120" date="10-09-2024" component="TSManager" context="" type="0" thread="6480" file="String.cpp:1364">
<![LOG[Failed to run the action: DisableAV2. 
Unknown error (Error: 00000001; Source: Unknown)]LOG]!><time="14:38:01.847-120" date="10-09-2024" component="TSManager" context="" type="3" thread="6480" file="instruction.cxx:924">
<![LOG[Executing in non SMS standalone mode. Ignoring send a task execution status message request]LOG]!><time="14:38:01.847-120" date="10-09-2024" component="TSManager" context="" type="1" thread="6480" file="utils.cpp:6604">
<![LOG[Set a global environment variable _SMSTSLastActionRetCode=1]LOG]!><time="14:38:01.847-120" date="10-09-2024" component="TSManager" context="" type="0" thread="6480" file="executionenv.cxx:662">
<![LOG[Set a global environment variable _SMSTSLastActionName=DisableAV2]LOG]!><time="14:38:01.849-120" date="10-09-2024" component="TSManager" context="" type="0" thread="6480" file="executionenv.cxx:662">
<![LOG[Set a global environment variable _SMSTSLastActionSucceeded=false]LOG]!><time="14:38:01.849-120" date="10-09-2024" component="TSManager" context="" type="0" thread="6480" file="executionenv.cxx:662">
<![LOG[Clear local default environment]LOG]!><time="14:38:01.849-120" date="10-09-2024" component="TSManager" context="" type="0" thread="6480" file="executionenv.cxx:801">
<![LOG[The execution engine ignored the failure of the action (DisableAV2) and continues execution]LOG]!><time="14:38:01.878-120" date="10-09-2024" component="TSManager" context="" type="2" thread="6480" file="instruction.cxx:993">
<![LOG[Executing in non SMS standalone mode. Ignoring send a task execution status message request]LOG]!><time="14:38:01.880-120" date="10-09-2024" component="TSManager" context="" type="1" thread="6480" file="utils.cpp:6604">
<![LOG[Updated security on object C:\_SMSTaskSequence.]LOG]!><time="14:38:01.884-120" date="10-09-2024" component="TSManager" context="" type="1" thread="6480" file="utils.cpp:1967">

I also renamed the batch .bat into ".cmd" interesstingly then there is no "cmd.exe" to kill. Just an Unresponsive "psexec.exe" and its Service that cannot be """killed""". PSTools are the latest Version 2.43.

I suspect it is the PSExec that is used here that is the problem, somehow something goes wrong in this context that has worked before the Update.


Environment:

Additional Information:

Steps to Reproduce: Starting a Deployment with a "Run Command Line" that calls a Batch Via PSExec (So the Access Rights are correct) Expected Behavior: After the sucessful Installation it should continue with the last steps. Actual Behavior: Just stops after the Script was started the Deployment does not continue Screenshots/Logs: Logs-After-Batch-Started.zip mstsc_IwGUskND1q image After-Restart-smsts.zip

Skydea777 commented 1 month ago

If you are believing it or not, after over eighty failed deployments, I found it, change the "PsExec.exe" into its 64Bit counterpart "PsExec64.exe". Thats it, that is the reason the whole thing stopped working and I am screaming in anguish.

Thank you all, wish you a great day.