-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathReset-SmartCardPassword
More file actions
35 lines (25 loc) · 1.06 KB
/
Reset-SmartCardPassword
File metadata and controls
35 lines (25 loc) · 1.06 KB
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-SmartCardPassword {
<#
.SYNOPSIS
Flips the "Smart card is required for interactive logon" account setting in order to generate a new random password for each user.
Author: Chris Campbell (@obscuresec)
License: BSD 3-Clause
Required Dependencies: ActiveDirectory
Optional Dependencies: None
.EXAMPLE
Reset-SmartCardPassword
.LINK
http://www.obscuresec.com/
#>
#Import AD Module
Import-Module ActiveDirectory
#Create an array of all accounts that have smart card logon enforced
$ADUsers = (Get-AdUser -Filter * -Properties 'SmartcardLogonRequired' | Where-Object {($_.SmartcardLogonRequired)}).SamAccountName
if ($ADUsers -eq $null) {Write-Error "No Accounts Require Smart Cards for logon"}
#Iterate through each account that has the setting enabled and toggle
ForEach ($User in $ADUsers) {
Get-AdUser -Identity $($User) | Set-AdUser -SmartcardLogonRequired $False
Start-Sleep 1
Get-AdUser -Identity $($User) | Set-AdUser -SmartcardLogonRequired $True
}
}