Hi
I looking for inspiration och help.
This script fetch user from Active directory.
So far so good,
What I am looking for help with is
-
value from users.txt is the first value in output.csv
Example: Maria,SamAccountName, GivenName, SurName, EmailAddress, Department
and not as it at the moment SamAccountName, GivenName, SurName, EmailAddress, Department -
is it possible to build in a check in case user don’t exist it will add some kind a note in tex output.csv instead of jump over that user.
$txt_location[2] = 'C:\Script\users.txt'
$csv_location[2] = 'C:\Script\output.csv'
Get-Content $txt_location[2] | forEach { Get-ADUser $_ -properties SamAccountName, GivenName, SurName, EmailAddress, Department} | select SamAccountName, GivenName, SurName, EmailAddress, Department | Export-Csv -Path $csv_location[2] -Encoding Default -NoTypeInformation
Inside users.txt contains only SamAccountName (userid)
Maria
Camilla
Peter
Igor
Ivan