Add scripts for backing up and restoring personal files
This commit is contained in:
parent
8cf7791723
commit
1b6ebcd554
2 changed files with 204 additions and 123 deletions
37
scripts/Windows/Software/Windows/Home.exclude.txt
Normal file
37
scripts/Windows/Software/Windows/Home.exclude.txt
Normal file
|
@ -0,0 +1,37 @@
|
|||
Pictures/Feedback
|
||||
Documents/BeamNG.drive
|
||||
Documents/Default.rdp
|
||||
Documents/den4b/ReNamer
|
||||
Documents/Dolphin Emulator
|
||||
Documents/eFisc
|
||||
Documents/IISExpress
|
||||
Documents/KINGDOM HEARTS HD 1.5+2.5 ReMIX
|
||||
Documents/ManiaPlanet
|
||||
Documents/MetaX
|
||||
Documents/MuseScore3
|
||||
Documents/My Web Sites
|
||||
Documents/OneNote-Notizbücher
|
||||
Documents/PCSX2
|
||||
Documents/PowerShell
|
||||
Documents/PPSSPP
|
||||
Documents/PS Vita
|
||||
Documents/PSV Packages
|
||||
Documents/PSV Updates
|
||||
Documents/Repositories
|
||||
Documents/Rise of the Tomb Raider
|
||||
Documents/S2
|
||||
Documents/SEGA
|
||||
Documents/SEGA Mega Drive Classics
|
||||
Documents/SQL Server Management Studio
|
||||
Documents/Square Enix
|
||||
Documents/TI-Nspire CX
|
||||
Documents/TmForever
|
||||
Documents/TrackMania
|
||||
Documents/UltraVNC
|
||||
Documents/Visual Studio 2017
|
||||
Documents/Visual Studio 2019
|
||||
Documents/Visual Studio 2022
|
||||
Documents/Viwizard M4V Converter
|
||||
Documents/WindowsPowerShell
|
||||
Documents/Zoom
|
||||
Music/iTunes
|
|
@ -5,134 +5,178 @@ param(
|
|||
[hashtable] $Arguments
|
||||
)
|
||||
|
||||
. "$PSScriptRoot/../../Scripts/Registry.ps1";
|
||||
. "$PSScriptRoot/../../../Common/Scripts/Config.ps1";
|
||||
. "$PSScriptRoot/../../../Common/Scripts/System.ps1";
|
||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
||||
|
||||
Start-SoftwareInstaller @PSBoundParameters `
|
||||
-Configurator {
|
||||
$dir = New-TemporaryDirectory;
|
||||
Push-Location $dir;
|
||||
& {
|
||||
param($Parameters)
|
||||
|
||||
function Get-WinConfig {
|
||||
. "$PSScriptRoot/../../Scripts/Registry.ps1";
|
||||
. "$PSScriptRoot/../../Scripts/Restoration.ps1";
|
||||
. "$PSScriptRoot/../../../Common/Scripts/Config.ps1";
|
||||
. "$PSScriptRoot/../../../Common/Scripts/System.ps1";
|
||||
|
||||
$userFolders = @(
|
||||
"Pictures",
|
||||
"Documents",
|
||||
"Downloads",
|
||||
"Music",
|
||||
"Videos"
|
||||
);
|
||||
|
||||
$userExclusions = @(
|
||||
"Documents/Eigene*",
|
||||
"Documents/My Games",
|
||||
"Documents/My Music",
|
||||
"Documents/My Pictures",
|
||||
"Documents/My Videos"
|
||||
);
|
||||
|
||||
[string[]] $homeExclusions = Get-Content "$PSScriptRoot/Home.exclude.txt";
|
||||
|
||||
Start-SoftwareInstaller @Parameters `
|
||||
-Backup {
|
||||
Add-BackupArtifacts -Source "$env:PUBLIC" -Path "Public" `
|
||||
-Include ($userFolders) `
|
||||
-Exclude ($userExclusions + @("Documents/Hyper-V", "Documents/reWASD"));
|
||||
} `
|
||||
-Configurator {
|
||||
$dir = New-TemporaryDirectory;
|
||||
Push-Location $dir;
|
||||
|
||||
function Get-WinConfig {
|
||||
param(
|
||||
[string] $Name
|
||||
)
|
||||
|
||||
Get-Config "valhalla.windows.$Name";
|
||||
}
|
||||
|
||||
# Copy keyboard layout
|
||||
# ToDo: Why not NewUser? Investiagte!
|
||||
Copy-UserInternationalSettingsToSystem -WelcomeScreen $True -NewUser $False;
|
||||
|
||||
if (Get-WinConfig "legacyIconSpacing") {
|
||||
Write-Host "Setting up old-school Desktop Icon spacing";
|
||||
|
||||
Edit-DefaultUserKey {
|
||||
param (
|
||||
[RegistryKey] $Key
|
||||
)
|
||||
|
||||
$property = "IconSpacing";
|
||||
$relativePath = "Control Panel\Desktop\WindowMetrics"
|
||||
$path = "$($Key.PSPath)\$relativePath";
|
||||
Copy-ItemProperty "HKCU:\$relativePath" $path $property;
|
||||
Rename-ItemProperty $path $property "_$property";
|
||||
Set-ItemProperty $path -Name $property -Value "-1710" -Type "String";
|
||||
};
|
||||
}
|
||||
|
||||
if (-not (Get-WinConfig "dynamicLighting")) {
|
||||
Write-Host "Disabling Dynamic Lighting";
|
||||
|
||||
Edit-DefaultUserKey {
|
||||
param (
|
||||
[RegistryKey] $Key
|
||||
)
|
||||
|
||||
$path = "$($Key.PSPath)\Software\Microsoft\Lighting";
|
||||
$null = New-Item $path -ErrorAction SilentlyContinue;
|
||||
Set-ItemProperty $path -Name "AmbientLightingEnabled" -Value 0 -Type "DWord";
|
||||
};
|
||||
}
|
||||
|
||||
if (-not (Get-WinConfig "adware")) {
|
||||
$startLayoutFile = "start.json";
|
||||
Write-Host "Removing adware";
|
||||
|
||||
Remove-DesktopIcon "*Microsoft Edge*";
|
||||
|
||||
Edit-DefaultUserKey {
|
||||
param (
|
||||
[RegistryKey] $Key
|
||||
)
|
||||
|
||||
$winKey = "$($Key.PSPath)\Software\Microsoft\Windows\CurrentVersion";
|
||||
$contentDeliveryKey = "$winKey\ContentDeliveryManager";
|
||||
$cloudContentKey = "HKLM:\Software\Policies\Microsoft\Windows\CloudContent";
|
||||
|
||||
foreach ($path in @($contentDeliveryKey, $cloudContentKey)) {
|
||||
if (-not (Test-Path $path)) {
|
||||
$null = New-Item $path;
|
||||
}
|
||||
}
|
||||
|
||||
# Set-ItemProperty $cloudContentKey -Name "DisableWindowsConsumerFeatures" -Value 1 -Type "DWord";
|
||||
Set-ItemProperty $cloudContentKey -Name "DisableCloudOptimizedContent" -Value 1 -Type "DWord";
|
||||
Set-ItemProperty $cloudContentKey -Name "DisableConsumerAccountStateContent" -Value 1 -Type "DWord";
|
||||
|
||||
# Disabling Personal MS Teams Icon
|
||||
Set-ItemProperty "$winKey\Explorer\Advanced" -Name "TaskBarMn" -Value 0 -Type "DWord";
|
||||
Set-ItemProperty $contentDeliveryKey -Name "ContentDeliveryAllowed" -Value 0 -Type "DWord";
|
||||
Set-ItemProperty $contentDeliveryKey -Name "SilentInstalledAppsEnabled" -Value 0 -Type "DWord";
|
||||
Set-ItemProperty $contentDeliveryKey -Name "SystemPaneSuggestionsEnabled" -Value 0 -Type "DWord";
|
||||
};
|
||||
|
||||
Write-Host "Removing ads from pinned apps";
|
||||
Export-StartLayout $startLayoutFile;
|
||||
|
||||
$startLayout = Get-Content $startLayoutFile | ConvertFrom-Json;
|
||||
$property = "pinnedList";
|
||||
|
||||
$newLayout = $startLayout | Select-Object -ExpandProperty $property | Where-Object {
|
||||
-not (
|
||||
($_.desktopAppLink -like "*Microsoft Edge*") -or
|
||||
[System.Linq.Enumerable]::Any(
|
||||
@(
|
||||
"*MicrosoftOfficeHub*",
|
||||
"*SpotifyMusic*",
|
||||
"*WhatsApp*",
|
||||
"*PrimeVideo*",
|
||||
"*Netflix*",
|
||||
"*Instagram*",
|
||||
"*ChipChamp*",
|
||||
"*Facebook*",
|
||||
"*LinkedIn*"),
|
||||
[System.Func[System.Object,bool]]{
|
||||
param($pattern)
|
||||
$_.packagedAppId -like "$pattern";
|
||||
}));
|
||||
};
|
||||
|
||||
$startLayout.PSObject.Properties.Remove($property);
|
||||
$startLayout | Add-Member -NotePropertyName $property -NotePropertyValue $newLayout;
|
||||
|
||||
$startLayout | ConvertTo-Json -Compress | Set-Content "$env:SystemDrive\Users\Default\AppData\Local\Microsoft\Windows\Shell\LayoutModification.json";
|
||||
}
|
||||
|
||||
if (Get-WinConfig "showFileExt") {
|
||||
Edit-DefaultUserKey {
|
||||
param (
|
||||
[RegistryKey] $Key
|
||||
)
|
||||
|
||||
Set-ItemProperty "$($Key.PSPath)\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "HideFileExt" -Value 0 -Type "DWord";
|
||||
};
|
||||
}
|
||||
|
||||
Pop-Location;
|
||||
Remove-Item -Recurse $dir;
|
||||
Expand-BackupArtifacts -Path "Public" -Target $env:PUBLIC;
|
||||
} `
|
||||
-UserBackup {
|
||||
param(
|
||||
[string] $Name
|
||||
[hashtable] $Arguments
|
||||
)
|
||||
|
||||
Get-Config "valhalla.windows.$Name";
|
||||
}
|
||||
Add-BackupArtifacts -User $Arguments.Name -Source $HOME -Path "Home" -Include ($userFolders) -Exclude ($userExclusions + $homeExclusions);
|
||||
} `
|
||||
-UserConfigurator {
|
||||
param(
|
||||
[hashtable] $Arguments
|
||||
)
|
||||
|
||||
# Copy keyboard layout
|
||||
# ToDo: Why not NewUser? Investiagte!
|
||||
Copy-UserInternationalSettingsToSystem -WelcomeScreen $True -NewUser $False;
|
||||
|
||||
if (Get-WinConfig "legacyIconSpacing") {
|
||||
Write-Host "Setting up old-school Desktop Icon spacing";
|
||||
|
||||
Edit-DefaultUserKey {
|
||||
param (
|
||||
[RegistryKey] $Key
|
||||
)
|
||||
|
||||
$property = "IconSpacing";
|
||||
$relativePath = "Control Panel\Desktop\WindowMetrics"
|
||||
$path = "$($Key.PSPath)\$relativePath";
|
||||
Copy-ItemProperty "HKCU:\$relativePath" $path $property;
|
||||
Rename-ItemProperty $path $property "_$property";
|
||||
Set-ItemProperty $path -Name $property -Value "-1710" -Type "String";
|
||||
};
|
||||
}
|
||||
|
||||
if (-not (Get-WinConfig "dynamicLighting")) {
|
||||
Write-Host "Disabling Dynamic Lighting";
|
||||
|
||||
Edit-DefaultUserKey {
|
||||
param (
|
||||
[RegistryKey] $Key
|
||||
)
|
||||
|
||||
$path = "$($Key.PSPath)\Software\Microsoft\Lighting";
|
||||
$null = New-Item $path;
|
||||
Set-ItemProperty $path -Name "AmbientLightingEnabled" -Value 0 -Type "DWord";
|
||||
};
|
||||
}
|
||||
|
||||
if (-not (Get-WinConfig "adware")) {
|
||||
$startLayoutFile = "start.json";
|
||||
Write-Host "Removing adware";
|
||||
|
||||
Remove-DesktopIcon "*Microsoft Edge*";
|
||||
|
||||
Edit-DefaultUserKey {
|
||||
param (
|
||||
[RegistryKey] $Key
|
||||
)
|
||||
|
||||
$winKey = "$($Key.PSPath)\Software\Microsoft\Windows\CurrentVersion";
|
||||
$contentDeliveryKey = "$winKey\ContentDeliveryManager";
|
||||
$cloudContentKey = "HKLM:\Software\Policies\Microsoft\Windows\CloudContent";
|
||||
|
||||
foreach ($path in @($contentDeliveryKey, $cloudContentKey)) {
|
||||
if (-not (Test-Path $path)) {
|
||||
$null = New-Item $path;
|
||||
}
|
||||
}
|
||||
|
||||
# Set-ItemProperty $cloudContentKey -Name "DisableWindowsConsumerFeatures" -Value 1 -Type "DWord";
|
||||
Set-ItemProperty $cloudContentKey -Name "DisableCloudOptimizedContent" -Value 1 -Type "DWord";
|
||||
Set-ItemProperty $cloudContentKey -Name "DisableConsumerAccountStateContent" -Value 1 -Type "DWord";
|
||||
|
||||
# Disabling Personal MS Teams Icon
|
||||
Set-ItemProperty "$winKey\Explorer\Advanced" -Name "TaskBarMn" -Value 0 -Type "DWord";
|
||||
Set-ItemProperty $contentDeliveryKey -Name "ContentDeliveryAllowed" -Value 0 -Type "DWord";
|
||||
Set-ItemProperty $contentDeliveryKey -Name "SilentInstalledAppsEnabled" -Value 0 -Type "DWord";
|
||||
Set-ItemProperty $contentDeliveryKey -Name "SystemPaneSuggestionsEnabled" -Value 0 -Type "DWord";
|
||||
};
|
||||
|
||||
Write-Host "Removing ads from pinned apps";
|
||||
Export-StartLayout $startLayoutFile;
|
||||
|
||||
$startLayout = Get-Content $startLayoutFile | ConvertFrom-Json;
|
||||
$property = "pinnedList";
|
||||
|
||||
$newLayout = $startLayout | Select-Object -ExpandProperty $property | Where-Object {
|
||||
-not (
|
||||
($_.desktopAppLink -like "*Microsoft Edge*") -or
|
||||
[System.Linq.Enumerable]::Any(
|
||||
@(
|
||||
"*MicrosoftOfficeHub*",
|
||||
"*SpotifyMusic*",
|
||||
"*WhatsApp*",
|
||||
"*PrimeVideo*",
|
||||
"*Netflix*",
|
||||
"*Instagram*",
|
||||
"*ChipChamp*",
|
||||
"*Facebook*",
|
||||
"*LinkedIn*"),
|
||||
[System.Func[System.Object,bool]]{
|
||||
param($pattern)
|
||||
$_.packagedAppId -like "$pattern";
|
||||
}));
|
||||
};
|
||||
|
||||
$startLayout.PSObject.Properties.Remove($property);
|
||||
$startLayout | Add-Member -NotePropertyName $property -NotePropertyValue $newLayout;
|
||||
|
||||
$startLayout | ConvertTo-Json -Compress | Set-Content "$env:SystemDrive\Users\Default\AppData\Local\Microsoft\Windows\Shell\LayoutModification.json";
|
||||
}
|
||||
|
||||
if (Get-WinConfig "showFileExt") {
|
||||
Edit-DefaultUserKey {
|
||||
param (
|
||||
[RegistryKey] $Key
|
||||
)
|
||||
|
||||
Set-ItemProperty "$($Key.PSPath)\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "HideFileExt" -Value 0 -Type "DWord";
|
||||
};
|
||||
}
|
||||
|
||||
Pop-Location;
|
||||
Remove-Item -Recurse $dir;
|
||||
};
|
||||
Expand-BackupArtifacts -User $Arguments.Name -Path "Home" -Target $HOME;
|
||||
};
|
||||
} $PSBoundParameters;
|
||||
|
|
Loading…
Reference in a new issue