Detect entrypoint automatically
This commit is contained in:
parent
e63b161243
commit
8339cb3006
4 changed files with 16 additions and 2 deletions
|
@ -16,7 +16,6 @@ function Restore-Apps {
|
||||||
Write-Host "Starting Restoration of Windows";
|
Write-Host "Starting Restoration of Windows";
|
||||||
. "$PSScriptRoot/../../../scripts/Windows/OS/Install.ps1";
|
. "$PSScriptRoot/../../../scripts/Windows/OS/Install.ps1";
|
||||||
[Context]$context = [Context]::new();
|
[Context]$context = [Context]::new();
|
||||||
$context.EntryPoint = "$($MyInvocation.MyCommand.Path)";
|
|
||||||
$context.UserName = "Manuel";
|
$context.UserName = "Manuel";
|
||||||
Invoke-WindowsInstallation $context;
|
Invoke-WindowsInstallation $context;
|
||||||
Restart-Computer -Force;
|
Restart-Computer -Force;
|
||||||
|
|
|
@ -10,7 +10,6 @@ function Restore-Apps {
|
||||||
}
|
}
|
||||||
|
|
||||||
[Context]$context = [Context]::new();
|
[Context]$context = [Context]::new();
|
||||||
$context.EntryPoint = "$($MyInvocation.MyCommand.Path)";
|
|
||||||
$context.UserName = "Manuel";
|
$context.UserName = "Manuel";
|
||||||
Invoke-WindowsInstallation $context;
|
Invoke-WindowsInstallation $context;
|
||||||
Restart-Computer -Force;
|
Restart-Computer -Force;
|
||||||
|
|
|
@ -3,10 +3,12 @@
|
||||||
. "$PSScriptRoot/Upgrade.ps1";
|
. "$PSScriptRoot/Upgrade.ps1";
|
||||||
. "$PSScriptRoot/User.ps1";
|
. "$PSScriptRoot/User.ps1";
|
||||||
. "$PSScriptRoot/../Scripts/Context.ps1";
|
. "$PSScriptRoot/../Scripts/Context.ps1";
|
||||||
|
. "$PSScriptRoot/../Scripts/Entrypoints.ps1";
|
||||||
. "$PSScriptRoot/../Software/Firefox/Install.ps1";
|
. "$PSScriptRoot/../Software/Firefox/Install.ps1";
|
||||||
|
|
||||||
function Invoke-WindowsInstallation([Context] $context)
|
function Invoke-WindowsInstallation([Context] $context)
|
||||||
{
|
{
|
||||||
|
$context.EntryPoint = Get-Entrypoint;
|
||||||
$configPath = "$PSScriptRoot/../Config";
|
$configPath = "$PSScriptRoot/../Config";
|
||||||
$softwarePath = "$PSScriptRoot/../Software";
|
$softwarePath = "$PSScriptRoot/../Software";
|
||||||
|
|
||||||
|
|
14
scripts/Windows/Scripts/Entrypoints.ps1
Normal file
14
scripts/Windows/Scripts/Entrypoints.ps1
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
function Get-Entrypoint() {
|
||||||
|
$stackTrace = Get-PSCallStack
|
||||||
|
$call = $stackTrace[$stackTrace.Count - 1];
|
||||||
|
|
||||||
|
if ($null -ne $call.ScriptName) {
|
||||||
|
return $call.ScriptName;
|
||||||
|
} else {
|
||||||
|
$call = $CallStack[$CallStack.Count - 2];
|
||||||
|
return $call.ScriptName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
throw "No PowerShell entry point script could be found.";
|
||||||
|
}
|
Loading…
Reference in a new issue