Oct 02 2019
04:21 PM
- last edited on
Apr 08 2022
10:08 AM
by
TechCommunityAP
Oct 02 2019
04:21 PM
- last edited on
Apr 08 2022
10:08 AM
by
TechCommunityAP
I created computer group using powershell cmdlet New-AzOperationalInsightsComputerGroup
-------
$Query = "Heartbeat | where Computer in ('myserver.adx.com') | distinct Computer"
New-AzOperationalInsightsComputerGroup -ResourceGroupName "MyRG" -WorkspaceName "My WN" -SavedSearchId "id12345" -DisplayName "MyDN" -Category "MyCategory" -Query $Query -Version 1
-------
Oct 03 2019 08:11 AM
SolutionHi@Mayank Bansal You can use PowerShell to do ARM template deployment. The resource part in your case will look like this:
{
"name": "[concat(parameters('logAnalyticsWorkspaceName'), '/', 'id12345' )]",
"type": "Microsoft.OperationalInsights/workspaces/savedSearches",
"apiVersion": "2017-03-15-preview",
"tags": {
},
"properties": {
"query": "Heartbeat | where Computer in ('myserver.adx.com') | distinct Computer",
"displayName": "MyDN",
"category": "MyCategory",
"FunctionAlias" : "MyDN",
"Version": 2,
"ETag": "*",
"Tags": [
{
"Name": "Group",
"Value": "Computer"
}
]
}
}
The tags part with name Group and value Computer basically makes the function also Computer group.
Oct 11 2019 01:14 PM
Dec 04 2020 08:04 AM
To assist anyone else arriving from Google/Bing, I'd suggest using the more fully-featured cmdlet New-AzOperationalInsightsSavedSearch to create usable computer groups.
A computer group saved query (e.g. used to target Azure Update Management deployments) needs to be saved both as a Function, and also have a tag of 'Group' with value of 'Computer'.
New-AzOperationalInsightsComputerGroup with -Debug shows it creates the tag, but forgets to add the necessary functionAlias parameter.
$Query = "ComputerGroup | where GroupSource == 'ActiveDirectory' and Group == '$ADGroupName' | distinct Computer"
$Tag = @{
Group = 'Computer'
}
New-AzOperationalInsightsSavedSearch -ResourceGroupName "MyRG" -WorkspaceName "MyWN" -SavedSearchId "id12345" -DisplayName "MyDN" -Category "MyCategory" -Query $Query -FunctionAlias "my_ad_group_name" -Tag $Tag