The Set-OSCADAccountPassword function
To display help about the
Set-OSCADAccountPassword function, run the following command:
Get-Help Set-OSCADAccountPassword -Full
![](http://gallery.technet.microsoft.com/scriptcenter/site/view/file/71436/1/image002.png)
Example 02:
How to reset password for specified users.
To reset password for specified users, should put these user’s
SamAccountName in a CSV file, then run the following command:
Set-OSCADAccountPassword -path "c:\Userlist.csv"
Note first, you need to prepare a CSV file,
its format appears as below. One user per line. The “Password” column is optional, if you leave it empty, this command will help you to generate a random password with 10 characters, 7 char are alphanumeric, the rest are NONalphanumeric. Both format A and format B are allowed
SamAccountName
|
Password
|
SamAccountName of user, who should reset password
|
The new password you want to set
|
Format A Format B
B
efore run this command, prepare a CSV file show as below:
![](http://gallery.technet.microsoft.com/scriptcenter/site/view/file/71437/1/image004.png)
Then run the command: Set-OSCADAccountPassword -path "c:\Userlist.csv"
![](http://gallery.technet.microsoft.com/scriptcenter/site/view/file/71438/1/image005.png)
Finally, a CSV file will be created on “C:\”, which contains user SamAccountName and new password.
![](http://i1.gallery.technet.s-msft.com/scriptcenter/reset-password-for-all-412fbc72/image/file/71450/1/image007.png)
Example 03
:
How to reset password for all users in specified OUs and their sub OU
To reset password for all users in specified OUs and their sub OU, run the following command:
Set-OSCADAccountPassword –OrganizationalUnit “testou1”, "testou2" -Recurse
To reset password for all users in specified OUs and their sub OU, run the following command:
Set-OSCADAccountPassword –OrganizationalUnit “testou1”, "testou2" -Recurse
![](http://gallery.technet.microsoft.com/scriptcenter/site/view/file/71442/1/image008.png)
![](http://gallery.technet.microsoft.com/scriptcenter/site/view/file/71443/1/image009.png)
![](http://gallery.technet.microsoft.com/scriptcenter/site/view/file/71444/1/image010.png)
Note AD structure show as below
![](http://gallery.technet.microsoft.com/scriptcenter/site/view/file/71445/1/image011.png)
Example 04:
How to reset password to “P@Ssw0rd” for all users in specified OU, and indicate the path of result CSV file.
To reset password to “P@Ssw0rd” for all users in OU “TestOU” and indicate the path of CSV file to “c:\report\result.csv”, run the following command:
Set-OSCADAccountPassword –OrganizationalUnit “testou" -Password "P@Ssw0rd" –CSVPath “c:\report\result.csv”
Set-OSCADAccountPassword –OrganizationalUnit “testou" -Password "P@Ssw0rd" –CSVPath “c:\report\result.csv”
![](http://gallery.technet.microsoft.com/scriptcenter/site/view/file/71446/1/image012.png)
![](http://gallery.technet.microsoft.com/scriptcenter/site/view/file/71448/1/image013.png)
![](http://gallery.technet.microsoft.com/scriptcenter/site/view/file/71449/1/image014.png)