PowerShell Application wrapper for Standalone,MDT and SCCM

Update 2018-04-23: Due to issues with download and for better tracking the script has been moved to github. Link at the bottom of the post.

Update 2016-08-02: Someone asked, could it not be possible to run external vbs and ps1 scripts as well. Well hat has now been fixed and the new version is available for download.
Current versions support the following installertypes, EXE/MSI/MSP/VBS/PS1. Happy deploying!

My good friend “The Deployment Bunny” did a while back a nice script to install Internet Explorer 11 into a ref image. I now needed a nice way to deploy other applications using the same principle and way to deliver this to customers.
The problem now is most don’t want to edit the script every time a new application should be used. To sort this out the script uses a settings.xml file to specify the needed parameters.
The XML in itself is a short simple one as can be seen below.

<xml>
<Application>
<Name>Oracle Java <InstallerName>jre-8u40-windows-i586.exe</InstallerName>
<InstallerType>EXE</InstallerType>
<InstallSwitches>/s</InstallSwitches>
</Application>
</xml>

Now all that has to be changed for this to work with other applications is the Name, the file to run and the install switches. If you change to run a MSI instead just change installertype to MSI.
The folder structure for it to work needs to look like this and the install files is then place inside the Source folder.

Install-AppScript

This can then either be run by simply running the PowerShell script from the folder or by calling on it from inside SCCM or MDT. The Install command from MDT and SCCM is then “cmd /c PowerShell.exe –ExecutionPolicy ByPass –File install-applications.ps1”
If you run this inside of MDT or SCCM and in a Task sequence the logging will be done to the relevant logfolders used by MDT and SCCM.

The script can and a sample settings.xml can be downloaded from here on github

Happy deploying!

Advertisements

17 comments

  1. If I run this using CMD it works fine. I’ve tried this with your Oracle example and a few other MSI and EXE installs.

    If I run it via MDT, I’m getting: “Application [NAME] returned an unexpected return code: -196608”.

    My Application details look like this:
    cmd /c PowerShell.exe -ExecutionPolicy Bypass -File Install-Application.ps1

    Any ideas?

    Like

    1. hey, that is because mdt nativley starts all applications with cmd /c so your commandline will cause a double cmd /c and that wont work. Just remove the cmd /c part from your application command and it should be fine.
      /Peter

      Like

  2. Thanks for the great wrapper!
    What about starting .vbs or .ps1 the same way as .msi & .exe?

    It happens quite often that you have to script something before or after installation, and it would be good to do it with the same method through an external script instead of having to make changes in the installation script.

    Like

  3. Hello Peter,
    Thanks for your job, it’s perfect.
    Just a question. When I use the script in SCCM, the PC reboot automatically.
    Have you any idea?

    Like

    1. The script in itself does not reboot ever. The reboot needs to be controlled as part of the install switches. Which switches are you using and for what application?

      Like

  4. Can this be used to install two MSIs in sequence, or do I need to write another ps1 file to do that and feed it into install-application? I’d rather not create two separate apps in MDT for the two MSIs.
    Thanks,
    Ilona

    Like

    1. Not out-of-the-box since the commands to uninstall would be diffrent to the commands for installing. However that being said creating a wrapper for uninstall is not impossible and the script could be modified to do uninstallations.

      Like

      1. Is it as simple as changing the /i to a /u or x. Or would you eed the guid and all that. I would love for some one to create that script

        Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s