New SCCM user here, pardon the terminology.
I am trying to get detailed progress messages of a Deployment that deploys a Task sequence, using Powershell. The below command shows the status of the Deployment but I would like to display the status messages from every step of the task sequence.
The Management Console shows this data under
Monitoring->Deployments->Asset Details->Double click a Device -> Click Status tab. The status tab has the following columns. Execution Time, Step, Action Name, Group Name, Last Message Name, Last Message ID, Exit Code, Action Output
Get-CMDeploymentStatus -DeploymentId $depID | Get-CMDeploymentStatusDetails | Where DeviceName -eq $computername
Version: SCCM 1802
I don't think there is a convenient powershell cmdlet for this information however as basically all information in the console comes from the site server via wmi you can just do it the exact same way the console does it.
To find out how it is good to know that there is a logfile "SMSProv.log" that tells you what the console does for every dialog you open. It is located on the site server wherever you installed the ConfigMgr in a subfolder Logs (so default would be %Program Files%\Microsoft Configuration Manager\Logs).
If you check it after opening the status tab as you described it it will show two command lines:
WMI:
SELECT * FROM SMS_TaskSequenceExecutionStatus WHERE AdvertisementID='<DeploymentID>' AND PackageID='<PackageID>' AND ResourceID='<ResourceID>' ORDER BY Step
SQL:
select all __askSequenceExecutionStatus0.ActionName,__askSequenceExecutionStatus0.ActionOutput,__askSequenceExecutionStatus0.AdvertisementID,__askSequenceExecutionStatus0.ExecutionTime,__askSequenceExecutionStatus0.ExitCode,__askSequenceExecutionStatus0.GroupName,__askSequenceExecutionStatus0.LastStatusMsgID,__askSequenceExecutionStatus0.LastStatusMsgName,__askSequenceExecutionStatus0.PackageID,__askSequenceExecutionStatus0.ResourceID,__askSequenceExecutionStatus0.Step from vSMS_TaskSequenceExecutionStatus AS __askSequenceExecutionStatus0 where ((__askSequenceExecutionStatus0.AdvertisementID = '<DeploymentID>' AND __askSequenceExecutionStatus0.PackageID = '<PackageID>') AND __askSequenceExecutionStatus0.ResourceID = '<ResourceID>') order by __askSequenceExecutionStatus0.Step
You can use both to get your information. The general rule is WMI is better in terms of rights management but for complicated things sql can be quite a bit faster. It is also the only possible way if you want to do complex joins with more data and not just the one the console shows. (It also needs more rights as you have to connect to the sccmdb directly to use it)
So in your case it is probably easier to use WMI. So you would use something like:
gwmi -ComputerName <SiteServer>-Namespace 'Root\SMS\site_<SiteCode>' -Query "SELECT * FROM SMS_TaskSequenceExecutionStatus WHERE AdvertisementID='<DeploymentID>' AND PackageID='<PackageID>' AND ResourceID='<ResourceID>' ORDER BY Step"
and then work from there. If you prefer SQL it would be a little bit more complicated (this code produces some sort of csv output but you can of course also produce your own object)
$connStr = "Server=<sccm db server>;Database=<sccm db>;Integrated Security=SSPI"
$SQLConnection = New-Object System.Data.SqlClient.SqlConnection
$SQLConnection.ConnectionString = $connStr
$SQLConnection.Open()
$SQLQuery = "select all __askSequenceExecutionStatus0.ActionName,__askSequenceExecutionStatus0.ActionOutput,__askSequenceExecutionStatus0.AdvertisementID,__askSequenceExecutionStatus0.ExecutionTime,__askSequenceExecutionStatus0.ExitCode,__askSequenceExecutionStatus0.GroupName,__askSequenceExecutionStatus0.LastStatusMsgID,__askSequenceExecutionStatus0.LastStatusMsgName,__askSequenceExecutionStatus0.PackageID,__askSequenceExecutionStatus0.ResourceID,__askSequenceExecutionStatus0.Step from vSMS_TaskSequenceExecutionStatus AS __askSequenceExecutionStatus0 where ((__askSequenceExecutionStatus0.AdvertisementID = @DeploymentID AND __askSequenceExecutionStatus0.PackageID = @PackageID) AND __askSequenceExecutionStatus0.ResourceID = @ResourceID) order by __askSequenceExecutionStatus0.Step"
$SQLCommand = New-Object System.Data.SqlClient.SqlCommand($SQLQuery, $SQLConnection)
[Void]$SQLCommand.Parameters.AddWithValue("@DeploymentID", "<DeplyomentID>")
[Void]$SQLCommand.Parameters.AddWithValue("@PackageID", "<PackageID>")
[Void]$SQLCommand.Parameters.AddWithValue("@ResourceID", "<ResoruceID>")
$reader = $SQLCommand.ExecuteReader()
if ($reader.HasRows) {
while($reader.Read()) {
$line = ""
for ($i=0; $i -lt $reader.FieldCount; $i++) {
$line += $reader[$i].ToString() + ","
}
$line
}
}
$SQLConnection.Close()