I have seen some great responses to questions on this forum and people go into great detail when helping others. With that being said, please bear with me on this. :)
I am working on a project at work where they want me to go through all users in an OU with the "manager" property in the query, match the names for the users to a folder within a SharePoint library. If the folder name matches the User's name in AD, then I use the SamAccountName property to give read permissions to the folder and all subfolders. Some of the subfolders also have to have read permissions for the manager of that person and whatever division directory they have. I am not focused on the director right now, just the rest of it.
If I use the line:
$UserInfo = Get-ADUser -Filter * -SearchBase "ou=MY OU,dc=MyDomain" -properties Manager, Surname, GivenName, Initials, SamAccountname | Select-Object -property Surname, GivenName, Initials, SamAccountName, @{label='Manager';expression={$_.manager -replace '^CN=|,.*$'}}
How would I use this to match the folder name in SharePoint? I am not sure how to use this to get the Surname, Givenname, Initials and match them to the correct folder. The only Powershell scripting that I have done so far has been 3-4 months out of the last year and it has been really small 15-20 line scripts used to create or manage sites and libraries in SharePoint.