Deploy a PowerShell Script as a SCCM Application or Program

This is just a quick post to help those who are struggling to find the correct syntax to place into the program (CMD line) field when deploying a PowerShell Script as an application or program for that matter using SCCM.

For an “Application” “Deployment type” just place this into the Program line.

For a “Package” “Program ” just place this into the CMD line.

Note: When using MDT install applications step in you task sequence (Customsettings or MDT DB driven) to install programs this also works a treat!

You can add other properties also like -NoProfile but to be honest I have found this to work 100% of the time without the need for those extras. Just make sure you detection method is solid!

13 Replies to “Deploy a PowerShell Script as a SCCM Application or Program”

  1. Are you able to execute commands such as “Start-Process” or “Start-Job” inside the “Your-Scriptfilename.PS1” script executed by SCCM?
    Executing the script containing these commands manually works but executing the same script with SCCM returns a powershell.exe error message “The application was unable to start correctly (0x0000142)”

  2. Isn’t “sysnative” going to depend on 32 vs. 64 bit? Or will that “sysnative” work 100% of the time for all versions of w7 and w10, with both 32-bit & 64-bit? Also, this is a good article/tip, but screen-shots, start-to-finish, with full example, would be ideal. Thanks for this info!

  3. Hello,

    What are the log files from SCCM\CCM\Log to follow the process.
    I tested the PowerShell locally.
    I deployed the PowerShell to the client, it is in the ccmcache folder
    I do not see the execution???

    Any idea?
    Thanks,
    Dom

    1. If you have not changed the default installation folder for the ConfigMgr Client then the logs will be located here:
      C:\Windows\CCM\Logs
      Appenforce.log
      AppDiscovery.log

      Cheers,
      SCCMOG

  4. Thank you. Works decently well. Just a quick note. On my Windows 11 test pc the script fails if the ps1 file is located on a network share – so I had to have my script copy it over locally and then execute it. I don’t know if that’s a powershell feature or just a quirk of my script though.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.