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
This commit is contained in:
MyDrift
2025-03-08 09:49:05 +01:00
parent 27a97e4650
commit f8b7f626d8
9 changed files with 280 additions and 199 deletions

View File

@ -0,0 +1,28 @@
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
}
}
}