Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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