Working to get all active users in AD (LastlogonTimestamp within 14 days):
That puts the result in Array - $ADActiveUsers
$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
Result Looks like: Name | SamAccountName | LastLogonDate | employeeType | UserPrincipalName | E-mailAddress |
*** SQL Query in Array.
$SqlData = Invoke-Sqlcmd -Query "select NT_LGN_TXT from vw9897 where SCU_QUE_CD is Null" -ServerInstance (Server Name) -Database (DB Name)
Result looks like: SAMAccountName "James.Bond"
***Where i`m stuck: I need to be able to compare the SQL Array Result to the Active Directory Array result and create an Array for that (Email Array)
**End Result - I`m trying to create an E-mail notification from the Email Array (Result)