No announcement yet.

problem with powershell script

  • Filter
  • Time
  • Show
Clear All
new posts

  • problem with powershell script

    hello ,

    im MCITP student and i have problem with my finall project.
    i need to make 200 users in AD so i decide to make it with power shell commands in a script , this is the script i use.
    Import-Csv c:\users.csv | foreach-object { 
    $userprinicpalname = $_.SamAccountName + "" 
    New-ADUser -SamAccountName $_.SamAccountName -UserPrincipalName $userprinicpalname -Name $ -DisplayName $ -GivenName $_.GivenName -SurName $_.SurName -Manager $_.Manager -Department $_.Department -Path "OU=Sales,DC=contoso,DC=com" -AccountPassword (ConvertTo-SecureString "Pa$$w0rd;" -AsPlainText -force) -Enabled $True -PassThru }
    i managed to crate the users in AD but when i try to log in with any of those users it didnt work its just sais "the user name or password incorrect" , but when i made one user manual (without the script) it works and i can log in with the user.

    can anyone advice me what should i do with the script or how to fix it.

    i tried to run this script on Windows server 2008R2 + Windows 7 attached to the domain.
    both virtual machines run on Hyper - V.

    tnx in advance.
    Last edited by Rems; 15th December 2012, 23:46.

  • #2
    Re: problem with powershell script

    What are you using for your password when you attempt to logon??

    My reckoning it should be this Pa$$w0rd;

    What happens if you reset the password to somethind different on a user account and retry??

    Try reading this,2-236.html


    • #3
      Re: problem with powershell script

      Powershell does not like the dollar signs in the password string. You can try replacing the doublequote signs around the string to singe ones.

      -accountPassword (ConvertTo-SecureString 'Pa$$w0rd;' -AsPlainText -Force)


      Similar Thread:
      Last edited by Rems; 9th May 2013, 20:46.

      This posting is provided "AS IS" with no warranties, and confers no rights.


      ** Remember to give credit where credit's due **
      and leave Reputation Points for meaningful posts