4 Replies Latest reply on Jan 26, 2018 8:52 AM by anthony.swanson

    power shell custom action

    swichowski Rookie

      I created a Deployment template with a custom action just like in  How To: Run a PowerShell Script with a Custom Action

       

      The patch deploys but it does not seem to run the powershell custom action comand or even put the file on the computer  being patched.

       

      It looks like it started in the log below but thats all I get.

       

       

       

      -01-25T16:58:22.0378315Z 15dc I ChildProcess.cpp:114 Started C:\WINDOWS\sysnative\cmd.exe /U /Q /D /V:ON /C "PowerShell -Command "Start-Process PowerShell -Verb Runas"  %C:\Windows\ProPatches\Patches%AppX-Removal.ps1"

      2018-01-25T16:58:40.2728313Z 15dc V ChildProcess.cpp:140 Process handle 000007D0 returned '0'.

      2018-01-25T16:58:40.2728313Z 15dc W SingleInstanceLock.cpp:28 Waiting for another deployment to finish.

      2018-01-25T16:58:40.2728313Z 15dc I SingleInstanceLock.cpp:36 Exclusively continuing deployment.

      2018-01-25T16:58:40.2728313Z 15dc V STPackageDeployer.cpp:85 Initiating patch store servicing.

      2018-01-25T16:58:40.2884594Z 15dc V STPackageDeployer.cpp:106 Patch store servicing complete.

      2018-01-25T16:58:40.2884594Z 15dc I STPackageDeployer.cpp:1336 Postboot actions filename='PostBootTasks.xml' does not exist on the file system

      2018-01-25T16:58:40.2884594Z 15dc I STPackageDeployer.cpp:484 Reboot disallowed or not required. safeRebootOption = '3', deployer requested reboot: false

      2018-01-25T16:58:40.2884594Z 15dc V DeployStatusReporter.cpp:128 Queueing online machine status msg. DeploymentId='8667cef7-0aed-4c52-90a3-d8ce04f54058', machineId='230557', status='99', isFinal='true'

      2018-01-25T16:58:40.2884594Z 15dc S StatusClient.cpp:109 Entering STDeployment::CStatusClient::ReportMachineStatusOnline.

      2018-01-25T16:58:41.5697520Z 15dc S DeployExeStates.cpp:409 Leaving STDeploy::CInitialExecutionPackageDeploy::DoStatefulRemediateActions.

      2018-01-25T16:58:41.5697520Z 15dc I STDeploy.cpp:365 Current remediation phase completed. Process exit code: 0.

      2018-01-25T16:58:41.5697520Z 15dc S STDeploy.cpp:257 Leaving wmain.

        • 1. Re: power shell custom action
          anthony.swanson SupportEmployee

          Hello,

           

          Thank you for your post. Can you provide a screenshot of your deployment template, specifically showing the Custom Action tab? I'd like to make sure the custom actions were configured correctly.

           

          Thank you,

           

          Anthony

          • 3. Re: power shell custom action
            swichowski Rookie

            I see:

            2018-01-26T14:38:47.0803200Z 2794 I ChildProcess.cpp:114 Started C:\WINDOWS\sysnative\cmd.exe /U /Q /D /V:ON /C "PowerShell %PATHTOFIXES%AppX-Removal.ps1"

             

            so I opened an 'Administrator: Command Prompt' and ran the following, after locating 'AppX-Removal.ps1' in C:\Windows\ProPatches\Installation\InstallationSandbox#2018-01-26-T-14-37-54\:

             

            C:\WINDOWS\system32> cmd.exe /U /Q /D /V:on /C "PowerShell C:\Windows\Propatches\Installation\InstallationSandbox#2018-01-26-T-14-37-54\AppX-removal.ps1

             

            and the script ran successfully.  I think the question is where does %PATHTOFIXES% point to?

            • 4. Re: power shell custom action
              anthony.swanson SupportEmployee

              Hello,

               

              Thank you for your update. You'll need to change your command to as listed in the document. In your situation, that would be "Powershell %PATHTOFIXES%AppX-Removal.ps1".

               

              %PATHTOFIXES% refers to the installation sandbox variable location that is created for each deployment. When pushing your files, they will end up in an Installation sandbox named similar to "InstallationSandbox#YYYY-MM-DD-T-HH-MM-SS".  As such, when calling files you will need to call from the %PATHTOFIXES% location in order to have our engines find the correct file.

               

              Thank you,

               

              Anthony