powershell - 如何通过 New-CMDetectionClauseWindowsInstaller 将 Productcode 设置为检测方法
问题描述
我有一个 PowerShell 脚本,它创建具有部署类型的应用程序...我能够使用 New-CMDetectionClauseRegistryKeyValue 为注册表项创建一个检测方法
但我想要的是有两种检测方法。一个是注册表项,另一个是 ProductCode。
所以我这样做:
$clause1 = New-CMDetectionClauseRegistryKeyValue -Hive LocalMachine -KeyName "pathstuff" -Is64Bit -ValueName "aValue" -PropertyType String -ExpressionOperator IsEquals -ExpectedValue $aVar -Value
$clause2 = New-CMDetectionClauseWindowsInstaller -ProductCode $ProductCode
但是我收到第二个子句的错误:
无法使用指定的命名参数解析参数集
我相信之后我的行必须如下:
Add-CMScriptDeploymentType -ApplicationName $AppName -DeploymentTypeName $DepTypeName -ContentLocation $DepContentLocation -InstallCommand $DepInstallCommand `
-UninstallCommand $DepUninstallCommand -AddDetectionClause $clause1,$clause2 -EstimatedRuntimeMins $DepMinRuntime -MaximumRuntimeMins $DepMaxRuntime `
-LogonRequirementType WhetherOrNotUserLoggedOn -UserInteractionMode Hidden -InstallationBehaviorType InstallForSystem -AddRequirement $oDTRule
但我得到了错误
该参数不能绑定到 AddDetectionClause 参数,因为它是 NULL。
因为第2条不起作用...
我发现如果你这样做,它似乎可以工作:
$clause1 = New-CMDetectionClauseWindowsInstaller -ProductCode $guid [Value -ExpressionOperator IsEquals -ExpectedValue "1.1.1.1" # Do a version check
但这将是 SCCM 中的第二个 Radiobutton,我想要第一个。
我只是不知道我错过了什么。没有关于这个的文档......而且谷歌并没有给我太多......
任何帮助,将不胜感激。
问候
解决方案
这让我困扰了好几个星期,最后这只是 RTFM 的一个例子。因此,在此命令的 Microsoft Docs页面上是我无法阅读的答案。
$clause2 = New-CMDetectionClauseWindowsInstaller -ProductCode $ProductCode -Existence
你只需要把 -Existence 放在最后就可以了。
我非常专注于没有没有阅读完整语法描述的示例。
推荐阅读
- asp.net-core - AspNetCore 应用程序中 OpenIdConnect 身份验证流的 PostLogout 重定向问题
- node.js - Heroku节点js没有运行Web进程
- amazon-web-services - 如何使用 Terraform 和 cloud-init 为 AWS 实例配置集群的 IP?
- python - 'VoiceState' 对象没有属性 'disconnect' (discord.py)
- c - 打印键所在的树的级别
- apache-spark - 带有字符串值的 Pyspark Cumcount
- mysql - 我可以使用 varchar 在 mysql 中存储日期和时间吗?
- javascript - 如何使范围滑块流畅?
- java - ImageIO.read 中的 IllegalArgumentException
- javascript - 谁能告诉我如何使用 javascript/jquery 将其放入三列表中?产品、价格和折扣(计算 20%)