powershell - Can't output any information about a new user created within script -


i have script create , add user groups in active directory. if tell script create active directory user named 'john smith' using new-aduser cmdlet, can't use get-aduser cmdlet pull information 'john smith' until after script has finished executing. in case, script output 'john smith' created before script terminates show successful creation of user.

by default new-aduser doesn't return information created account. can change using parameter -passthru.

$user = new-aduser ... -passthru 

if need information if account created: use automatic variable $? check if cmdlet ran or not.

new-aduser ... if ($?) {   'account created.' } else {   'account creation failed.' } 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -