Powershell脚本在DeploymentType中创建注册表检测方法

时间:2019-11-22 07:11:34

标签: powershell sccm

因此,我具有用于在SCCM中创建应用程序的脚本和用于创建DeploymentType的脚本。 在DeploymentType中,我正在创建使用注册表的检测方法。

$clause1 = New-CMDetectionClauseRegistryKeyValue -Hive LocalMachine -KeyName "SOFTWARE\Folder1\Folrder2\$DepName" -ValueName "some_Value" -PropertyType String -ExpressionOperator IsEquals -ExpectedValue $DepNummer -Value

    Add-CMScriptDeploymentType -ApplicationName $DepName -DeploymentTypeName $DepTypeName -ContentLocation $DepContent -InstallCommand $DepInst -UninstallCommand $DepUninst -AddDetectionClause $Clause1 -EstimatedRuntimeMins $DepMaxRun -MaximumRuntimeMins $DepMinRun -LogonRequirementType WhetherOrNotUserLoggedOn -UserInteractionMode Hidden -InstallationBehaviorType InstallForSystem -AddRequirement $oDTRule

到目前为止,该脚本有效,但是我有一个小问题。 如果您查看注册表的检测方法,则有一个复选框

“此注册表项与64位系统上的32位应用程序相关联” 我知道这是什么,但是如果不选中此框,我无法弄清楚创建DM所要做的事情。

我使用Get-CMDeploymentType提取了有关DeploymenType的信息。我找到了DM的零件,但没有关于此复选框的提示。

<EnhancedDetectionMethod>
    <Settings xmlns=\"http://schemas.microsoft.com/SystemCenterConfigurationManager/2009/AppMgmtDigest\">
        <SimpleSetting xmlns=\"http://schemas.microsoft.com/SystemsCenterConfigurationManager/2009/07/10/DesiredConfiguration\" LogicalName=\"RegSetting_8277224f-cd13-48b8-8a94-efbe3b67d5ea\" DataType=\"String\">
            <Annotation xmlns=\"http://schemas.microsoft.com/SystemsCenterConfigurationManager/2009/06/14/Rules\">
                <DisplayName Text=\"\"/>
                <Description Text=\"\"/>
            </Annotation>
            <RegistryDiscoverySource Hive=\"HKEY_LOCAL_MACHINE\" Depth=\"Base\" Is64Bit=\"true\" CreateMissingPath=\"true\">
                <Key>SOFTWARE\\Folder1\\Folder2\\Stuff</Key>
                <ValueName>some_Value</ValueName>
            </RegistryDiscoverySource>
        </SimpleSetting>
    </Settings>
    <Rule xmlns=\"http://schemas.microsoft.com/SystemsCenterConfigurationManager/2009/06/14/Rules\" id=\"ScopeId_F7D7B005-5475-42F3-8D53-C6F2B0DA1B17/DeploymentType_1dae9225-e8ee-4923-b38f-2bdcf3bd656d\" Severity=\"Informational\" NonCompliantWhenSettingIsNotFound=\"false\">
        <Annotation>
            <DisplayName Text=\"\"/>
            <Description Text=\"\"/>
        </Annotation>
        <Expression>
            <Operator>Equals</Operator>
            <Operands>
                <SettingReference AuthoringScopeId=\"ScopeId_F7D7B005-5475-42F3-8D53-C6F2B0DA1B17\" LogicalName=\"Application_6f616284-4cb8-423b-94a5-20d6e5f687fd\" Version=\"8\" DataType=\"String\" SettingLogicalName=\"RegSetting_8277224f-cd13-48b8-8a94-efbe3b67d5ea\" SettingSourceType=\"Registry\" Method=\"Value\" Changeable=\"false\"/>
                <ConstantValue Value=\"some_Value\" DataType=\"String\"/>
            </Operands>
        </Expression>
    </Rule>
</EnhancedDetectionMethod>

任何人都有主意。

高级thx

1 个答案:

答案 0 :(得分:1)

所以永远不要假设任何东西。

正如我所说,您可以在上方看到,我通过get-CMDeploymentType提取了信息,并且选中了Checkbox时对其进行了查看,而当我手动将其未选中时对其进行了查看。

但是有些东西吸引了我。

<RegistryDiscoverySource Hive=\"HKEY_LOCAL_MACHINE\" Depth=\"Base\" Is64Bit=\"true\" CreateMissingPath=\"true\">

魔术在Is64Bit =“ \ true \”部分中

我敢肯定,在SCCM中手动更改它之后,这仍然是正确的,所以我没有研究开关-is64Bit

在TechNet论坛上有人说我应该再调查一次,但是我做到了。我把它放进脚本了,哦,不知道它能起作用。

New-CMDetectionClauseRegistryKeyValue -Hive LocalMachine -KeyName "SOFTWARE\Folder1\Folrder2\$DepName" -Is64Bit -ValueName "some_Value" -PropertyType String -ExpressionOperator IsEquals -ExpectedValue $DepNummer -Value

这是版本,因此未选中复选框。

致谢

相关问题