-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeek_2_Exercise.ps1
130 lines (125 loc) · 5.11 KB
/
Week_2_Exercise.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
$userData = '[
{
"AccountExpires": null,
"Description": "Built-in account for administering the computer/domain",
"Enabled": true,
"FullName": "",
"PasswordChangeableDate": null,
"PasswordExpires": null,
"UserMayChangePassword": true,
"PasswordRequired": true,
"PasswordLastSet": null,
"LastLogon": "\/Date(1605771872777)\/",
"Name": "Administrator",
"SID": {
"BinaryLength": 28,
"AccountDomainSid": "S-1-5-21-1627568633-850217724-3435047281",
"Value": "S-1-5-21-1627568633-850217724-3435047281-500"
},
"PrincipalSource": 1,
"ObjectClass": "User"
},
{
"AccountExpires": null,
"Description": "A user account managed by the system.",
"Enabled": false,
"FullName": "",
"PasswordChangeableDate": null,
"PasswordExpires": null,
"UserMayChangePassword": true,
"PasswordRequired": false,
"PasswordLastSet": null,
"LastLogon": null,
"Name": "DefaultAccount",
"SID": {
"BinaryLength": 28,
"AccountDomainSid": "S-1-5-21-1627568633-850217724-3435047281",
"Value": "S-1-5-21-1627568633-850217724-3435047281-503"
},
"PrincipalSource": 1,
"ObjectClass": "User"
},
{
"AccountExpires": null,
"Description": "Built-in account for guest access to the computer/domain",
"Enabled": false,
"FullName": "",
"PasswordChangeableDate": null,
"PasswordExpires": null,
"UserMayChangePassword": false,
"PasswordRequired": false,
"PasswordLastSet": null,
"LastLogon": null,
"Name": "Guest",
"SID": {
"BinaryLength": 28,
"AccountDomainSid": "S-1-5-21-1627568633-850217724-3435047281",
"Value": "S-1-5-21-1627568633-850217724-3435047281-501"
},
"PrincipalSource": 1,
"ObjectClass": "User"
},
{
"AccountExpires": null,
"Description": "shared",
"Enabled": false,
"FullName": "shared",
"PasswordChangeableDate": "\/Date(-11644387200000)\/",
"PasswordExpires": null,
"UserMayChangePassword": false,
"PasswordRequired": true,
"PasswordLastSet": null,
"LastLogon": null,
"Name": "shared",
"SID": {
"BinaryLength": 28,
"AccountDomainSid": "S-1-5-21-1627568633-850217724-3435047281",
"Value": "S-1-5-21-1627568633-850217724-3435047281-1002"
},
"PrincipalSource": 1,
"ObjectClass": "User"
},
{
"AccountExpires": null,
"Description": "A user account managed and used by the system for Windows Defender Application Guard scenarios.",
"Enabled": false,
"FullName": "",
"PasswordChangeableDate": "\/Date(1605858056395)\/",
"PasswordExpires": "\/Date(1609400456395)\/",
"UserMayChangePassword": true,
"PasswordRequired": true,
"PasswordLastSet": "\/Date(1605771656395)\/",
"LastLogon": null,
"Name": "WDAGUtilityAccount",
"SID": {
"BinaryLength": 28,
"AccountDomainSid": "S-1-5-21-1627568633-850217724-3435047281",
"Value": "S-1-5-21-1627568633-850217724-3435047281-504"
},
"PrincipalSource": 1,
"ObjectClass": "User"
}
]'
$users = $userData | ConvertFrom-Json
$adminGroup = "Administrator", "Tim Davis"
# Step 1, run lines 1-104 to populate $users with User data (Local User Accounts from a PC)
# and Administrators Group data.
# Using user data, generate a collection of custom user objects with the following properties
# Name
# Enabled (Yes|No)
# PasswordRequired (Yes|No)
# UserCanChangePassword (Yes|No)
# IsAdmin (Yes|No) (Can compare to users in $adminGroup)
# IsBuiltInAdmin (Yes|No)
# One a collection of custom objects have been created, display them by piping to Format-Table
# Results will look like
#
#Name PasswordRequired IsBuiltInAdmin IsAdmin UserMayChangePassword Enabled
#---- ---------------- -------------- ------- --------------------- -------
#Administrator Yes Yes Yes Yes Yes
#DefaultAccount No No No Yes No
#Guest No No No No No
#shared Yes No No No No
#WDAGUtilityAccount Yes No No Yes No
# In this exercise you will use Loops, Conditionals, could potentially use a Function,
# HashTable, as well as creaing an object from a Hashtable, and Lists