Last active
September 25, 2020 05:54
-
-
Save Peleke/b588efbfbdbd8c9b4be6d634dbc61483 to your computer and use it in GitHub Desktop.
This file contains 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
# Relax PowerShell | |
Set-ExecutionPolicy -ExecutionPolicy Unrestricted | |
# Install .NET Framework 3.5 | |
Dism /Online /Enable-Feature /FeatureName:'NetFx3' | |
# Disable UAC | |
# Alt.: reg add HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /d 0 /t REG_DWORD /f /reg:64 | |
$newItemParameters = @{ | |
Force = $true | |
Name = 'EnableLUA' | |
Path = 'HKLM:Software\Microsoft\Windows\CurrentVersion\Policies\System' | |
PropertyType = 'DWord' | |
Value = 0 | |
} | |
New-ItemProperty @newItemParameters | |
# Configure & Enable WinRM | |
winrm quickconfig -q | |
winrm set winrm/config/winrs @{MaxMemoryPerShellMB="512"} | |
winrm set winrm/config @{MaxTimeoutms="1800000"} | |
winrm set winrm/config/service @{AllowUnencrypted="true"} | |
winrm set winrm/config/service/auth @{Basic="true"} | |
$winRm = Get-Service | Where-Object { $_.Name -like "*WinRM*" } | |
$winRm | Set-Service -StartupType Automatic | |
# Enable NLA | |
$registryPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" | |
$name1 = "UserAuthentication" | |
$value1 = "00000000" | |
if (!(Test-Path $registryPath)) { | |
New-Item -Path $registryPath -Force | Out-Null | |
New-ItemProperty -Path $registryPath -Name $name1 -Value $value1 -PropertyType DWORD -Force | Out-Null | |
} else { | |
New-ItemProperty -Path $registryPath -Name $name1 -Value $value1 -PropertyType DWORD -Force | Out-Null | |
} | |
$name2 = "SecurityLayer" | |
$value2 = "00000000" | |
if (!(Test-Path $registryPath)) { | |
New-Item -Path $registryPath -Force | Out-Null | |
New-ItemProperty -Path $registryPath -Name $name2 -Value $value2 -PropertyType DWORD -Force | Out-Null | |
} else { | |
New-ItemProperty -Path $registryPath -Name $name2 -Value $value2 -PropertyType DWORD -Force | Out-Null | |
} | |
# Clean Unused Files | |
C:\Windows\System32\cleanmgr.exe /autoclean | |
# Zero Free Space | |
$zipName = 'SDelete.zip' | |
$iwrParameters = @{ | |
Uri = "https://download.sysinternals.com/files/$zipName" | |
UseBasicParsing = $true | |
OutFile = "$HOME/Downloads/$zipName" | |
} | |
Invoke-WebRequest @iwrParameters | |
Expand-Archive -Path "$HOME/Downloads/$zipName" | |
./SDelete/sdelete.exe /accepteula | |
./SDelete/sdelete.exe -z c: | |
Remove-Item -Force -Recurse -Path './SDelete' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment