Repository navigation
Expand file tree
/
Copy pathReportingUsersData.ps1
More file actions
70 lines (66 loc) · 2.23 KB
/
Copy pathReportingUsersData.ps1
File metadata and controls
70 lines (66 loc) · 2.23 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
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
$users = @(
"1000935@gianteagle.com",
"1003034@gianteagle.com",
"1097654@gianteagle.com",
"1161641@gianteagle.com",
"1174374@gianteagle.com",
"1000837@gianteagle.com",
"margaret.allison@gianteagle.com",
"john.adams@gianteagle.com",
"tim.baker@gianteagle.com",
"lisa.clark@gianteagle.com",
"paul.davis@gianteagle.com",
"sarah.evans@gianteagle.com",
"nancy.foster@gianteagle.com",
"luis.gomez@gianteagle.com",
"julie.harris@gianteagle.com",
"keith.irwin@gianteagle.com",
"laura.jackson@gianteagle.com",
"robert.kelly@gianteagle.com",
"ana.lopez@gianteagle.com",
"sophia.martinez@gianteagle.com",
"charles.nelson@gianteagle.com",
"maria.owens@gianteagle.com",
"david.perez@gianteagle.com",
"emma.quinn@gianteagle.com",
"brian.reed@gianteagle.com",
"olivia.smith@gianteagle.com",
"daniel.taylor@gianteagle.com",
"zoe.underwood@gianteagle.com",
"eric.vargas@gianteagle.com",
"helen.white@gianteagle.com",
"mark.young@gianteagle.com",
"chloe.zimmer@gianteagle.com"
)
# report users AD data
$results = foreach ($user in $users) {
$adUser = Get-ADUser -Filter "UserPrincipalName -eq '$user'" -Properties samaccountname, emailaddress, Title, Department, employeeType, whenChanged, whenCreated
$samaccountname = $adUser.samaccountname
$email = $adUser.emailaddress
$title = $adUser.Title
$department = $adUser.Department
$employeeType = $adUser.employeeType
$whenChanged = $adUser.whenChanged
$whenCreated = $adUser.whenCreated
[PSCustomObject]@{
UserPrincipalName = $user
SamAccountName = $samaccountname
Email = $email
Title = $title
Department = $department
EmployeeType = $employeeType
WhenChanged = $whenChanged
WhenCreated = $whenCreated
}
}
foreach ($user in $users) {
Set-ADUser -Identity $user -PasswordNeverExpires $false
}
foreach ($user in $users) {
$user = Get-AzureADUser -ObjectId $user
Set-AzureADUser -ObjectId $user.ObjectId -PasswordPolicies "None"
}
# export report to CSV
$exportPath = "C:\temp\UsersPassPol.csv"
$results | Export-Csv -Path $exportPath -NoTypeInformation
Write-Host "Exported CSV file path: $exportPath"