Search code examples
powershellsccm

Add-CMDeploymentType warning


Im using poweshell to automate creating applications in SCCM 2012, distributing content and deploying them once created.

I have the following code:

   New-CMApplication -name $appname -Manufacturer $manu -SoftwareVersion $ver

Which works fine. However.

Add-CMDeploymentType -MsiInstaller -applicationName $appname -AutoIdentifyFromIntallationFile -InstallationFileLocation $content -ForceForUnknownPublisher $true

Gives me a warning " Failed to get install type's technology and it won't create the deployment type.

As far as I can tell from other sites, I shouldn't need to specifiy and more than that. I've experimented with adding more options on the end but none seem to make a difference.

There isnt very much out there about this error - has anyone got past it before?


Solution

  • I actually gave up on this - As you say - Add-CMDeployment type is completely useless. There was nothing online anywhere that described this error, or how to use it properly - an Application with no detection is pointless and adding it manually later defeats the point in trying to automate it.

    PowerShell centre had some examples of how it could be used but neither of these worked...

    This link was pretty useful and has everything I needed to create an application without powershell.

    link

    a bit long but the code was...

    Public Sub create_SCCM_application(appname As String, version As String, content_location As String, filename As String, manu As String)
    
        Try
            Dim appID As ObjectId = New ObjectId("ScopeId_devscope", "Application_" & Guid.NewGuid().ToString())
            Dim app As New Application(appID)
    
            app.Title = appname
            app.Version = "1.0"
            app.Publisher = manu
            app.SoftwareVersion = version
            app.AutoInstall = True
    
    
            Dim dinfo As New AppDisplayInfo
            dinfo.Title = appname
            dinfo.Version = version
    
            dinfo.Language = Globalization.CultureInfo.CurrentCulture.Name
            app.DisplayInfo.Add(dinfo)
    
    
            Dim dtID As ObjectId = New ObjectId("ScopeId_devscope", "DeploymentType_" & Guid.NewGuid().ToString())
            Dim dt As New DeploymentType(dtID, MsiInstallerTechnology.TechnologyId)
            dt.Title = appname & " Deployment type"
            dt.Version = "1.0"
    
    
            app.DeploymentTypes.Add(dt)
    
            Dim installer As MsiInstaller = dt.Installer
            Dim fakecode As Guid = Guid.NewGuid
            installer.ProductCode = "{" & fakecode.ToString & "}"
            installer.InstallCommandLine = "msiexec /i " & filename
            installer.UninstallCommandLine = "msiexec /x " & filename
            installer.AllowUninstall = True
            installer.ExecuteTime = 30
            installer.MaxExecuteTime = 30
            installer.ExecutionContext = ExecutionContext.System
            installer.UserInteractionMode = UserInteractionMode.Hidden
            installer.DetectionMethod = DetectionMethod.ProductCode
            installer.ProductVersion = version
    
    
    
            Dim appcont As Content = New Content
            installer.Contents.Add(appcont)
            appcont.Location = content_location
            Dim msifile As New ContentFile
            msifile.Name = "_temp.msi"
            appcont.Files.Add(msifile)
    
    
            Dim appxml As XDocument = SccmSerializer.Serialize(app, True)
            Dim appinstance As ManagementObject = Nothing
            Dim path As ManagementPath = New ManagementPath("SMS_Application")
            Dim options As New ObjectGetOptions
            Dim appClass As ManagementClass = Nothing
    
            Dim scope As ManagementScope = New ManagementScope("\\devserver\root\Sms\Site_devsitecode")
            appClass = New ManagementClass(scope, path, options)
            appinstance = appClass.CreateInstance()
            appinstance.Properties("SDMPackageXML").Value = appxml
            appinstance.Put()
        Catch x As System.Exception
            Console.WriteLine(x.Message)
        End Try
    
    
    End Sub
    

    Your question regarding the deployment type behaviour is also wierd - We have that same product and it works from an MSI deployment type.