I have script below to check the deadline of the updates available in software center```
$TargetedUpdates= Get-WmiObject -ComputerName $system -Namespace root\CCM\ClientSDK -Class CCM_SoftwareUpdate -Filter ComplianceState=0
Foreach ($Update in $TargetedUpdates){
$Object = New-Object PSObject -Property ([ordered]@{
Deadline = [datetime]::ParseExact("$($Update.Deadline.Substring(6,2))/$($Update.Deadline.Substring(4,2))/$($Update.Deadline.Substring(0,4))", "dd/MM/yyyy", $null)
}
$Object
}
I am getting error for some updates as below, though for some updates Its going smooth
You cannot call a method on a null-valued expression.
At line:99 char:71
+ ... = [datetime]::ParseExact("$($Update.Deadline.Substring(6,2))/$($Upd ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Please help