forked from RyanC92/Powershell-Repository
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMass Password change notes.txt
22 lines (10 loc) · 1.11 KB
/
Mass Password change notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Import-csv C:\Csv\MAC_ADDRESS.CSV | ForEach-Object {New-Aduser -GivenName $_.NewGivenName -Name $_.NewName -UserPrincipalName $_.UserPrincipalName -SamAccountName $_.SamAccountName -AccountPassword (ConvertTo-SecureString $_.SamAccountName -AsPlainText -Force ) -CannotChangePassword $True -PasswordNeverExpires $True -DisplayName $_.NewGivenName -enabled $True -passthru}
-Path "OU=Mac Addresses,OU=HQ,DC=Excelsior, DC=Local" -Enabled $True | Enable-AdAccount
Import-csv C:\Csv\Test_Mac.CSV | ForEach-Object {New-Aduser -GivenName $_.NewGivenName -Name $_.NewName -UserPrincipalName $_.UserPrincipalName -SamAccountName $_.SamAccountName -AccountPassword (ConvertTo-SecureString $_.Pass -AsPlainText ) -CannotChangePassword $True -PasswordNeverExpires $True -DisplayName $_.NewGivenName -enabled $True -passthru}
$Users = Import-CSV C:\CSV\TEst_mac.csv
ForEach($User in $users)
{
Get-Aduser $user | Set-AdAccountPassword -Newpassword $password -reset}
Get-ADuser $user | Set-Aduser -ChangePasswordatLogon $False -PasswordNeverExpires $True)
Write-Host "Password has beensreset for the user: $user"
}