Skip to content

Instantly share code, notes, and snippets.

@bobfrankly
Created April 18, 2018 22:41
Show Gist options
  • Save bobfrankly/76212ed202481142b7a25c6e5688c080 to your computer and use it in GitHub Desktop.
Save bobfrankly/76212ed202481142b7a25c6e5688c080 to your computer and use it in GitHub Desktop.
Star Wars Name Generator in Powershell for use against AD
function Get-StarWarsName
{
[cmdletbinding()]
param
(
$user
)
# Get user
try { $foundUser = Get-ADuser $user -properties title }
catch { throw "$user not found or other AD error" ; break}
$leadf = $foundUser.surname.substring(0,3)
$tailf = $foundUser.givenname.substring(0,2)
$leadl = $foundUser.givenname.substring($foundUser.givenname.length - 3,2)
$taill = $founduser.title.substring($foundUser.givenname.length - 3,3)
Return "Your Star Wars Name is " + $leadf + $tailf + " " + $leadl + $taill
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment