Created
April 18, 2018 22:41
-
-
Save bobfrankly/76212ed202481142b7a25c6e5688c080 to your computer and use it in GitHub Desktop.
Star Wars Name Generator in Powershell for use against AD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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