【发布时间】:2019-02-14 00:18:00
【问题描述】:
我有一个 power shell 命令行,我试图将一个包含序列号(例如“123”、“456”等)的 txt 文件导入 SCCM 以创建设备集合。我正在尝试在参数中导入,因此它只使用值列表创建 1 个查询,但我不断收到错误“找不到接受参数的位置参数 .\process.txt”
$Process = ".\process.txt
Add-CMDeviceCollectionQueryMembershipRule -Collection $collection -RuleName "Membership $collectionName" -QueryExpression "select * from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM_PRODUCT on SMS_G_System_COMPUTER_SYSTEM_PRODUCT.ResourceId = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM_PRODUCT.IdentifyingNumber in "`("$Process"`)""
预期结果
select * from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM_PRODUCT on SMS_G_System_COMPUTER_SYSTEM_PRODUCT.ResourceId = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM_PRODUCT.IdentifyingNumber in ("9876","6543",12345")
实际结果
Add-CMDeviceCollectionQueryMembershipRule : A positional parameter cannot be found that accepts argument
'(C:\Users\Owner\Desktop\Process.txt)'.
At C:\Users\Owner\Desktop\Add2Sccm_Works SerialNumber - Copy.ps1:42 char:1
+ Add-CMDeviceCollectionQueryMembershipRule -Collection $collection -Ru ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Add-CMDeviceCol...yMembershipRule], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ConfigurationManagement.Cmdlets.Collections.Comman
ds.AddDeviceCollectionQueryMembershipRuleCommand
【问题讨论】:
标签: powershell powershell-2.0 powershell-3.0 sccm