SCCM - PowerShell:所有系统集合不可用

SCCM - PowerShell:所有系统集合不可用

我尝试使用 cmdlet“Import-CMComputerInformation”将计算机导入 SCCM (https://technet.microsoft.com/en-us/library/jj821991(v=sc.20).aspx), 使用

Import-CMComputerInformation -CollectionName "All Systems" -ComputerName "Computer1" -MacAddress "FA:FA:FA:FA:FA:FA"

也尝试过

Import-CMComputerInformation -ComputerName "Computer1" -MacAddress "FA:FA:FA:FA:FA:FA"

但是我得到了这个错误

Import-CMComputerInformation : No object corresponds to the specified parameters.
At line:1 char:1
+ Import-CMComputerInformation -ComputerName "Computer1" -MacAddress "FA:FA:FA:FA:FA:FA"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Confi...ormationCommand:ImportComputerInformationCommand) [Import-CMComputerInformation], ItemNotFoundException
    + FullyQualifiedErrorId : ItemNotFound,Microsoft.ConfigurationManagement.Cmdlets.Oob.Commands.ImportComputerInformationCommand

此命令也没有输出:

Get-CMDeviceCollection -Name "All Systems"

我可以查询某些其他集合(我们的 IT 部门是分部门的,您没有权限查看所有内容)。如果我尝试使用 SCCM 控制台添加计算机,我可以将计算机导入到“所有系统”,但如果我搜索“所有系统”集合,也找不到它。

使用 WMI,与此类似:

#New computer account information
$WMIConnection = ([WMIClass]"\\SERVER100\root\SMS\Site_PRI:SMS_Site")
    $NewEntry = $WMIConnection.psbase.GetMethodParameters("ImportMachineEntry")
    $NewEntry.MACAddress = $MACAddress
    $NewEntry.NetbiosName = $ResourceName
    $NewEntry.OverwriteExistingRecord = $True
$Resource = $WMIConnection.psbase.InvokeMethod("ImportMachineEntry",$NewEntry,$null)

我可以导入它。

导入后,PC 似乎会移动到某些集合,由规则定义。

有没有办法使用 Import-CMComputerInformation 命令?如果已经有一个非常好的 cmdlet,那么编写自己的函数似乎有点愚蠢。我也不想将其直接写入某个集合,因为这些规则可能会改变,而且应该可以将其导入到所有系统。

SCCM 由中央 IT 管理,而我们是分散的,并使用他们的基础设施(在本例中)。这意味着我们没有 SCCM 的完全访问权限。我们想要一种更自动化的方式来导入计算机,而他们不会调整他们的导入工具来接受命令行参数,所以我决定编写自己的导入工具。

编辑,详细输出:

PS L01:\> Import-CMComputerInformation -ComputerName $pcName -MacAddress $macAddress -Verbose
Import-CMComputerInformation : No object corresponds to the specified parameters.
At line:1 char:1
+ Import-CMComputerInformation -ComputerName $pcName -MacAddress $macAddress -Verb ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Confi...ormationCommand:ImportComputerInformationCommand) [Import-CMComputerInformation], ItemNotFoundException
    + FullyQualifiedErrorId : ItemNotFound,Microsoft.ConfigurationManagement.Cmdlets.Oob.Commands.ImportComputerInformationCommand


PS L01:\> $macAddress
98:90:96:AE:64:97

PS L01:\> $pcName
SET-D-DI-00804

答案1

首先,上面所有的 PowerShell 行工作没有问题。我能想到的唯一原因是你说:“我们的 IT 部门是分开的,你没有对所有事情的权限”。所以这可能是你的权限问题。你可以在控制台中工作并不意味着你可以通过 PowerShell 来做,需要不同的权限。一种测试方法是通过完整的管理员帐户进行。

其次,Import-CMComputerInformation 命令使用起来没有问题。需要注意的是,运行该命令后,设备信息将首先导入到设备中,但不会导入到所有系统或您在命令中指定的任何其他集合中。在评估集合成员身份后,它将出现在所有系统和任何其他集合中。只需在网上搜索,您就会找到解决这个问题的方法。

因此,我建议您可以与中央 IT 部门联系,并请他授予您适当的权限来执行您应该能够执行的操作,包括您在此处询问的这个问题。

相关内容