-
Notifications
You must be signed in to change notification settings - Fork 0
/
logonscript.ps1
33 lines (29 loc) · 1.03 KB
/
logonscript.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
<#
.SYNOPSIS
Creation of a logon tracking system native to Windows & searcable in Active Directory
.DESCRIPTION
This logon script will do the following things:
- Update a central log with Time, User, Computer for logon events
- Populate custom attributes in the following manner:
- ADUser attributes will contain the last logged on computer
- ADComputer attributes will contain the last logged on user
.OUTPUTS
None
.NOTES
Version: 1.0
Author: CielGoldenflame
Creation Date: 2020 04 25
Purpose/Change: Test Script
PSVersion: 5.1
OS Versions: Windows Server 2016 & Win 10 Enterprise
.EXAMPLE
implemented automatically with setup.ps1
#>
# Variable to input time
$date = Get-Date
$user = "$env:USERDOMAIN\$env:USERNAME"
# Command adds info to text
Add-Content \\DESKTOP-LDGMO77\Logroot\logonlog.txt -Value "
Time: $date
User: $user
Computer: $env:COMPUTERNAME"