update-mgpolicyhomerealmdiscoverypolicy ...如何为applyto参数指定对象

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

该命令的语法指定适用于参数应该是这样的:

 <IMicrosoftGraphDirectoryObject[]>

当我尝试此命令时,出现实体集不匹配错误。知道需要为此命令提供什么吗?

有问题的目录对象是一个已注册的应用程序:

[@odata.type, #microsoft.graph.servicePrincipal]

$directoryobject=Get-MgDirectoryObject -DirectoryObjectId 5cacc587-24f4-43a4-9aae-6d59927e7bf9

Update-MgPolicyHomeRealmDiscoveryPolicy -HomeRealmDiscoveryPolicyId 0b4f3006-d531-46db-a239-115752fa41c7 -AppliesTo $directoryobject

更新-MgPolicyHomeRealmDiscoveryPolicy_UpdateExpanded:

 The context URI 'https://graph.microsoft.com/v1.0/$metadata#directoryObjects/$entity' references the entity set with name 'directoryObjects'; however, the name of the expected entity set is 'directoryObjects.appliesTo' and does not match the entity set referenced in the context URI.

我已经尝试了我能想到的所有语法,但这是最接近我遇到的有意义的错误。

谢谢,马丁

powershell graph azure-active-directory
1个回答
0
投票

该错误可能与传递给 -AppliesTo

 命令中的 
Update-MgPolicyHomeRealmDiscoveryPolicy
 参数的输入有关。尝试以下解决方法,使其按预期工作。

不要将

directoryObject
作为字符串传递,而是创建一个包含单个元素
directoryObject
的数组来准确处理输入。

$directoryobject=Get-MgDirectoryObject -DirectoryObjectId xxxxxx
$directoryArray = @($directoryObject)
Update-MgPolicyHomeRealmDiscoveryPolicy -HomeRealmDiscoveryPolicyId 0b4f3006-d531-46db-a239-115752fa41c7 -AppliesTo $directoryArray

确保您已安装图形目录对象模块,没有任何问题。

Install-Module Microsoft.Graph.DirectoryObjects 
Import-Module Microsoft.Graph.DirectoryObjects 
Connect-Mggraph

enter image description here

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