-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Reset-ADUserPassword.ps1
35 lines (30 loc) · 1.04 KB
/
Reset-ADUserPassword.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function Reset-ADUserPassword {
<#
.SYNOPSIS
Reset a user's password in Active Directory.
.DESCRIPTION
Quick function for resetting a user's password in Active Directory to be changed immediately.
.PARAMETER Identity
The user account to reset
.EXAMPLE
Reset-ADUserPassword brett.miller
.NOTES
This is insecure but a quick way to reset a password for an immediate user change.
#>
[CmdletBinding()]
Param (
[Parameter(Mandatory=$true,
Position=0,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)]
[ValidateNotNull()]
[ValidateNotNullOrEmpty()]
[string[]]$Identity
)
process {
foreach ($user in $Identity) {
Set-ADAccountPassword -Identity $user -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "Pa55word1!" -Force) -Credential $creds
Set-ADUser -Identity $user -ChangePasswordAtLogon $true -Credential $creds
}
}
}