Get Config Refresh Events from the Event Log
# Define the event log name
$logName = "Microsoft-Windows-DeviceManagement-Enterprise-Diagnostics-Provider/Operational"
# Define the event IDs you want to retrieve
$eventIDs = @(4200, 4201, 4202) + (4203..4214)
# Retrieve the events from the specified log and event IDs
$events = Get-WinEvent -FilterHashtable @{LogName=$logName; Id=$eventIDs}
# Display the retrieved events
$events | Format-List
To determine when the next Config Refresh will take place based on the last successful time (Event ID 4202) plus 30 minutes, you can use the following PowerShell script:
# Define the event log name
$logName = "Microsoft-Windows-DeviceManagement-Enterprise-Diagnostics-Provider/Operational"
# Define the event ID for a successful config refresh
$successEventID = 4202
# Retrieve the most recent successful config refresh event
$lastSuccessEvent = Get-WinEvent -FilterHashtable @{LogName=$logName; Id=$successEventID} -MaxEvents 1
# Check if a successful event was found
if ($lastSuccessEvent) {
# Get the time of the last successful config refresh
$lastSuccessTime = $lastSuccessEvent.TimeCreated
# Calculate the next config refresh time (30 minutes after the last success)
$nextConfigRefreshTime = $lastSuccessTime.AddMinutes(30)
# Display the next config refresh time
Write-Output "The next Config Refresh is expected to take place at: $nextConfigRefreshTime"
} else {
Write-Output "No successful Config Refresh event (Event ID 4202) found."
}