-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCreate-PSOs.ps1
64 lines (59 loc) · 2.05 KB
/
Create-PSOs.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
$PSOs = @(
@{
Name = "PSO_AT0_Administrator";
ComplexityEnabled = $true;
MaxPasswordAge = "120";
MinPasswordAge = "1";
MinPasswordLength = "20";
PasswordHistoryCount = "20";
Precedence = "10";
Appliesto = "PSO_Tier 0 ADM Users_APPLY"
},
@{
Name = "PSO_AT1_Administrator";
ComplexityEnabled = $true;
MaxPasswordAge = "120";
MinPasswordAge = "1";
MinPasswordLength = "20";
PasswordHistoryCount = "20";
Precedence = "20";
Appliesto = "PSO_Tier 1 ADM Users_APPLY"
},
@{
Name = "PSO_AT2_Administrator";
ComplexityEnabled = $true;
MaxPasswordAge = "120";
MinPasswordAge = "1";
MinPasswordLength = "16";
PasswordHistoryCount = "20";
Precedence = "30";
Appliesto = "PSO_Tier 2 ADM Users_APPLY"
},
@{
Name = "PSO_ST0_Service User";
ComplexityEnabled = $true;
MaxPasswordAge = "100000";
MinPasswordAge = "1";
MinPasswordLength = "100";
PasswordHistoryCount = "20";
Precedence = "10";
Appliesto = "PSO_Tier 0 Service Users_APPLY"
},
@{
Name = "PSO_ST1_Service user";
ComplexityEnabled = $true;
MaxPasswordAge = "100000";
MinPasswordAge = "1";
MinPasswordLength = "100";
PasswordHistoryCount = "20";
Precedence = "20";
Appliesto = "PSO_Tier 1 Service Users_APPLY"
}
)
function Create-PSO ($Name, $ComplexityEnabled, $MaxPasswordAge, $MinPasswordAge, $MinPasswordLength, $Precedence) {
New-ADFineGrainedPasswordPolicy -Name $Name -ComplexityEnabled $ComplexityEnabled -MaxPasswordAge $MaxPasswordAge -MinPasswordAge $MinPasswordAge -MinPasswordLength $MinPasswordLength -Precedence $Precedence
}
foreach ($PSO in $PSOs) {
Create-PSO $PSO.Name $PSO.ComplexityEnabled $PSO.MaxPasswordAge $PSO.MinPasswordAge $PSO.MinPasswordLength $PSO.Precedence
Add-ADFineGrainedPasswordPolicySubject -Identity $PSO.Name -Subjects $PSO.Appliesto
}