Reset Password and Rename User using PowerShell (bulk)

hi guys,

can somebody provide how to reset passwrod and rename user in active directory using powershell in bulk?

July 2nd, 2010 9:03am

Using Quest cmdlets for Active Directory:

 

Get-QADUser user1 | Set-QADUser -UserPassword 'P@ssw0rd' | Rename-QADObject -NewName 'new name'

 

You can download the cmdlets for free here:

http://www.quest.com/powershell/activeroles-server.aspx

Free Windows Admin Tool Kit Click here and download it now
July 2nd, 2010 11:39am

thanks m8,

for the completed task I have to create *.csv with this following header :

  • User
  • Password
  • NewName
then execute this cmdlets :
  • $Users = Import-CSV csvfiles.csv
  • $Users | Foreach {Get-QADuser -Identity $_.User | Set-QADUser -UserPassword | Rename-QADObject -NewName $_.NewName

July 3rd, 2010 1:10pm

Import-CSV csvfiles.csv | Foreach-Object{
    
    $user = Get-QADuser -Identity $_.User
    
    if($user)
    {
        $user | Set-QADUser -UserPassword $_.Password | Rename-QADObject -NewName $_.NewName
    }
    else
    {
        Write-Warning "Can't find user: $($_.User)"
    }
}

Free Windows Admin Tool Kit Click here and download it now
July 3rd, 2010 1:16pm

So I need this to change the password only.

I've modifiled the script it as follows:

$Users = Import-CSV c:\ps_scripts\naconda1.csv

Foreach ($User in $Users)

{

Set-QADUser $User.UPN -UserPassword $user.Password `

-PasswordNeverExpires $true `

-UserMustChangePassword $false `

}

My csv looks like: UserName,UPN,Password "Nocona Test",nocona.test@domain.com,"P4ssw0rd!" The script runs with out returning errors however the password is not changed.  What am I missing?

June 20th, 2011 11:59pm

You have one too many line continuation characters (the backtick, "`"). Remove the backtick from the line:

-UserMustChangePassword $false

 

Free Windows Admin Tool Kit Click here and download it now
June 21st, 2011 1:16am

Removed backtick, no change.  script still runs without error but does not change password.

I have added write $user.password as a test and it does not return the password.

 

Thanks for your assistance.

June 21st, 2011 3:48am

The following worked for me, where my file c:\Scripts\Users.csv is identical to what you specified (with the 3 fields, UserName, UPN, and Password):

 

$Users = Import-CSV c:\Scripts\Users.csv

Foreach ($User in $Users)
{
    $User.UPN
    $User.Password
}

 

Free Windows Admin Tool Kit Click here and download it now
June 21st, 2011 4:43pm

I've tried this format but the script does not run and it does not return to the PS prompt. Its as if the ActiveRoles Management Shell is looking for more input. Here is what I have. 

 

 

Import-CSV c:\Scripts\passwordreset.csv | Foreach-Object{

 

    $user = Get-QADuser -Identity $_.Username 

 

    if($username)

    {

        $username | Set-QADUser -UserPassword $_.Password 

    }

    else

    {

        Write-Warning "Can't find user: $($_.Username)"

    }

}

_________________________________________________________________________________________________________________________

Here is what I get when I run the script. 

[PS] C:\Users\jcochran>Import-CSV c:\Scripts\passwordreset.csv | Foreach-Object{

>>

>>     $user = Get-QADuser -Identity $_.Username

>>

>>     if($username)

>>     {

>>         $username | Set-QADUser -UserPassword $_.Password

>>     }

>>     else

>>     {

>>         Write-Warning "Can't find user: $($_.Username)"

>>     }

>> }


June 29th, 2011 3:58pm

Thats ok I've found what I needed...

 

Thats OK I got what I needed!

[PS] C:\Users\jcochran>Import-Csv c:\scripts\passwordreset.csv | foreach {Set-QADUser -Identity $_.username -UserPasswor

d $_.password -PasswordNeverExpires $true -UserMustChangePassword $false}

Free Windows Admin Tool Kit Click here and download it now
June 29th, 2011 4:47pm

I want to change passwords but do it by OU.  What would the script look like in this case?

thanks 

July 11th, 2011 4:22pm

Hello Kris,

I have a requirement here to set different passwords for different users in a domain and i have formulated a script as below by looking at the content in this page. Am very new to powershell so need assistance. Thankyou for your time

Import-csv C:\Users\m0137533\Desktop\Users1.csv | Foreach-object{get-qaduser -identity ten\$_.id | set-qaduser -userpassword $_.link -PasswordNeverExpires $false -UserMustChangePassword $false}

This command does not return error but returns to the command prompt 

#here ten is the domain of the users

When i go to the Qwest active roles server and look at the change history of a couple of users, i dont find any change summary there.

Please assist here

Free Windows Admin Tool Kit Click here and download it now
September 3rd, 2015 7:05pm

You  are posting to a very old and very closed thread.  Please read the forum posting guidelines and open a new question with your issue, your  script and the complete text of your error message.
September 3rd, 2015 7:22pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics