如何将计算机OU的要求应用于SCCM部署类型

时间:2019-05-07 10:16:28

标签: powershell active-directory sccm

我正在创建一个脚本,以将App-V应用程序部署到SCCM中,并且除了在新的部署类型上设置要求以外,其他所有操作均正常。我需要申请3个OU。

到目前为止,我已经解决了如何反序列化SDMPackage XML的问题,并深入研究了现有的Deployment Type,其中包含我需要的值。我该如何设置 new 部署类型以获取此信息?

我尝试遵循https://www.reddit.com/r/SCCM/comments/9sfbul/updating_application_sdmpackagexml_example/,但是我不知道设置OU所需的格式。我尝试过的一切都没有被接受。

AuthoringScopeId   : GLOBAL
LogicalName        : MACHINEOU
SettingDataType    : Microsoft.SystemsManagementServer.DesiredConfigurationManagement.Expressions.ScalarDataType
SettingLogicalName : MachineOU_Setting_LogicalName
MethodType         : Value
PropertyPath       : 
SettingSourceType  : CIM
IsDirty            : False
ItemUniqueId       : GLOBAL/MACHINEOU
OperandDataType    : Microsoft.SystemsManagementServer.DesiredConfigurationManagement.Expressions.ScalarDataType

ValueList              : {, , }
Values                 : {OU=UAT,OU=Desktops,OU=Physical,OU=Windows10,OU=Clients,OU=Computers,DC=domain,DC=rootdomain,DC=local, 
                         OU=UAT,OU=Laptops,OU=Physical,OU=Windows10,OU=Clients,OU=Computers,DC=domain,DC=rootdomain,DC=local, 
                         OU=UAT,OU=XenApp,OU=Virtual,OU=Windows10,OU=Clients,OU=Computers,DC=domain,DC=rootdomain,DC=local}
CultureInvariantValues : {OU=UAT,OU=Desktops,OU=Physical,OU=Windows10,OU=Clients,OU=Computers,DC=domain,DC=rootdomain,DC=local, 
                         OU=UAT,OU=Laptops,OU=Physical,OU=Windows10,OU=Clients,OU=Computers,DC=domain,DC=rootdomain,DC=local, 
                         OU=UAT,OU=XenApp,OU=Virtual,OU=Windows10,OU=Clients,OU=Computers,DC=domain,DC=rootdomain,DC=local}
ListValueType          : Microsoft.SystemsManagementServer.DesiredConfigurationManagement.Expressions.VectorDataType
IsDirty                : False
OperandDataType        : Microsoft.SystemsManagementServer.DesiredConfigurationManagement.Expressions.VectorDataType

1 个答案:

答案 0 :(得分:0)

我不知道您是否已经知道了。如果没有,也许可以帮忙:

  $ApplicationName = "your app name" 
  [Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine.WqlResultObject]$Application = Get-CMApplication -Name $ApplicationName
  $DeserializedApp =  [Microsoft.ConfigurationManagement.ApplicationManagement.Serialization.SccmSerializer]::DeserializeFromString($Application.SDMPackageXML, $true)

  # This will take expression for first deployment type and its first requirement, 
  # so if you have more deployment types with multiple requirements probably you want to add some filtering
  [Microsoft.SystemsManagementServer.DesiredConfigurationManagement.Expressions.Expression]$Expression = 
  [Microsoft.SystemsManagementServer.DesiredConfigurationManagement.Expressions.Expression]$DeserializedApp.DeploymentTypes[0].Requirements[0].Expression
  $OuValue = New-Object Microsoft.SystemsManagementServer.DesiredConfigurationManagement.Expressions.OUValue -ArgumentList "here put your OU",$true 

  # MACHINE OU Expression consists of two operands, you want to add OU to second one
  $Expression.Operands[1].ValueList.Add($OuValue)

  # Now serialize back to string
  $Application =  [Microsoft.ConfigurationManagement.ApplicationManagement.Serialization.SccmSerializer]::Serialize($DeserializedApp)
  $Application.Put()