Add capabilities to back up apps

This commit is contained in:
Manuel Thalmann 2024-08-28 00:37:04 +02:00
parent 5dcf809caf
commit f5c2d678ae
2 changed files with 19 additions and 4 deletions

View file

@ -200,6 +200,7 @@ $null = New-Module {
[scriptblock] $Backup = $null,
[scriptblock] $Installer = $null,
[scriptblock] $Configurator = $null,
[scriptblock] $UserBackup = $null,
[scriptblock] $UserConfigurator = $null,
[Nullable[InstallerAction]] $Action,
[hashtable] $Arguments
@ -262,14 +263,26 @@ $null = New-Module {
& $Configurator @argumentList;
}
}
([InstallerAction]::ConfigureUser) {
default {
if ((-not $Arguments.ContainsKey($userArgument)) -or (-not $Arguments[$userArgument])) {
$Arguments.Add($userArgument, ($IsWindows ? $env:UserName : $env:USER));
}
if ($UserConfigurator) {
Write-Host "Configuring $Name for user ``$($Arguments[$userArgument])``";
& $UserConfigurator @argumentList;
$user = $Arguments[$userArgument];
switch ($_) {
([InstallerAction]::BackupUser) {
if ($UserBackup) {
Write-Host "Backing up $Name for user ``$user``";
& $UserBackup @argumentList;
}
}
([InstallerAction]::ConfigureUser) {
if ($UserConfigurator) {
Write-Host "Configuring $Name for user ``$user``";
& $UserConfigurator @argumentList;
}
}
}
}
}

View file

@ -1,5 +1,7 @@
enum InstallerAction {
Backup
Install
Configure
BackupUser
ConfigureUser
}