Menu
CCMEXEC.COM – Enterprise Mobility
  • Home
  • General
  • Configuration Manager
  • Windows 10
  • Windows 11
  • Intune
  • GitHub
  • About
CCMEXEC.COM – Enterprise Mobility

Vbscript: Modify packages to be available on package share ConfigMgr2012

Posted on December 20, 2012 by Jörgen Nilsson

In some scenarios in Configuration Manager 2012 you want your packages, OS images, boot image and driver packages, well everything you use in a task sequence to be available on the package share so that we can use the option to access the content directly during OS deployment.
This of course takes up more disk space but makes the OS deployment a little bit faster.

Here is the setting in question:

packageshare1

I got a question today if you could script that setting, so after a little bit of WMI browsing I found the value that needs to changed, as I couldn’t find it in the SDK for Configuration Manager 2012, maybe I wasn’t looking hard enough.

However here is a code snippet that you can use together together with the example on MSDN on how to call an example snippet: http://msdn.microsoft.com/en-us/library/hh949053.aspx.

Sub ModifyPackageFlags(connection, existingPackageID)

' Define a constant with the hex value for USE_PKGSHARE.

CONST USE_PKGSHARE = "&H00000080"

' Get the specific advertisement instance to modify.

Set packageToModify = connection.Get("SMS_Package.PackageID='" & existingPackageID & "'")

' List the existing property values.

Wscript.Echo " "

Wscript.Echo "Values before change: "

Wscript.Echo "--------------------- "

Wscript.Echo "Package Name: " & packageToModify.Name

Wscript.Echo "Package Flags: " & packageToModify.PkgFlags

' Set the new property value.

packageToModify.PkgFlags = packageToModify.PkgFlags OR USE_PKGSHARE

' Save the advertisement.

packageToModify.Put_

' Output the new property values.

Wscript.Echo " "

Wscript.Echo "Values after change: "

Wscript.Echo "--------------------- "

Wscript.Echo "Package Name: " & packageToModify.Name

Wscript.Echo "Package Flags: " & packageToModify.PkgFlags

End Sub

2 thoughts on “Vbscript: Modify packages to be available on package share ConfigMgr2012”

  1. Simon Erratt says:
    June 11, 2014 at 8:04 am

    Hi, great snippet, it got me on the right track.

    I found that for me, it falls over with driver packages. I replaced this line…

    packageToModify.PkgFlags = packageToModify.PkgFlags OR USE_PKGSHARE

    with these lines…

    Err.Clear
    On Error Resume Next
    Set packageToModify = swbemServices.Get(“SMS_Package.PackageID='” & objResource.ReferencePackageID & “‘”)
    If Err.Number 0 Then
    Set packageToModify = swbemServices.Get(“SMS_DriverPackage.PackageID='” & objResource.ReferencePackageID & “‘”)
    End If

    Cheers!

    Simon.

    Reply
    1. Jörgen Nilsson says:
      June 13, 2014 at 11:59 am

      Hi, Great! Thanks for the update, will use it as well.

      Reply

Leave a Reply Cancel 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.

My name is Jörgen Nilsson and I work as a Senior Consultant at Onevinn in Malmö, Sweden. This is my blog where I will share tips and stuff for my own and everyone elses use on Enterprise Mobility and Windows related topics.
All code is provided "AS-IS" with no warranties.

Recent Posts

  • Tip when troubleshooting unexpected reboots during Autopilot – event ID 2800
  • New settings in Intune Security Baseline Windows 11 24H2 -2504
  • Managing extensions in Visual Studio Code
  • Reinstall a required Win32app using remediation on demand
  • Administrator protection in Windows 11 – First look
©2025 CCMEXEC.COM – Enterprise Mobility | WordPress Theme by Superb Themes
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.Accept Reject Read More
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT