Hi Scripting Guys,
I have a powershell script that allows me to query a list of users against AD, and if they exist, it will write their details into a new file.
I want to adapt this script so that it will still do the same, but if the user does NOT exist anymore, write a line such as "<User-ID> does not exist in AD".
Here's the code I have so far:
Import-Module ActiveDirectory
$UserList = get-content C:\temp\checkAD\Accounts.txt
Foreach ($Item in $UserList) {
Get-aduser -filter {samAccountName -eq $Item} | Out-File C:\temp\checkAD\existingAccounts.txt -encoding default -append
}Does anybody know how to achieve that?
Thanks and best regards,
Cap'