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
|
||||
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 {
|
||||
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,7 +255,8 @@ $null = New-Module {
|
|||
. "$PSScriptRoot/../../Windows/Software/PinnedItem/Manage.ps1";
|
||||
}
|
||||
|
||||
Invoke-Hook "Install-PSModules" -Fallback {
|
||||
Write-Host "Installing PowerShell Modules…";
|
||||
|
||||
foreach ($module in (Get-RequiredModules)) {
|
||||
$parameters = @{ };
|
||||
|
||||
|
@ -277,7 +273,6 @@ $null = New-Module {
|
|||
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;
|
||||
};
|
||||
|
||||
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