-
Notifications
You must be signed in to change notification settings - Fork 39
/
Get-EmployeeInfo.ps1
98 lines (79 loc) · 3.18 KB
/
Get-EmployeeInfo.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
Function Get-EmployeeInfo {
<#
.Synopsis
Returns a customized list of Active Directory account information for a single user
.Description
Returns a customized list of Active Directory account information for a single user.
The customized list is a combination of the fields that are most commonly needed to review
when an employee calls the helpdesk for assistance.
.Example
Get-EmployeeInfo Tom_Brady
Returns a customized list of AD account information for user account named Tom_Brady
PS C:\Scripts> Get-EmployeeInfo Michael_Kanakos
FirstName : Tom
LastName : Brady
Title : Server Engineer
Department : Strategic Server Solutions
Manager : Bill_Belichick
City : Cary
EmployeeID : 123456
UserName : Tom_Brady
DisplayNme : Brady, Tom
EmailAddress : [email protected]
OfficePhone : +1 919-555-1212
MobilePhone : +1 631-555-1212
PasswordExpired : False
AccountLockedOut : False
LockOutTime : 0
AccountEnabled : True
AccountExpirationDate :
PasswordLastSet : 3/26/2018 9:29:02 AM
PasswordExpireDate : 9/28/2018 9:29:02 AM
.Parameter UserName
The employee account to lookup in Active Directory
.Notes
NAME: Add-EmployeeInfo.ps1
AUTHOR: Mike Kanakos
VERSION: 1.0.3
DateCreated: 2018-04-10
DateUpdated: 2019-01-15
v 1.0.3 - update help file formatting
.Link
https://github.com/compwiz32/PowerShell
#>
[CmdletBinding()]
Param(
[Parameter(Mandatory = $True, Position = 1)]
[string]$UserName
)
#Import AD Module
Import-Module ActiveDirectory
$Employee = Get-ADuser $UserName -Properties *, 'msDS-UserPasswordExpiryTimeComputed'
$Manager = ((Get-ADUser $Employee.manager).samaccountname)
$PasswordExpiry = [datetime]::FromFileTime($Employee.'msDS-UserPasswordExpiryTimeComputed')
$AccountInfo = [PSCustomObject]@{
FirstName = $Employee.GivenName
LastName = $Employee.Surname
Title = $Employee.Title
Department = $Employee.department
Manager = $Manager
City = $Employee.city
EmployeeID = $Employee.EmployeeID
UserName = $Employee.SamAccountName
DisplayNme = $Employee.displayname
EmailAddress = $Employee.emailaddress
OfficePhone = $Employee.officephone
MobilePhone = $Employee.mobilephone
}
$AccountStatus = [PSCustomObject]@{
PasswordExpired = $Employee.PasswordExpired
AccountLockedOut = $Employee.LockedOut
LockOutTime = $Employee.AccountLockoutTime
AccountEnabled = $Employee.Enabled
AccountExpirationDate = $Employee.AccountExpirationDate
PasswordLastSet = $Employee.PasswordLastSet
PasswordExpireDate = $PasswordExpiry
}
$AccountInfo
$AccountStatus
} #END OF FUNCTION