So, Recently my team and I are working on Integrating AD into another application in our environment. I, however, had to supply a list of GUID’s from Active Directory and return them to the end user to review. Apparently, they bind the existing user’s via GUID to prevent any mix-up and could only supply me their Given and Surname. I threw them in a CSV and used the following Powershell code below to generate the list they wanted.

Remove-Variable * -ErrorAction SilentlyContinue; Remove-Module *; $error.Clear(); Clear-Host
$mytable = Import-Csv -Path "C:\Feed.csv" -Header ID,Data
foreach($r in $mytable)
    if ($r.ID -notlike '#*')

     $Name = $r.Data + ", " + $r.ID.Substring(0,3) + "*"
     #Write-Host $Name
     $User = Get-ADUser -Filter 'Name -like $Name' -Properties Name, objectGUID
     Write-Host $User.Name $User.ObjectGUID
     #Get-ADUser -Filter 'GivenName -like $r.ID'
     #Get-ADUser -Filter *

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see