Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Created by Fran Blanco
- # web: www.vlan18.com
- # LinkedIn: https://es.linkedin.com/in/fblancos
- # Date: 05/09/2020
- # Version: 1.01
- Set-ExecutionPolicy Unrestricted -Force
- Write-Host ""
- Write-Host "Starting setup ... Please, be patient" -ForegroundColor Black -BackgroundColor White
- Write-Host ""
- #Install .Net Framework 3.5
- Enable-WindowsOptionalFeature -Online -FeatureName "NetFx3" -NoRestart
- # Full path on Explorer title bar
- Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\" -Name CabinetState -Value 1
- # TCP Hardening
- Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -Name "SynAttackProtect" -Type Dword -Value 2 -Force
- Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -Name "DefaultTTL" -Type Dword -Value 64 -Force
- # Disable obsolete SMB 1.0 protocol
- Disable-WindowsOptionalFeature -Online -FeatureName smb1protocol -NoRestart
- Disable-WindowsOptionalFeature -Online -FeatureName MicrosoftWindowsPowerShellV2 -NoRestart
- # Set to private network profile
- Set-NetConnectionProfile -NetworkCategory Private
- # Configuracion Firewall
- Set-NetFirewallProfile -Name Domain -LogMaxSizeKilobytes 16384 -DefaultInboundAction Block -DefaultOutboundAction Allow -LogAllowed True -LogBlocked True -NotifyOnListen True -AllowUnicastResponseToMulticast True -LogFileName %SystemRoot%\System32\LogFiles\Firewall\domainfw.log
- Set-NetFirewallProfile -Name Private -LogMaxSizeKilobytes 16384 -DefaultInboundAction Block -DefaultOutboundAction Allow -LogAllowed True -LogBlocked True -NotifyOnListen True -AllowUnicastResponseToMulticast True -LogFileName %SystemRoot%\System32\LogFiles\Firewall\privatefw.log
- Set-NetFirewallProfile -Name Public -LogMaxSizeKilobytes 16384 -DefaultInboundAction Block -DefaultOutboundAction Block -LogAllowed True -LogBlocked True -NotifyOnListen False -AllowUnicastResponseToMulticast True -LogFileName %SystemRoot%\System32\LogFiles\Firewall\publicfw.log
- # Enable Controlled Folder Access
- Set-MpPreference -EnableControlledFolderAccess Enabled
- # Stop and disable Diagnostics Tracking Service
- Stop-Service "DiagTrack" -WarningAction SilentlyContinue
- Set-Service "DiagTrack" -StartupType Disabled
- # Block Microsoft Telemetry Spying
- New-NetFirewallRule -DisplayName 'DiagTrack-Service' -Name 'DiagTrack-Service' -Direction Outbound -Action Block -Service 'DiagTrack'
- # Disable Error Reporting
- Disable-WindowsErrorReporting
- # Disable Telemetry
- Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 0
- Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 0
- Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Policies\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 0
- # Disable Location Tracking
- Function DisableLocationTracking {
- Write-Output "Disabling Location Tracking..."
- If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location")) {
- New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location" -Force | Out-Null
- }
- Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location" -Name "Value" -Type String -Value "Deny"
- Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Sensor\Overrides\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}" -Name "SensorPermissionState" -Type DWord -Value 0
- Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\lfsvc\Service\Configuration" -Name "Status" -Type DWord -Value 0
- }
- # Stop and disable Diagnostics Tracking Service
- Stop-Service "DiagTrack" -WarningAction SilentlyContinue
- Set-Service "DiagTrack" -StartupType Disabled
- # Disable Feedback
- Function DisableFeedback {
- Write-Output "Disabling Feedback..."
- If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Siuf\Rules")) {
- New-Item -Path "HKCU:\SOFTWARE\Microsoft\Siuf\Rules" -Force | Out-Null
- }
- Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Siuf\Rules" -Name "NumberOfSIUFInPeriod" -Type DWord -Value 0
- Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" -Name "DoNotShowFeedbackNotifications" -Type DWord -Value 1
- Disable-ScheduledTask -TaskName "Microsoft\Windows\Feedback\Siuf\DmClient" -ErrorAction SilentlyContinue | Out-Null
- Disable-ScheduledTask -TaskName "Microsoft\Windows\Feedback\Siuf\DmClientOnScenarioDownload" -ErrorAction SilentlyContinue | Out-Null
- }
- # Enable Windows Defender Cloud
- Function EnableDefenderCloud {
- Write-Host "Enabling Windows Defender Cloud..."
- Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SpynetReporting" -ErrorAction SilentlyContinue
- Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SubmitSamplesConsent" -ErrorAction SilentlyContinue
- }
- # Disable Remote Assistance
- Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Remote Assistance" -Name "fAllowToGetHelp" -Type DWord -Value 0
- # Show known file extensions
- Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "HideFileExt" -Type DWord -Value 0
- # Hide hidden files
- Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Hidden" -Type DWord -Value 2
- # Enable Ctrl+Alt+Del requirement before login
- Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "DisableCAD" -Type DWord -Value 0
- # Disable IPv6
- Get-NetAdapter | foreach { Disable-NetAdapterBinding -InterfaceAlias $_.Name -ComponentID ms_tcpip6 }
- # Enable Remote Desktop w/o Network Level Authentication
- Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections" -Type DWord -Value 0
- Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name "UserAuthentication" -Type DWord -Value 1
- # Hide network options from Lock Screen
- Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "DontDisplayNetworkSelectionUI" -Type DWord -Value 1
- # Hide shutdown options from Lock Screen
- Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ShutdownWithoutLogon" -Type DWord -Value 0
- # Disable Sticky keys prompt
- Set-ItemProperty -Path "HKCU:\Control Panel\Accessibility\StickyKeys" -Name "Flags" -Type String -Value "506"
- # Show Task Manager details
- Function ShowTaskManagerDetails {
- Write-Host "Showing task manager details..."
- If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager")) {
- New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Force | Out-Null
- }
- $preferences = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Name "Preferences" -ErrorAction SilentlyContinue
- If (!($preferences)) {
- $taskmgr = Start-Process -WindowStyle Hidden -FilePath taskmgr.exe -PassThru
- While (!($preferences)) {
- Start-Sleep -m 250
- $preferences = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Name "Preferences" -ErrorAction SilentlyContinue
- }
- Stop-Process $taskmgr
- }
- $preferences.Preferences[28] = 0
- Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Name "Preferences" -Type Binary -Value $preferences.Preferences
- }
- # Show file operations details
- Function ShowFileOperationsDetails {
- Write-Host "Showing file operations details..."
- If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager")) {
- New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager" | Out-Null
- }
- Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager" -Name "EnthusiastMode" -Type DWord -Value 1
- }
- # Show titles in taskbar
- Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarGlomLevel" -Type DWord -Value 1
- # Hide tray icons as needed
- Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" -Name "EnableAutoTray" -ErrorAction SilentlyContinue
- # Uninstall Microsoft Print to PDF
- Disable-WindowsOptionalFeature -Online -FeatureName "Printing-PrintToPDFServices-Features" -NoRestart -WarningAction SilentlyContinue | Out-Null
- # Uninstall Microsoft XPS Document Writer
- Disable-WindowsOptionalFeature -Online -FeatureName "Printing-XPSServices-Features" -NoRestart -WarningAction SilentlyContinue | Out-Null
- # Remove Default Fax Printer
- Remove-Printer -Name "Fax" -ErrorAction SilentlyContinue
- # Set Photo Viewer association for bmp, gif, jpg, png and tif
- Function SetPhotoViewerAssociation {
- Write-Output "Setting Photo Viewer association for bmp, gif, jpg, png and tif..."
- If (!(Test-Path "HKCR:")) {
- New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | Out-Null
- }
- ForEach ($type in @("Paint.Picture", "giffile", "jpegfile", "pngfile")) {
- New-Item -Path $("HKCR:\$type\shell\open") -Force | Out-Null
- New-Item -Path $("HKCR:\$type\shell\open\command") | Out-Null
- Set-ItemProperty -Path $("HKCR:\$type\shell\open") -Name "MuiVerb" -Type ExpandString -Value "@%ProgramFiles%\Windows Photo Viewer\photoviewer.dll,-3043"
- Set-ItemProperty -Path $("HKCR:\$type\shell\open\command") -Name "(Default)" -Type ExpandString -Value "%SystemRoot%\System32\rundll32.exe `"%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll`", ImageView_Fullscreen %1"
- }
- }
- Set-ExecutionPolicy Restricted -Force
- Write-Host
- Write-Host "Press any key to restart your system..." -ForegroundColor Black -BackgroundColor White
- Write-Host
- $key = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
- Write-Host "Restarting..."
- Restart-Computer
Add Comment
Please, Sign In to add comment