Skip to content

Instantly share code, notes, and snippets.

@gislig
Created August 2, 2018 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gislig/985fff968096f3c655b1aba9e7e61660 to your computer and use it in GitHub Desktop.
Save gislig/985fff968096f3c655b1aba9e7e61660 to your computer and use it in GitHub Desktop.
#Function that contains some default values and some $null values.
function CreateUser($SamAccountName, [string]$UPN = "domain.local", [bool]$Enabled = $True, $FirstName, $LastName){
New-ADUser -SamAccountName $SamAccountName -UserPrinciplalName "$SamAccountName@$UPN" -Enabled $Enabled -FirstName $FirstName -SurName $LastName
}
#Creating a user with out the dfeaults
CreateUser -SamAccountName "Bob" -UPN "bob.com" -Enabled $False -FirstName "Bob" -LastName "Builder"
#Creating a user with the defaults
CreateUser -SamAccountName "Hugi" -FirstName "Hugi" -LastName "Freyr"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment