添加 CMDeploymentType 警告
Add-CMDeploymentType warning
我使用 poweshell 在 SCCM 2012 中自动创建应用程序,分发内容并在创建后部署它们。
我有以下代码:
New-CMApplication -name $appname -Manufacturer $manu -SoftwareVersion $ver
效果很好。
然而
Add-CMDeploymentType -MsiInstaller -applicationName $appname -AutoIdentifyFromIntallationFile -InstallationFileLocation $content -ForceForUnknownPublisher $true
给我一个警告“未能获得安装类型的技术并且它不会创建部署类型。
据我从其他网站得知,我不需要具体说明,甚至更多。我尝试在最后添加更多选项,但 none 似乎有所作为。
关于此错误的信息不多 - 以前有人解决过这个错误吗?
我怀疑您能否 Add-CMDeploymentType
做很多有用的事情 -- 至少不会以目前的形式出现。当我注意到它缺少基本的、必要的参数时,我曾经尝试并放弃了。 The documentation 甚至没有提到任何类型的检测。在没有检测的情况下使用 ConfigMgr 应用程序没有多大意义,如果您仍然必须通过 UI.
定义检测标准,则编写 DeploymentTypes 创建脚本也没有多大意义
您可能会得到使用 Add-CMDeploymentType
的 AddDeploymentTypeByMsiInstallerX
参数集配置的奇数 msi
文件。在那种情况下,您将依赖 ConfigMgr 自动计算出检测逻辑。这可能有效,但是 I have had significant issues with the MSI Deployment。如果可能的话,我会避免这种情况。
我不希望 Add-CMDeploymentType
永远可用。作为应用程序基础的对象树必然很复杂,并且实际上不适合使用简单的 PowerShell cmdlet 进行交互。要完全配置一个应用程序,您需要访问 几十 个对象的 数百个 个属性。许多这些对象都包含在类似字典和数组的集合中,这些集合有自己的特殊语义来访问它们。您无法将其简化为少量 PowerShell cmdlet。
我正在使用以下 .dll 中的类型与 ConfigMgr 交互:
- AdminUI.WqlQueryEngine.dll
- Microsoft.ConfigurationManagement.ApplicationManagement.dll
- Microsoft.ConfigurationManagement.ApplicationManagement.MsiInstaller.dll
据我所知,这与管理控制台使用的 API 相同,因此您可以期待完整的功能。您不能对 PowerShell cmdlet 做出相同的声明。到目前为止,我已经找到一种方法来使用 PowerShell 访问我通过 API 尝试过的所有内容。访问 API 的基础知识记录在 ConfigMgr SDK 中。使用反射和一些实验来弄清楚这些对象是如何工作的是相当简单的。
当您使用 Get-CMApplication
检索应用程序时,您实际上获得了完整的对象树。 SDMPackageXML
对象包含应用程序、DeploymentTypes、检测、安装程序等的序列化副本。[Microsoft.ConfigurationManagement.ApplicationManagement.Serialization.SccmSerializer]::DeserializeFromString()
用于反序列化该对象,以便您自己检查它。
我实际上放弃了这个 - 正如你所说 - Add-CMDeployment 类型完全没用。网上没有任何地方描述这个错误,或者如何正确使用它 - 一个没有检测到的应用程序是没有意义的,稍后手动添加它会破坏尝试自动化它的意义。
PowerShell centre 有一些如何使用它的示例,但这些都不起作用...
这个 link 非常有用,并且拥有我在没有 powershell 的情况下创建应用程序所需的一切。
有点长但是代码是...
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
你关于部署类型行为的问题也很奇怪——我们有同样的产品,它在 MSI 部署类型中工作。
我使用 poweshell 在 SCCM 2012 中自动创建应用程序,分发内容并在创建后部署它们。
我有以下代码:
New-CMApplication -name $appname -Manufacturer $manu -SoftwareVersion $ver
效果很好。 然而
Add-CMDeploymentType -MsiInstaller -applicationName $appname -AutoIdentifyFromIntallationFile -InstallationFileLocation $content -ForceForUnknownPublisher $true
给我一个警告“未能获得安装类型的技术并且它不会创建部署类型。
据我从其他网站得知,我不需要具体说明,甚至更多。我尝试在最后添加更多选项,但 none 似乎有所作为。
关于此错误的信息不多 - 以前有人解决过这个错误吗?
我怀疑您能否 Add-CMDeploymentType
做很多有用的事情 -- 至少不会以目前的形式出现。当我注意到它缺少基本的、必要的参数时,我曾经尝试并放弃了。 The documentation 甚至没有提到任何类型的检测。在没有检测的情况下使用 ConfigMgr 应用程序没有多大意义,如果您仍然必须通过 UI.
您可能会得到使用 Add-CMDeploymentType
的 AddDeploymentTypeByMsiInstallerX
参数集配置的奇数 msi
文件。在那种情况下,您将依赖 ConfigMgr 自动计算出检测逻辑。这可能有效,但是 I have had significant issues with the MSI Deployment。如果可能的话,我会避免这种情况。
我不希望 Add-CMDeploymentType
永远可用。作为应用程序基础的对象树必然很复杂,并且实际上不适合使用简单的 PowerShell cmdlet 进行交互。要完全配置一个应用程序,您需要访问 几十 个对象的 数百个 个属性。许多这些对象都包含在类似字典和数组的集合中,这些集合有自己的特殊语义来访问它们。您无法将其简化为少量 PowerShell cmdlet。
我正在使用以下 .dll 中的类型与 ConfigMgr 交互:
- AdminUI.WqlQueryEngine.dll
- Microsoft.ConfigurationManagement.ApplicationManagement.dll
- Microsoft.ConfigurationManagement.ApplicationManagement.MsiInstaller.dll
据我所知,这与管理控制台使用的 API 相同,因此您可以期待完整的功能。您不能对 PowerShell cmdlet 做出相同的声明。到目前为止,我已经找到一种方法来使用 PowerShell 访问我通过 API 尝试过的所有内容。访问 API 的基础知识记录在 ConfigMgr SDK 中。使用反射和一些实验来弄清楚这些对象是如何工作的是相当简单的。
当您使用 Get-CMApplication
检索应用程序时,您实际上获得了完整的对象树。 SDMPackageXML
对象包含应用程序、DeploymentTypes、检测、安装程序等的序列化副本。[Microsoft.ConfigurationManagement.ApplicationManagement.Serialization.SccmSerializer]::DeserializeFromString()
用于反序列化该对象,以便您自己检查它。
我实际上放弃了这个 - 正如你所说 - Add-CMDeployment 类型完全没用。网上没有任何地方描述这个错误,或者如何正确使用它 - 一个没有检测到的应用程序是没有意义的,稍后手动添加它会破坏尝试自动化它的意义。
PowerShell centre 有一些如何使用它的示例,但这些都不起作用...
这个 link 非常有用,并且拥有我在没有 powershell 的情况下创建应用程序所需的一切。
有点长但是代码是...
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
你关于部署类型行为的问题也很奇怪——我们有同样的产品,它在 MSI 部署类型中工作。