Add a script for installing windows
This commit is contained in:
parent
6138ad7ffa
commit
ac288a913d
4 changed files with 35 additions and 1 deletions
4
scripts/Windows/OS/Install.ps1
Normal file
4
scripts/Windows/OS/Install.ps1
Normal file
|
@ -0,0 +1,4 @@
|
|||
. "$PSScriptRoot/Manage.ps1";
|
||||
|
||||
Invoke-WindowsRestore;
|
||||
|
|
@ -28,3 +28,21 @@ function Invoke-WindowsBackup([Context] $context) {
|
|||
Invoke-BackupVisualStudio $context;
|
||||
$context.Backup($backupRoot, "$backupRoot.7z", @("-sdel"));
|
||||
}
|
||||
|
||||
function Invoke-WindowsRestore() {
|
||||
function Read-Path()
|
||||
{
|
||||
$backupPath = Read-Host -Prompt "Please enter the path to the archive load the backup from.";
|
||||
|
||||
if (-not (Test-Path -PathType Leaf $backupPath))
|
||||
{
|
||||
Write-Host "No file could be found at the specified path.";
|
||||
return Read-Path;
|
||||
}
|
||||
}
|
||||
|
||||
$backupPath = Read-Path;
|
||||
$context = [Context]::new();
|
||||
$context.BackupName = "PortValhalla";
|
||||
$context.Restore($backupPath, $context.BackupRoot());
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ foreach ($module in @("PSWindowsUpdate"))
|
|||
Import-Module PSWindowsUpdate;
|
||||
Import-Module ScheduledTasks;
|
||||
|
||||
$installerPath = "$PSScriptRoot/Manage.ps1";
|
||||
$installerPath = "$PSScriptRoot/Install.ps1";
|
||||
$setupPath = "$($MyInvocation.MyCommand.Path)";
|
||||
|
||||
Install-WindowsUpdate -AcceptAll -IgnoreReboot;
|
||||
|
|
|
@ -33,4 +33,16 @@ class Context {
|
|||
-Wait `
|
||||
-NoNewWindow;
|
||||
}
|
||||
|
||||
[void] Restore([string]$archivePath, [string]$destinationPath) {
|
||||
if (-not (Test-Path -PathType Container $destinationPath)) {
|
||||
New-Item -ItemType Directory "$destinationPath";
|
||||
}
|
||||
|
||||
Start-Process -WorkingDirectory "$destinationPath" `
|
||||
-FilePath "7z"
|
||||
-ArgumentList "x" `
|
||||
-Wait `
|
||||
-NoNewWindow;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue