Ok, I need some help please
I have this code and getting results, however no entry is formatted (meaning if statement is never true)
$today = (Get-Date).AddDays(-1)
$criteria = New-AdmCriteria "user" { (accountDisabled -eq $True) -and (description -contains "DRAFTEE") }
$Context.DirectorySearcher.AddCriteria($criteria)
try {
$searchIterator = $Context.DirectorySearcher.ExecuteSearch()
while ($Context.MoveNext($searchIterator)) {
$startDate = "%adm-CustomAttributeDate1%"
if($startDate -eq $today){
$searchResult = $searchIterator.Current
$textColor1 = "red"
$backgroundColor1 = $null # default
$fontStyle1 = "ADM_LISTITEMFONTSTYLE_BOLD" # bold
$style1 = $Context.Items.CreateItemStyle($textColor1, $backgroundColor1, $fontStyle1)
$Context.Items.Add($searchResult, $style1)
} else {
$searchResult = $searchIterator.Current
$Context.Items.Add($searchResult)
}
}
} finally {
if ($searchIterator) {
$searchIterator.Dispose()
}
}
I tried to extract and convert the date from extensionAttribute3 - but no luck
$startDateString = $searchResult.Properties["extensionAttribute3"].Value
$startDateString = $startDateString.Replace("startdate_","")
$startDate = [Datetime]::ParseExact($startDateString, 'yyyy-MM-dd', $NULL)