I have the following Code - to get all active users in AD (LastlogonTimestamp
within 14 days):
$ADActiveUsers = Get-ADUser -Filter {(employeeType -like "*user*") -and (enabled -eq $true)} -Properties lastlogondate, employeetype, emailaddress |
? { ($_.LastLogonDate -gt (Get-Date).AddDays(-15))} |
Select-Object Name, SAMAccountName, LastLogonDate, employeetype, userprincipalname, emailaddress
Also, I'm trying to get all users that haven't completed their security questions and answers with this query:
$SqlData = Invoke-Sqlcmd -Query "select NT_LGN_TXT from vw6201 where SCU_QUE_CD is Null" -ServerInstance (Server Name) -Database (DB Name)
My need (where I'm stuck) - I'm trying to compare the data from SQL to the AD, create array for the result and send it as e-mail notification.