Remove hooks support from PS scripts
This commit is contained in:
parent
d9d1575a19
commit
db3955a090
|
@ -4,7 +4,6 @@ $null = New-Module {
|
|||
. "$PSScriptRoot/Scripting.ps1";
|
||||
. "$PSScriptRoot/SoftwareManagement.ps1";
|
||||
. "$PSScriptRoot/../../Windows/Scripts/Constants.ps1";
|
||||
. "$PSScriptRoot/../../Windows/Scripts/Hooks.ps1";
|
||||
. "$PSScriptRoot/../../Windows/Scripts/PowerManagement.ps1";
|
||||
. "$PSScriptRoot/../../Windows/Scripts/Registry.ps1";
|
||||
. "$PSScriptRoot/../../Windows/Scripts/Security.ps1";
|
||||
|
@ -92,23 +91,19 @@ $null = New-Module {
|
|||
while (-not $initialized) {
|
||||
if ($IsWindows) {
|
||||
if (-not ((Test-Command "choco") -and (Test-Command "refreshenv"))) {
|
||||
Invoke-Hook "Install-Chocolatey" -Fallback {
|
||||
# Install chocolatey
|
||||
New-Item -Force $PROFILE;
|
||||
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
|
||||
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'));
|
||||
Import-Module $env:ChocolateyInstall/helpers/chocolateyProfile.psm1;
|
||||
refreshenv;
|
||||
};
|
||||
|
||||
# Install chocolatey
|
||||
Write-Host "Installing Chocolatey…";
|
||||
New-Item -Force $PROFILE;
|
||||
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
|
||||
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'));
|
||||
Import-Module $env:ChocolateyInstall/helpers/chocolateyProfile.psm1;
|
||||
refreshenv;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (-not (Test-ChocoPackage "powershell-core")) {
|
||||
Invoke-Hook "Install-PowerShellCore" -Fallback {
|
||||
choco install -y powershell-core --install-arguments='"ADD_FILE_CONTEXT_MENU_RUNPOWERSHELL=1 ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 REGISTER_MANIFEST=1 USER_MU=1 ENABLE_MU=1"';
|
||||
};
|
||||
|
||||
Write-Host "Installing PowerShell Core…";
|
||||
choco install -y powershell-core --install-arguments='"ADD_FILE_CONTEXT_MENU_RUNPOWERSHELL=1 ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 REGISTER_MANIFEST=1 USER_MU=1 ENABLE_MU=1"';
|
||||
Restart-Intermediate;
|
||||
return;
|
||||
}
|
||||
|
@ -260,24 +255,24 @@ $null = New-Module {
|
|||
. "$PSScriptRoot/../../Windows/Software/PinnedItem/Manage.ps1";
|
||||
}
|
||||
|
||||
Invoke-Hook "Install-PSModules" -Fallback {
|
||||
foreach ($module in (Get-RequiredModules)) {
|
||||
$parameters = @{ };
|
||||
Write-Host "Installing PowerShell Modules…";
|
||||
|
||||
if ($module -is [string]) {
|
||||
$module = @($module);
|
||||
}
|
||||
foreach ($module in (Get-RequiredModules)) {
|
||||
$parameters = @{ };
|
||||
|
||||
if ($module[1]) {
|
||||
$parameters = @("-AllowPrerelease");
|
||||
}
|
||||
|
||||
if (-not (Test-PSModule $module[0])) {
|
||||
sudo pwsh -Command Install-Module -Scope AllUsers -AcceptLicense -Force -AllowClobber $module[0] @parameters;
|
||||
Import-Module $module[0];
|
||||
}
|
||||
if ($module -is [string]) {
|
||||
$module = @($module);
|
||||
}
|
||||
};
|
||||
|
||||
if ($module[1]) {
|
||||
$parameters = @("-AllowPrerelease");
|
||||
}
|
||||
|
||||
if (-not (Test-PSModule $module[0])) {
|
||||
sudo pwsh -Command Install-Module -Scope AllUsers -AcceptLicense -Force -AllowClobber $module[0] @parameters;
|
||||
Import-Module $module[0];
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $env:CONFIG_NAME) {
|
||||
Show-ProfileNamePrompt;
|
||||
|
|
|
@ -7,7 +7,6 @@ using namespace System.Security.Principal;
|
|||
$null = New-Module {
|
||||
. "$PSScriptRoot/../Scripts/Constants.ps1";
|
||||
. "$PSScriptRoot/../Scripts/Deployment.ps1";
|
||||
. "$PSScriptRoot/../Scripts/Hooks.ps1";
|
||||
. "$PSScriptRoot/../Scripts/PowerManagement.ps1";
|
||||
. "$PSScriptRoot/../Scripts/Registry.ps1";
|
||||
. "$PSScriptRoot/../Scripts/Security.ps1";
|
||||
|
@ -80,10 +79,7 @@ $null = New-Module {
|
|||
while (-not (Get-IsFinished)) {
|
||||
if (Test-Admin) {
|
||||
$null = Import-Module PSWindowsUpdate;
|
||||
|
||||
Invoke-Hook "Invoke-WindowsUpdate" -Fallback {
|
||||
Update-WindowsInstallation;
|
||||
};
|
||||
Update-WindowsInstallation;
|
||||
|
||||
if ((Get-WURebootStatus -Silent)) {
|
||||
Restart-Intermediate;
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
function Invoke-Hook() {
|
||||
param(
|
||||
[string] $Name,
|
||||
[scriptblock] $Fallback
|
||||
)
|
||||
|
||||
if ($Fallback) {
|
||||
$scriptBlock = $Fallback;
|
||||
} else {
|
||||
$scriptBlock = { };
|
||||
}
|
||||
|
||||
if (Get-Command "$Name" -ErrorAction SilentlyContinue) {
|
||||
$parameters = {
|
||||
fallback = $scriptBlock;
|
||||
};
|
||||
|
||||
Write-Host "Running Hook ``$Name``";
|
||||
& "$Name" @parameters;
|
||||
} elseif ($Fallback) {
|
||||
Write-Host "Running Default of Hook ``$Name``";
|
||||
& $scriptBlock;
|
||||
} else {
|
||||
Write-Host "Hook ``$Name``";
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue