Ensure the KnownFolders module is imported before use

This commit is contained in:
Manuel Thalmann 2024-03-24 15:18:01 +01:00
parent 57bb8cf830
commit ff211d89ae
5 changed files with 23 additions and 3 deletions

View file

@ -0,0 +1,3 @@
#!/bin/pwsh
. "$PSScriptRoot/Modules.ps1" KnownFolders;
Import-Module KnownFolders;

View file

@ -0,0 +1,17 @@
#!/bin/pwsh
param (
[string]$ModuleName,
[switch]$WindowsPowerShell
)
if ($WindowsPowerShell) {
if (-not (powershell -c Get-Module -ListAvailable $ModuleName)) {
Write-Host "Installing Windows PowerShell Module $ModuleName";
powershell -c Install-Module -Force "$ModuleName";
}
} else {
if (-not (Get-Module -ListAvailable $ModuleName)) {
Write-Host "Installing PowerShell Module $ModuleName";
Install-Module -AcceptLicense -Force "$ModuleName";
}
}

View file

@ -9,7 +9,7 @@ if (-not $?) {
powershell -c '$null = Install-PackageProvider -Name NuGet -Force';
}
foreach ($module in @("PSWindowsUpdate", "KnownFolders"))
foreach ($module in @("PSWindowsUpdate"))
{
if (-not (Get-Module -ListAvailable $module))
{

View file

@ -1,8 +1,8 @@
#!/bin/pwsh
. "$PSScriptRoot/../../Scripts/KnownFolders.ps1";
. "$PSScriptRoot/../../Scripts/Context.ps1";
$null = New-Module {
Import-Module "KnownFolders";
Import-Module "$env:ChocolateyInstall/helpers/chocolateyInstaller.psm1";
$path = "C:/tools/RetroArch-Win64";
$softwareName = "RetroArch";

View file

@ -1,5 +1,5 @@
#!/bin/pwsh
Import-Module "KnownFolders";
. "$PSScriptRoot/../../Scripts/KnownFolders.ps1";
. "$PSScriptRoot/../../Scripts/Context.ps1";
$null = New-Module {