Skip to content

Instantly share code, notes, and snippets.

@rebrec
rebrec / Watch_MECM_Deployment_For_Device.ps1
Created September 11, 2024 07:24
Monitor MECM Deployment progress for specific device
# Extract Deployment information from MECM (SCCM) through WMI for a specific device.
# Useful to monitor specific devide deployment current progression state or to get some history informations
$ComputerName = "VM-XXX" # computer to find deployment information
$ExecutionTime = '20240327100900.000000+000' # date of the oldest log to extract
$SiteCode = "XYZ"
pushd "$($SiteCode):"
$steps = Get-WmiObject -ComputerName "srv-mecm-01" -Namespace "Root\SMS\site_$SiteCode" -Query "Select * from SMS_TaskSequenceExecutionStatus Where ResourceID='$(get-cmdevice -name $Computername -Fast | select -ExpandProperty ResourceId)' AND ExecutionTime > '$ExecutionTime'" `