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

问题描述 投票:0回答:1

因此,我具有用于在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

powershell sccm
1个回答
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

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

问候

© www.soinside.com 2019 - 2024. All rights reserved.