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.' }