Skip to content

Instantly share code, notes, and snippets.

@Peleke
Last active September 25, 2020 05:54
Show Gist options
  • Save Peleke/b588efbfbdbd8c9b4be6d634dbc61483 to your computer and use it in GitHub Desktop.
Save Peleke/b588efbfbdbd8c9b4be6d634dbc61483 to your computer and use it in GitHub Desktop.
# 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