Remove hooks support from PS scripts
This commit is contained in:
parent
d9d1575a19
commit
db3955a090
3 changed files with 25 additions and 60 deletions
|
@ -4,7 +4,6 @@ $null = New-Module {
|
||||||
. "$PSScriptRoot/Scripting.ps1";
|
. "$PSScriptRoot/Scripting.ps1";
|
||||||
. "$PSScriptRoot/SoftwareManagement.ps1";
|
. "$PSScriptRoot/SoftwareManagement.ps1";
|
||||||
. "$PSScriptRoot/../../Windows/Scripts/Constants.ps1";
|
. "$PSScriptRoot/../../Windows/Scripts/Constants.ps1";
|
||||||
. "$PSScriptRoot/../../Windows/Scripts/Hooks.ps1";
|
|
||||||
. "$PSScriptRoot/../../Windows/Scripts/PowerManagement.ps1";
|
. "$PSScriptRoot/../../Windows/Scripts/PowerManagement.ps1";
|
||||||
. "$PSScriptRoot/../../Windows/Scripts/Registry.ps1";
|
. "$PSScriptRoot/../../Windows/Scripts/Registry.ps1";
|
||||||
. "$PSScriptRoot/../../Windows/Scripts/Security.ps1";
|
. "$PSScriptRoot/../../Windows/Scripts/Security.ps1";
|
||||||
|
@ -92,23 +91,19 @@ $null = New-Module {
|
||||||
while (-not $initialized) {
|
while (-not $initialized) {
|
||||||
if ($IsWindows) {
|
if ($IsWindows) {
|
||||||
if (-not ((Test-Command "choco") -and (Test-Command "refreshenv"))) {
|
if (-not ((Test-Command "choco") -and (Test-Command "refreshenv"))) {
|
||||||
Invoke-Hook "Install-Chocolatey" -Fallback {
|
|
||||||
# Install chocolatey
|
# Install chocolatey
|
||||||
|
Write-Host "Installing Chocolatey…";
|
||||||
New-Item -Force $PROFILE;
|
New-Item -Force $PROFILE;
|
||||||
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
|
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
|
||||||
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'));
|
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'));
|
||||||
Import-Module $env:ChocolateyInstall/helpers/chocolateyProfile.psm1;
|
Import-Module $env:ChocolateyInstall/helpers/chocolateyProfile.psm1;
|
||||||
refreshenv;
|
refreshenv;
|
||||||
};
|
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-not (Test-ChocoPackage "powershell-core")) {
|
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"';
|
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;
|
Restart-Intermediate;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -260,7 +255,8 @@ $null = New-Module {
|
||||||
. "$PSScriptRoot/../../Windows/Software/PinnedItem/Manage.ps1";
|
. "$PSScriptRoot/../../Windows/Software/PinnedItem/Manage.ps1";
|
||||||
}
|
}
|
||||||
|
|
||||||
Invoke-Hook "Install-PSModules" -Fallback {
|
Write-Host "Installing PowerShell Modules…";
|
||||||
|
|
||||||
foreach ($module in (Get-RequiredModules)) {
|
foreach ($module in (Get-RequiredModules)) {
|
||||||
$parameters = @{ };
|
$parameters = @{ };
|
||||||
|
|
||||||
|
@ -277,7 +273,6 @@ $null = New-Module {
|
||||||
Import-Module $module[0];
|
Import-Module $module[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
if (-not $env:CONFIG_NAME) {
|
if (-not $env:CONFIG_NAME) {
|
||||||
Show-ProfileNamePrompt;
|
Show-ProfileNamePrompt;
|
||||||
|
|
|
@ -7,7 +7,6 @@ using namespace System.Security.Principal;
|
||||||
$null = New-Module {
|
$null = New-Module {
|
||||||
. "$PSScriptRoot/../Scripts/Constants.ps1";
|
. "$PSScriptRoot/../Scripts/Constants.ps1";
|
||||||
. "$PSScriptRoot/../Scripts/Deployment.ps1";
|
. "$PSScriptRoot/../Scripts/Deployment.ps1";
|
||||||
. "$PSScriptRoot/../Scripts/Hooks.ps1";
|
|
||||||
. "$PSScriptRoot/../Scripts/PowerManagement.ps1";
|
. "$PSScriptRoot/../Scripts/PowerManagement.ps1";
|
||||||
. "$PSScriptRoot/../Scripts/Registry.ps1";
|
. "$PSScriptRoot/../Scripts/Registry.ps1";
|
||||||
. "$PSScriptRoot/../Scripts/Security.ps1";
|
. "$PSScriptRoot/../Scripts/Security.ps1";
|
||||||
|
@ -80,10 +79,7 @@ $null = New-Module {
|
||||||
while (-not (Get-IsFinished)) {
|
while (-not (Get-IsFinished)) {
|
||||||
if (Test-Admin) {
|
if (Test-Admin) {
|
||||||
$null = Import-Module PSWindowsUpdate;
|
$null = Import-Module PSWindowsUpdate;
|
||||||
|
|
||||||
Invoke-Hook "Invoke-WindowsUpdate" -Fallback {
|
|
||||||
Update-WindowsInstallation;
|
Update-WindowsInstallation;
|
||||||
};
|
|
||||||
|
|
||||||
if ((Get-WURebootStatus -Silent)) {
|
if ((Get-WURebootStatus -Silent)) {
|
||||||
Restart-Intermediate;
|
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