Did you know that you can navigate the posts by swiping left and right?
As a Configuration Manager Administrator, one thing I always have to deal with is Java. I Created a new application ten days ago, 8 Update 77, and today, its up to 8 Update 91. I really am not sure how that is even possible. But none the less. Creating an application is SCCM isn’t particularly hard, but it does take a little bit of time, and when you need to create 4 new Java packages a day, it can take a lot of time. Just kidding of course, I hope you are not deploying every version of Java. But I thought why not automate the application creation with PowerShell.
It has taken a few revisions, but it is now good to go, and I use it regularly. Here is the breakdown:
This task, I accomplished in three files, mainly because I am a huge advocate of re-usability so, two of these files (the helper functions) I use in my personal PowerShell module, for more then just this task.
What is happening?
In the Controller Script, lines 42-77 is the installer script that get generated for the application to install, this can be customized. I use this script to actually install the application. This will remove all versions of Java that match the current major version that is being deployed, IE: 8 Update 91 will remove all previous version of Java 8. But this script is extracted on the fly, so it can be customized.
Also in the Controller Script, lines 80-84, are the customizations for the Java install itself, things like disabling auto update, and not adding a start menu shortcut go here. This is also extracted on the fly. Options for using this file can be found Here.
I recommend using the -Verbose switch for insight into what is happening if you use this technique. I added a lot of verbose comments for this.
# SourcePackageCreationPath: is the path to where the application source files will be stored. # ComputerName: is the name of the Site Server. # Credential: context with rights to do create applications. # SiteCode: the site code. # ApplicationFolder: the folder in SCCM where to put the application, defaults to the root of the applications workspace. PS C:\> .\New-SccmJavaApplication.ps1 -SourcePackageCreationPath '\\mysccmserver\sources\applications\java' -ComputerName mysccmserver -Credential (Get-Credential) -SiteCode 1AB -ApplicationFolder 'Java' -Verbose
Use at your own risk (Obviously)
Can be found as a Gist on GitHub