winutil/functions/public/Invoke-WinUtilInitializeModule.ps1
MyDrift f8b7f626d8 refractor
- refractor scans into one function
- create Invoke-WinUtilInitializeModule Function & use it accordingly
- refractor Update Installation process
- refractor DataGrid Item-management through Itemsource for better Main Thread performance
2025-03-08 09:49:05 +01:00

29 lines
917 B
PowerShell

function Invoke-WinUtilInitializeModule {
<#
.SYNOPSIS
Initializes and imports a specified PowerShell module.
.PARAMETER module
The name of the module to be installed and imported. If the module is not already available, it will be installed for the current user.
#>
param (
[string]$module
)
Invoke-WPFRunspace -ArgumentList $module -DebugPreference $DebugPreference -ScriptBlock {
param ($module)
try {
if (-not (Get-Module -ListAvailable -Name $module)) {
Write-Host "Installing $module module..."
Install-Module -Name $module -Force -Scope CurrentUser
}
Import-Module $module -ErrorAction Stop
Write-Host "Imported $module module successfully"
} catch {
Write-Host "Error importing $module module: $_" -ForegroundColor Red
}
}
}