Last active
February 2, 2020 23:12
-
-
Save sholt0r/a948a34fa33d3b207437c53658b6d434 to your computer and use it in GitHub Desktop.
Good Pranks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Read-Host "Last logged on user" | Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI" -Name "LastLoggedOnDisplayName" -Value $_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $scriptName = $MyInvocation.MyCommand.Name | |
| #[TEST FOR LOGS DIR]# | |
| $dir = "C:\Temp\Logs" | |
| $dirTest = Test-Path -Path $dir | |
| if (!($dirTest)) { | |
| New-Item -Path $dir -ItemType Directory | |
| } | |
| #[TEST FOR LOG FILE]# | |
| $file = "C:\Temp\Logs\DisplayNameSet.txt" | |
| $fileTest = Test-Path -Path $file | |
| if (!($fileTest)) { | |
| New-Item -Force -Path $file -ItemType File | |
| } | |
| else { | |
| Clear-Content -Path $file | |
| } | |
| #[SET REGISTRY VALUE]# | |
| function SetValue { | |
| param ($name) | |
| Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI" -Name "LastLoggedOnDisplayName" -Value $name | |
| Write-Host "Registry value set." | |
| } | |
| function IfYes ($open) { | |
| if ($open -eq "Yes") { | |
| notepad "C:\Temp\Logs\DisplayNameSet.txt" | |
| } | |
| } | |
| #[MAIN SCRIPT]# | |
| & { | |
| #[TEST SCRIPT LOCATION]# | |
| $open = "No" | |
| $scriptProgFile = Test-Path "C:\Program Files\$scriptName" | |
| if (!($scriptProgFile)) { | |
| Write-Host "This script needs to be moved to C:\Program Files\" | |
| $open = "Yes" | |
| } | |
| #[TEST FOR SCHEDULED TASK]# | |
| #[CREATE IF NOT FOUND]# | |
| if (!(Get-ScheduledTask | Where-Object { $_.TaskName -eq "Prank"})) { | |
| $action = New-ScheduledTaskAction -Execute 'C:\Program Files\ChangeLastUser_1.1_2020_01_29.ps1' | |
| $trigger = New-ScheduledTaskTrigger -AtLogoff | |
| $STPrin = New-ScheduledTaskPrincipal -UserId "LOCALSERVICE" -LogonType ServiceAccount | |
| Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "Prank" -Description "Sholtor4096 was here." -Principal $STPrin | |
| Write-Host "Scheduled Task Created" | |
| SetValue("boris@kremlin.gov.ru") | |
| IfYes($open) | |
| } | |
| #[IF FOUND SET VALUE]# | |
| else { | |
| Write-Host "Scheduled Task Exists" | |
| SetValue("boris@kremlin.gov.ru") | |
| IfYes($open) | |
| } | |
| } *>> "C:\Temp\Logs\DisplayNameSet.txt" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment