forked from LeDragoX/Win-Debloat-Tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Backup-System.ps1
34 lines (26 loc) · 1.51 KB
/
Backup-System.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
34
Import-Module -DisableNameChecking "$PSScriptRoot\..\lib\debloat-helper\Set-ItemPropertyVerified.psm1"
Import-Module -DisableNameChecking "$PSScriptRoot\..\lib\Title-Templates.psm1"
$Script:TweakType = "Backup"
function New-RestorePoint() {
Write-Status -Types "+", $TweakType -Status "Breaking the Restore Point creation limit..."
Set-ItemPropertyVerified -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore" -Name "SystemRestorePointCreationFrequency" -Type DWord -Value 0
Write-Status -Types "+", $TweakType -Status "Enabling system drive Restore Point..."
Enable-ComputerRestore -Drive "$env:SystemDrive\"
Checkpoint-Computer -Description "Win 10 Restore Point" -RestorePointType "MODIFY_SETTINGS"
}
function Backup-HostsFile() {
$PathToHostsFile = "$env:SystemRoot\System32\drivers\etc"
Write-Status -Types "+", $TweakType -Status "Doing Backup on Hosts file..."
$Date = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
Push-Location "$PathToHostsFile"
If (!(Test-Path "$PathToHostsFile\Hosts_Backup")) {
Write-Status -Types "?", $TweakType -Status "Backup folder not found! Creating a new one..." -Warning
mkdir -Path "$PathToHostsFile\Hosts_Backup"
}
Push-Location "Hosts_Backup"
Copy-Item -Path ".\..\hosts" -Destination "hosts_$Date"
Pop-Location
Pop-Location
}
New-RestorePoint # This makes a restoration point before the script begins
Backup-HostsFile # Backup the Hosts file found on "X:\Windows\System32\drivers\etc" of the current system