Skip to content

Instantly share code, notes, and snippets.

@alexmags
Created February 26, 2021 08:14
Show Gist options
  • Save alexmags/a918b606a25393c89129526dbe66ec7d to your computer and use it in GitHub Desktop.
Save alexmags/a918b606a25393c89129526dbe66ec7d to your computer and use it in GitHub Desktop.
Auto configure Git user name and email based on Active Directory lookup
# Auto configure Git user name and email based on Active Directory lookup
[reflection.assembly]::LoadWithPartialName("System.DirectoryServices.AccountManagement") | out-null
$currentUser=[System.DirectoryServices.AccountManagement.UserPrincipal]::Current
& git.exe config --global user.name "$($currentUser.DisplayName)"
& git.exe config --global user.email $($currentUser.EmailAddress)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment