Exchange Server TechCenter > Exchange Server Forums > Admin > Powershell help needed - password not being set

Answered Powershell help needed - password not being set

  • Monday, September 08, 2008 2:36 PM
     
     

     

    Hi. I have no doubt done something stupid, but if anyone could be so kind as to point out exactly what...

     

    I am trying to create new users and mailboxes from a csv file. Users and mailboxes are created and they are enabled. There are no error messages. However when I try to login as one of them through OWA I get "username or password incorrect". If I manually reset the password to what I expected it to be, I can then login.

     

    Here's my script:

     

    cat add_users.csv > add_users2.csv # make utf8

    import-csv add_users2.csv | foreach {

    $secureString = ConvertTo-SecureString -string $_.password -AsPlainText –Force

    New-Mailbox -Name $_.displayName -displayName $_.displayName -Alias $_.alias -OrganizationalUnit $_.OU -UserPrincipalName $_.UPN -SamAccountName $_.UID -FirstName $_.givenName -Initials '' -LastName $_.surname -Database $_.MDB -password $secureString -ResetPasswordOnNextLogon $true

    } | out-file -filepath "c:\scripts\add_users.txt" -encoding "UNICODE"

     

    TIA,

     

    Carol

     


     

Answers

  • Tuesday, September 09, 2008 7:01 AM
     
     Answered

    I have solved it myself. It was because of the -ResetPasswordOnNextLogon $true. Apparently I have to have -ResetPasswordOnNextLogon $false.

     

    I was under the impression that OWA was capable of prompting a user to change their password. Guess not.

     

    Carol

     

All Replies

  • Monday, September 08, 2008 6:03 PM
     
     

    Carol,

     

    Try this as the $secureString

     

    $secureString = ConvertTo-SecureString $_.password -asPlainText -force

     

    Regards,

     

    Johan

     

    visit my site: www.johanveldhuis.nl

     

     

  • Tuesday, September 09, 2008 6:41 AM
     
     

    Actually I had already tried that - I only added the "-string" after reading through the get-help. The password is not set either way.

     

    Carol

     

     

  • Tuesday, September 09, 2008 7:00 AM
     
     

    I've solved it myself. It was because of the -ResetPasswordOnNextLogon $true. If I set it to -ResetPasswordOnNextLogon $false then the accounts can be used.

     

    How incredibly stupid. Surely the user should be able to login the first time? I guess I will have to force the password change later.

     

    Carol

     

     

  • Tuesday, September 09, 2008 7:01 AM
     
     Answered

    I have solved it myself. It was because of the -ResetPasswordOnNextLogon $true. Apparently I have to have -ResetPasswordOnNextLogon $false.

     

    I was under the impression that OWA was capable of prompting a user to change their password. Guess not.

     

    Carol