Tag Archives: ConfigMgr

Script Status Message queries!

If, like me, you spend more than your fair share of time searching through status messages to figure out what broke in the deployment over the weekend, then you’ll know what an arduous process it can be putting the criteria into each query. If you have a good few machines to check then you literally spend half your time typing in machine names and times.

Well no more, because did you know it is perfectly possibly to script this? Status Message Viewer (statview.exe) is simply an executable and with the right parameters and the correct time format applied, you can simply call the status messages from as many machines as you see fit (although I’d recommend you limit this to no more than 15-20 at a time).

One observation when running this against multiple machines is that you’ll notice some of the status messages won’t always contain as much info as you expect – simply refresh the status message and all info will display as expected.

Finally, create a text file containing a list of the machines you wish to take status messages from and use the path as a parameter along with the date from which you wish to obtain the messages, in the format YYYY-MM-DD.

Please note this script assumes you have installed the ConfigMgr admin console on the machine on which you run the script, and in the default location. If you have installed it elsewhere please change statview.exe path accordingly.

Param(
 [string]$path,
 [string]$date
 )
If($date -eq "" -or $path -eq "") 
 { 
     Write-Host "File path and date must be supplied as a parameters.
     Example: 
     -path C:\Temp\Computers.txt
     -date 2021-04-09"
     exit
 } 
$command = "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\i386\statview.exe"
$siteServer = "SCCMSiteSvr.contoso.com"
$startDate = Get-Date -Format "yyyyMMddHH:mmm.000" -Date $date
$Computers = Get-Content $path
foreach($compName in $Computers)
{
    $commandArgs = "/SMS:Server=\\$siteServer\ /SMS:SYSTEM=$compName /SMS:COMPONENT=Task Sequence Engine /SMS:COMPONENT=Task Sequence Action /SMS:SEVERITY=ERROR /SMS:SEVERITY=WARNING /SMS:SEVERITY=INFORMATION /SMSSTARTTIME=$startDate"
    & "$command" $commandArgs
} 

in-line script execution time-out…

Had this recently on a machine we were upgrading to Win 10 1909. Initially it looked as though there was an issue detecting the application being installed correctly but on closer inspection, the AppDiscovery log file revealed that the same timeout issue was happening on several applications. Googling about there were quite a few posts on how later versions on ConfigMgr now incorporated a client property to change the script timeout setting but this sadly appeared not to be the case. Other posts suggested a script that could be run at server level to fix this. Not really the short-term fix I needed to sort my issue as it would doubtless take weeks to get the change through at work.

Then I found what I needed – a client-side script which I have now lost the source to, so really sorry if this came from you. I’m happy to set the record straight and link as needed. In any case, I do have the script itself, see below. This wil set the timeout to 1200 seconds (from the 60s default). This fixed my issue. I would imagine this could be added to the start of a task sequence if required. Note it’s a VBScript…old skool.

On Error Resume Next
strQuery = "SELECT * FROM CCM_ConfigurationManagementClientConfig"
Set objWMIService = GetObject("winmgmts:\\" & "." & "\ROOT\ccm\Policy\Machine\ActualConfig")
Set colItems = objWMIService.ExecQuery(strQuery, "WQL")
For Each objItem in colItems
objItem.ScriptExecutionTimeOut=1200
objItem.put_()
Next

Set objWMIService = GetObject("winmgmts:\\" & "." & "\ROOT\ccm\Policy\Machine\ActualConfig")
Set colItems = objWMIService.ExecQuery(strQuery, "WQL")
For Each objItem in colItems
If 1200 = objItem.ScriptExecutionTimeOut Then
WScript.Echo "True"
Else
WScript.Echo "False"
End if
Next 

Phased deployments not deploying

AKA…

Exception: System.ArgumentNullException: Value cannot be null.
Parameter name: objectID
at Microsoft.ConfigurationManager.PhasedDeployment.Application.Deploy(IDatabaseOperation databaseOperation, List`1 phases, String phasedDeploymentID, String objectID)
at Microsoft.ConfigurationManager.PhasedDeployment.PODRuleEngine.EvaluatePhasedDeployments(SqlConnection connection)

I was testing a phased deployment the other day and couldn’t get it to work for the life of me. Although the phased deployment appeared under the Phased Deployments tab for the Office 365 application I was targeting, a corresponding deployment didn’t appear for the phase 1 collection under the Deployments tab.

I took a look at the SMS_PhasedDeployments.log on the site server and all I could see was the error message above. I would also see it repeat about every 2 minutes as below.

It kept mentioning there were two phased deployments it was trying to evaluate, but there were no other phased deployments set. There is a well-known bug when a task sequence can get locked and the admin will typically go into the db and remove the offending ID locking the task sequence from the database. Well it turns out this is a similar issue with an equally similar solution.

SOLUTION:

  1. Go into the ConfigMgr (sorry, Endpoint Manager!) DB and find dbo.PhasedDeployment, right-click the table and click Select Top 1000 rows.
  2. Identify the offending Phased Deployment from the list and copy the PhasedDeploymentID.
  3. Click New Query from the toolbar and type:

DELETE FROM dbo.PhasedDeployment WHERE PhasedDeploymentID='<PhasedDeploymentID>'

I would be inclined to delete and recreate your original phased deployment (from the console!) to be sure of a clean deployment but technically you be good from here on.