2022-10-27 21:20:03 +01:00
|
|
|
function Get_Profiles ([string]$kind_id) {
|
2022-06-25 23:12:02 +01:00
|
|
|
$basepath = Join-Path -Path $(Split-Path -Path $PSScriptRoot) -ChildPath "profiles"
|
|
|
|
if (Test-Path $basepath) {
|
|
|
|
$fullpath = Join-Path -Path $basepath -ChildPath $kind_id
|
|
|
|
}
|
|
|
|
else { return $null }
|
|
|
|
$filenames = @(Get-ChildItem -Path $fullpath -Filter *.psd1 -Recurse -File)
|
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
[hashtable]$data = @{}
|
2022-06-25 23:12:02 +01:00
|
|
|
if ($filenames) {
|
|
|
|
$filenames | ForEach-Object {
|
|
|
|
(Join-Path -Path $fullpath -ChildPath $_) | ForEach-Object {
|
|
|
|
$filename = [System.IO.Path]::GetFileNameWithoutExtension($_)
|
|
|
|
Write-Host ("Importing profile " + $kind_id + "/" + $filename)
|
|
|
|
$data[$filename] = Import-PowerShellDataFile -Path $_
|
|
|
|
}
|
|
|
|
}
|
2022-10-27 21:20:03 +01:00
|
|
|
return $data
|
2022-06-25 23:12:02 +01:00
|
|
|
}
|
|
|
|
return $null
|
|
|
|
}
|
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
function Set_Profile {
|
2022-06-25 23:12:02 +01:00
|
|
|
param(
|
2022-10-27 21:20:03 +01:00
|
|
|
[Object]$DATA, [string]$CONF
|
2022-06-25 23:12:02 +01:00
|
|
|
)
|
2023-08-16 16:36:43 +01:00
|
|
|
if ($null -eq $DATA -or -not $DATA.$CONF) {
|
|
|
|
throw [VMRemoteErrors]::new("No profile named '$CONF' has been loaded into memory.")
|
2022-06-25 23:12:02 +01:00
|
|
|
}
|
2023-08-16 16:36:43 +01:00
|
|
|
Param_Set_Multi -HASH $DATA.$CONF
|
|
|
|
Start-Sleep -m 1
|
2022-10-27 21:20:03 +01:00
|
|
|
}
|