Ensure the KnownFolders
module is imported before use
This commit is contained in:
parent
ba1d13d7ee
commit
1b87ddfabb
5 changed files with 23 additions and 3 deletions
scripts/Windows/Scripts
3
scripts/Windows/Scripts/KnownFolders.ps1
Normal file
3
scripts/Windows/Scripts/KnownFolders.ps1
Normal file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/pwsh
|
||||
. "$PSScriptRoot/Modules.ps1" KnownFolders;
|
||||
Import-Module KnownFolders;
|
17
scripts/Windows/Scripts/Modules.ps1
Normal file
17
scripts/Windows/Scripts/Modules.ps1
Normal 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";
|
||||
}
|
||||
}
|
|
@ -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))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue