次の方法で共有


サンプル クエリ

マネージド マシンから収集された更新プログラムの評価とデプロイ情報のクエリを開始するのに役立つ、いくつかのサンプル クエリを次に示します。 更新プログラムの評価やインストールなどの操作から作成されたログの詳細については、「クエリ ログの概要」を参照してください。

更新プログラムのカテゴリ別にグループ化されたすべてのマシンで使用可能な OS 更新プログラムを一覧表示する

次のクエリは、評価が実行された時刻、評価のリソース ID、マシン上の OS の種類、および更新の分類に基づいて利用可能な OS 更新プログラムを含む、マシンの保留中の更新プログラムの一覧を返します。

patchassessmentresources
| where type !has "softwarepatches"
| extend prop = parse_json(properties)
| extend lastTime = properties.lastModifiedDateTime
| extend updateRollupCount = prop.availablePatchCountByClassification.updateRollup, featurePackCount = prop.availablePatchCountByClassification.featurePack, servicePackCount = prop.availablePatchCountByClassification.servicePack, definitionCount = prop.availablePatchCountByClassification.definition, securityCount = prop.availablePatchCountByClassification.security, criticalCount = prop.availablePatchCountByClassification.critical, updatesCount = prop.availablePatchCountByClassification.updates, toolsCount = prop.availablePatchCountByClassification.tools, otherCount = prop.availablePatchCountByClassification.other, OS = prop.osType
| project lastTime, id, OS, updateRollupCount, featurePackCount, servicePackCount, definitionCount, securityCount, criticalCount, updatesCount, toolsCount, otherCount

更新プログラムのインストールの数

次のクエリは、更新プログラムのインストールの一覧を過去 7 日間のマシンの状態とともに返します。 結果には、更新プログラムのデプロイが実行された時刻、インストールのリソース ID、マシンの詳細、インストールされている OS 更新プログラムの数が、その状態と選択内容に基づいて示されます。

patchinstallationresources
| where type !has "softwarepatches"
| extend machineName = tostring(split(id, "/", 8)), resourceType = tostring(split(type, "/", 0)), tostring(rgName = split(id, "/", 4))
| extend prop = parse_json(properties)
| extend lTime = todatetime(prop.lastModifiedDateTime), OS = tostring(prop.osType), installedPatchCount = tostring(prop.installedPatchCount), failedPatchCount = tostring(prop.failedPatchCount), pendingPatchCount = tostring(prop.pendingPatchCount), excludedPatchCount = tostring(prop.excludedPatchCount), notSelectedPatchCount = tostring(prop.notSelectedPatchCount)
| where lTime > ago(7d)
| project lTime, RunID=name,machineName, rgName, resourceType, OS, installedPatchCount, failedPatchCount, pendingPatchCount, excludedPatchCount, notSelectedPatchCount

Windows Server OS 更新プログラムのインストールの一覧

次のクエリは、Windows Server の更新プログラムのインストールの一覧と、過去 7 日間のマシンの状態を返します。 結果には、更新プログラムのデプロイが実行された時刻、インストールのリソース ID、マシンの詳細、およびその他の関連するデプロイの詳細が含まれます。

patchinstallationresources
| where type has "softwarepatches" and isnull(properties.version)
| extend machineName = tostring(split(id, "/", 8)), resourceType = tostring(split(type, "/", 0)), tostring(rgName = split(id, "/", 4)), tostring(RunID = split(id, "/", 10))
| extend prop = parse_json(properties)
| extend lTime = todatetime(prop.lastModifiedDateTime), patchName = tostring(prop.patchName), kbId = tostring(prop.kbId), installationState = tostring(prop.installationState), classifications = tostring(prop.classifications)
| where lTime > ago(7d)
| project lTime, RunID, machineName, rgName, resourceType, patchName, kbId, classifications, installationState
| sort by RunID

Linux OS 更新プログラムのインストールの一覧

次のクエリでは、Linux の更新プログラムのインストールの一覧と、過去 7 日間のマシンの状態が返されます。 結果には、更新プログラムのデプロイが実行された時刻、インストールのリソース ID、マシンの詳細、およびその他の関連するデプロイの詳細が含まれます。

patchinstallationresources
| where type has "softwarepatches" and isnotnull(properties.version) and isnull(properties.kbId)
| extend machineName = tostring(split(id, "/", 8)), resourceType = tostring(split(type, "/", 0)), tostring(rgName = split(id, "/", 4)), tostring(RunID = split(id, "/", 10))
| extend prop = parse_json(properties)
| extend lTime = todatetime(prop.lastModifiedDateTime), patchName = tostring(prop.patchName), version = tostring(prop.version), installationState = tostring(prop.installationState), classifications = tostring(prop.classifications)
| where lTime > ago(7d)
| project lTime, RunID, machineName, rgName, resourceType, patchName, version, classifications, installationState
| sort by RunID

VM レベルでのメンテナンス実行レコードの一覧

次のクエリは、VM のすべてのメンテナンス実行レコードの一覧を返します

maintenanceresources 
| where ['id'] contains "/subscriptions/<subscription-id>/resourcegroups/<resource-group>/providers/microsoft.compute/virtualmachines/<vm-name>" //VM Id here
| where ['type'] == "microsoft.maintenance/applyupdates" 
| where properties.maintenanceScope == "InGuestPatch"

次のステップ