Application won’t download Content

In my previous post I had a script that creates the application. Everything looked fine but when trying to install SCCM could not find the source so it was thinking it was locally availble. Although I added content to the application it was missing content. Reason was that the object did not create a reference to the application. So the following lines should also be added to add content to the deployment type.

$newContentref  =  New-Object Microsoft.ConfigurationManagement.ApplicationManagement.ContentRef
$newContentref.ID  = $newApplicationContent.Id
$newDeploymentType.Installer.InstallContent =  $newContentref

10 thoughts on “Application won’t download Content”

  1. Your site is a huge help, I was running into this problem being seeing your post.

    The command helped some, but not 100%. Before, I got no content downloaded. Now, I get the MSI file downloaded but no companion files (transforms, etc.)

    Does that sound like a problem you’ve seen?

    1. Yes I had the same problem when the application had more than one file :-). The following line adds all the content of the folder as application content.

      $newApplicationContent = [Microsoft.ConfigurationManagement.ApplicationManagement.ContentImporter]::CreateContentFromFolder($APPUNCPath)

      Because wordpress don’t displayed the whole string hereby the code

      $newApplicationContent = [Microsoft.ConfigurationManagement.ApplicationManagement.ContentImporter]::

  2. Hi,
    I am trying to run the script from a machine which is not in sccm domain , and trying to import content from a valid UNC path using above command, but I am facing an error “Access to the path is denied”. Can you help us if we are doing something wrong ?

    1. I guess this is because the computer isn’t authorized to access the path. Can you map the network drive and than import the content via the UNC Path.

  3. Hi

    I am tring what u have writen. But I got the following error.

    Exception calling “SerializeToString” with “2” argument (s): “Invalid Property: Application object (
    ScopeId_B3BDB2B2-47B4-4045-A7AB-B6B049EB6651: Application_d8089c4e-b4db-44d1-B322-9219b82834e3: 1) property DeploymentTy
    pes.DeploymentTypes [0] Installer.Installer.InstallContent:. Contents Content not found in collection ”

    Can you help me to fixed this problem?

  4. When I execute the following codes, it returns the error message.
    $newApplicationXML = [Microsoft.ConfigurationManagement.ApplicationManagement.Serialization.SccmSerializer]::SerializeToSTring($newApplication,$true).

    The powershell codes :

    function Import-SCCMAssemblies($SCCMAdminConsolePath){
    $path = “$SCCMAdminConsolePath\Microsoft.ConfigurationManagement.ApplicationManagement.MsiInstaller.dll”
    if (Test-Path $path) { $t = [System.Reflection.Assembly]::LoadFrom($path)}

    $path = “$SCCMAdminConsolePath\Microsoft.ConfigurationManagement.ApplicationManagement.dll”
    if (Test-Path $path) { $t = [System.Reflection.Assembly]::LoadFrom($path)}

    $path = “$SCCMAdminConsolePath\Microsoft.ConfigurationManagement.ApplicationManagement.Extender.dll”
    if (Test-Path $path) { $t = [System.Reflection.Assembly]::LoadFrom($path)}

    $path = “$SCCMAdminConsolePath\DcmObjectModel.dll”
    if (Test-Path $path) { $t = [System.Reflection.Assembly]::LoadFrom($path)}

    Function Get-AuthoringScopeID{
    PARAM (
    [Parameter(Mandatory=$true, HelpMessage=”SCCM Server”)][Alias(“Server”,”SmsServer”)][System.Object] $SccmServer

    $identificationClass = [WMICLASS]”\\$($SccmServer.Machine)\$($SccmServer.Namespace):SMS_Identification”
    $cls = Get-WmiObject SMS_Identification -namespace $SccmServer.Namespace -ComputerName $SccmServer.Machine -list
    $tmp = $identificationClass.GetSiteID().SiteID
    return “ScopeId_$($tmp.Substring(1,$tmp.Length -2))”

    #SCCMServer & Site_Code
    $server = “08frbroundy”
    $site = “FRA”
    $con = New-Object System.Object
    $con | Add-member -type NoteProperty -name Machine -Value “$server”
    $con | Add-member -type NoteProperty -name namespace -Value “root\SMS\site_$site”

    #Next step is to get the ScopeID of you SCCM Site server.
    #How to do this can be found in my previous blog
    #Now you can create an application XML file with the use of the assemblies we have loaded
    #Loading Assemblies to create an SCCM 2012 application
    Import-SCCMAssemblies “C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin”

    #Get Authoring ScopeID
    $scopeid = Get-AuthoringScopeID $con

    #Create an unique id for the application and the deployment type
    $newApplicationID = “Application_” + [guid]::NewGuid().ToString()
    $newDeploymentTypeID = “DeploymentType_” + [guid]::NewGuid().ToString()

    #Create SCCM 2012 object id for application and deploymenttype
    $newApplicationID = New-Object Microsoft.ConfigurationManagement.ApplicationManagement.ObjectID($scopeid,$newApplicationID)
    $newDeploymentTypeID = New-Object Microsoft.ConfigurationManagement.ApplicationManagement.ObjectID($scopeid , $newDeploymentTypeID)

    #Create all the objects neccessary for the creation of the application
    $newApplication = New-Object Microsoft.ConfigurationManagement.ApplicationManagement.Application($newApplicationID)
    $newDeploymentType = New-Object Microsoft.ConfigurationManagement.ApplicationManagement.DeploymentType($newDeploymentTypeID,”MSI”)
    $newDisplayInfo = New-Object Microsoft.ConfigurationManagement.ApplicationManagement.AppDisplayInfo
    $newApplicationContent = New-Object Microsoft.ConfigurationManagement.ApplicationManagement.Content
    $newContentFile = New-Object Microsoft.ConfigurationManagement.ApplicationManagement.ContentFile

    $APPUNCPath = “\\localhost\Users\administrator.BROUNDYS\Desktop\msi”
    $APP = New-Object System.Object
    $APP | Add-Member -type noteproperty -Name “Title” -Value “TestApp”
    $APP | Add-Member -type noteproperty -Name “Description” -Value “This is a TestApp”
    $APP | Add-Member -type noteproperty -Name “DisplayName” -Value “TestApp”
    $APP | Add-Member -type noteproperty -Name “PRVersion” -Value “1.0”
    $APP | Add-Member -type noteproperty -Name “MSIName” -Value “orca.msi”
    $APP | Add-Member -type noteproperty -Name “ProductCode” -Value “{85F4CBCB-9BBC-4B50-A7D8-E1106771498D}”

    ##Setting Display Info
    $newDisplayInfo.Title = $APP.DisplayName
    $newDisplayInfo.Language = “en-US”#*****language*****
    $newDisplayInfo.Description = $APP.Description
    $newDisplayInfo.Version = $APP.PRVersion


    ##Setting default Language must be set and displayinfo must exist
    $newApplication.DisplayInfo.DefaultLanguage = $newDisplayInfo.Language
    $newApplication.Title = $APP.Title
    $newApplication.Version = 1

    #Deployment Type msi installer will be used
    $newDeploymentType.Title = “Deploy $($APP.DisplayName)”
    $newDeploymentType.Version = 1
    $newDeploymentType.Installer.ProductCode = $APP.ProductCode
    $newDeploymentType.Installer.InstallCommandLine = “Msiexec /i $($APP.MSIName) /q”
    $newDeploymentType.Installer.InstallFolder  =”\” 
    $newDeploymentType.Installer.UninstallCommandLine = “Msiexec /x $($APP.ProductCode) /q”

    #UPDATE: Add all content to the application
    $newApplicationContent = [Microsoft.ConfigurationManagement.ApplicationManagement.ContentImporter]::CreateContentFromFolder($APPUNCPath)

    $newApplicationContent.OnSlowNetwork = “Download”
    $newDeploymentType.Installer.Contents.Add($newApplicationContent )

    # Below should be the code to create an Enhanced Detection Rule, as found in
    # the console’s interface as Rules and Clauses under the Detection Method tab.

    ##Serialize the object to an xml file and stuff it into SCCM
    $newApplicationXML = [Microsoft.ConfigurationManagement.ApplicationManagement.Serialization.SccmSerializer]::SerializeToSTring($newApplication,$true)

    $applicationClass = [WMICLASS]”\\$($con.Machine)\$($con.Namespace):SMS_Application”
    $newApplication = $applicationClass.createInstance()

    $newApplication.SDMPackageXML = $newApplicationXML
    $tmp = $newApplication.Put()

    ##Reload the application to get the data


    1. I tested you code on my test machine and everything looks fine. Can you tell me the version of SCCM and Windows Server you are using.

    1. I had to update my test environment to R2 but even there it works. I guess there is something wrong with the content you add. Maybe you can choose an empty folder. Also check the paramaters
      – $newApplication.DeploymentTypes[0].Installer
      – $newApplication.DeploymentTypes[0].Installer.InstallContent

Comments are closed.