通过设备ID进行Get-azureaddevice过滤
我有一个Azure DeviceID的列表,并希望使用PowerShell命令删除-AsureadDevice删除它们,但是我只能通过设备的objectID删除它们。 因此,我现在的问题是我将匹配的objectid降低到deviceids的位置? 我只是得到这个错误消息
$csv = Import-Csv "C:\powershell\restazure.csv"
foreach($item in $csv){
$removeThisDevices = Get-AzureAdDevice -Filter "deviceId eq $item.ID"
}
消息:语法错误:字符'{'在位置13中无效 'DeviceID EQ @{ID = 445925F3-C35B-40AF-B5D4-1F71DEE08A39} .id'。
I have a list of Azure DeviceIDs and want to delete them with the Powershell command Remove-AzureADDevice, but i can only delete them by the ObjectID of a device.
so my question now is where i get the matching objectIDs to the DeviceIDs?
I'm just getting this Error-Message
$csv = Import-Csv "C:\powershell\restazure.csv"
foreach($item in $csv){
$removeThisDevices = Get-AzureAdDevice -Filter "deviceId eq $item.ID"
}
Message: Syntax error: character '{' is not valid at position 13 in
'deviceId eq @{ID=445925f3-c35b-40af-b5d4-1f71dee08a39}.ID'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
昨天这让我发疯。如果您查看错误,它将抱怨类型不匹配。 DeviceID是GUID。
我没有运气使用GUID键入变量:
这项工作:
感谢Github上的Klikr发布解决方案和链接以帮助文件,这似乎阐明了很多事情: https://github.com/azure/azure/azure-docs-powershell-azuread/shell-azuread/isshell-azuread/issues/issues/216#issuecomment-63333322 < /a>
帮助文件: https://www.powershellgallery.com/packages/azureadpreview/2.0.0.52/content/content/it%5cmicrosoft.azuread.azuread16.graph.graph.powershell.powershell.dll-hell.dll-hellp.xmll
ninl klikrikr: -p,我将在本周末阅读一些ODATA文档,以便我更好地理解所有这些文档。我发现自己写更多的自动化,需要Azure Err Entra数据,因此,如果我只知道并且不必搜索和玩耍就可以弄清楚某些事情,那就太好了。很棒的是他们具有铸造功能。
This was driving me crazy yesterday. If you look at the error it will complain about the type mismatch. DeviceID is a GUID.
I had no luck using a GUID typed variable:
This works:
Thank klikr on GitHub for posting the solution and link to help file which seems to spell out quite a few things: https://github.com/Azure/azure-docs-powershell-azuread/issues/216#issuecomment-633943632
Help file: https://www.powershellgallery.com/packages/AzureADPreview/2.0.0.52/Content/it%5CMicrosoft.Open.AzureAD16.Graph.PowerShell.dll-Help.xml
Unlike klikr :-P, I'll be reading some OData documentation this weekend so I can better understand all this. I'm finding myself writing more automation which requires Azure err Entra data, so it'd be nice if I just knew and didn't have to search and play around to figure certain things out. Great that they have casting functionality though.
请尝试
Please try this