Hello! I am trying to make a script I can quickly reference to pull some basic information for different users in our environment. I am running into an issue when I call the script and their are multiple people with the same First and Last Name. I call the function with, “.\MyFunction.ps1 John Smith”. Below in the code, when it my original ADUser query returns information in the 2 users, I am having trouble separating them, and putting them into their own location in the array, respectively. I marked the array of code below with ##.
This way it wouldn’t matter if someone like to provide the name as “John Smith” or “Smith, John”. If you do not provide a name at all you will be prompted for. … and because it is a function you can add it to your profile or a module and you don’t have to load the script file.
Thanks a ton, Olaf! How would you change this to allow for multiple users being entered in? Say I have a list of users from department “A” and I want all this info for each user to be outputted. I ask because I originally made this script with the FirstName and LastName params, but I wasn’t sure how to adapt it for scalability, other than specifying FullName.
I wouldn’t. Since combination of first name and last name is not sufficient to uniquely identify someone I would require them to provide a unique attribute. That could be the sAMAccountName, the UserPrincipalName, the email address or an employee number if your company uses something like this. With this I would create another function for that purpose.
That’s not my point actually. I meant that when another department asks for some information about other employees you should provide you should make sure that you do not give away information they actually did not ask for and they’re maybe not supposed to get.