Trying to determine if AD accounts have been modified in the last 2 hours.
If I manually do a Get-ADUser and then compare $ObjDelta = ((Get-Date) - ($i.Modified)) I can successfully check the "Hours" value.
Days : 0 Hours : 2 Minutes : 45 Seconds : 10 Milliseconds : 321 Ticks : 99103217697 TotalDays : 0.114702798260417 TotalHours : 2.75286715825 TotalMinutes : 165.172029495 TotalSeconds : 9910.3217697 TotalMilliseconds : 9910321.7697
Yet when I put it in a script with
$Output = Foreach ($i in $Imported) {
$ObjDelta = ((Get-Date) - ($i.Modified))
If ($ObjDelta.Hours -gt "1") {
<Do things here>
}
I get a running error on each $i of
Multiple ambiguous overloads found for "op_Subtraction" and the argument count: "2". At line:1 char:1
- $ObjDelta = ((Get-Date) - ($i.Modified))
CategoryInfo : NotSpecified: (:) [], MethodException FullyQualifiedErrorId : MethodCountCouldNotFindBest
I have confirmed that the "Modified" value is populated on these accounts.
Any thoughts?
The second argument can be [timespan] or [datetime]: