Scenario:
You are using MDT 2012 Update 1 (Lite Touch or Zero Touch), you have enabled MDT monitoring and you would like to know the current status of the OSD deployment, but you would like to read directly from the OData feed using PowerShell and maybe get a nice grid-view. Now, you might wonder why and that is easy, basically every blog post I have seen on this topic assumes you are logged on to the server where the MDT Workbench exists, but that is not always the case.
Solution:
Use PowerShell to get the data using the Invoke-RESTMethod, convert and read it as a Grid view
Display on screen in text
Display using grid view:
PowerShell command to execute:
You need to change MDT01 to the name of your deployment server for this to work.
$URL = "http://MDT01:9801/MDTMonitorData/Computers"
function GetMDTData {
$Data = Invoke-RestMethod $URL
foreach($property in ($Data.content.properties) ) {
New-Object PSObject -Property @{
Name = $($property.Name);
PercentComplete = $($property.PercentComplete.’#text’);
Warnings = $($property.Warnings.’#text’);
Errors = $($property.Errors.’#text’);
DeploymentStatus = $(
Switch ($property.DeploymentStatus.’#text’) {
1 { "Active/Running" }
2 { "Failed" }
3 { "Successfully completed" }
Default { "Unknown" }
}
);
StartTime = $($property.StartTime.’#text’) -replace "T"," ";
EndTime = $($property.EndTime.’#text’) -replace "T"," ";
}
}
}
GetMDTData | Select Name, DeploymentStatus, PercentComplete, Warnings, Errors, StartTime, EndTime | Out-GridView
Download script here: http://sdrv.ms/WtxtnU
/mike
Categories: Deployment, MAP, PowerShell, SCCM
That’s awesome, Mike. Thanks a lot.
Check! :-)
Is there any way to get the script to display the currently running step?
This looks really great!
Have to give it a try.
Is there any refresh interval?
No, Grid-View does not have that “feature”, but it is possible to make that work, you just need to use something else then grid-view to display data.
Like how? Outputting the info to a log file to open with cmtrace perhaps?