Hi,
I am trying to write a basic script/function to create a new user in AD, i want some of the information to be pre populated and some to be input by the admin who uses the script. Here it is.
Script foe New user.
Function newaduser {
Param (
$name,
$dispname,
$desc,
$title,
$depar,
$SamName
)
New-aduser -Name $name -DisplayName $dispname -SamAccountName $SamName -Description $desc -Office “Office” -Company “Company” UK -City “City” -State “State”
-PostalCode “Post Code”
}
So the variables i want to be prompted for are those defined in the Param section. I know there are ways to get text on screen with Write-Output. If i run the script nothing happens. If i call the function newaduser and run it with -whatif it complains that the first variable $name is empty. This is good as i want it to prompt for the users name. Can i create my own message to say, “Please input users name” rather than the error message?
Sorry if my technical terms aren’t correct, still new to all this and learning the ropes.
Cheers,
Jay