Skip to content

Commit cab3b2f

Browse files
committed
fix
1 parent 24aaba1 commit cab3b2f

3 files changed

Lines changed: 49 additions & 33 deletions

File tree

fscps.tools/fscps.tools.psm1

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,24 @@ function Import-ModuleFile
4545
$Path
4646
)
4747

48-
$resolvedPath = $ExecutionContext.SessionState.Path.GetResolvedPSPathFromPSPath($Path).ProviderPath
49-
if ($doDotSource) { . $resolvedPath }
50-
else { $ExecutionContext.InvokeCommand.InvokeScript($false, ([scriptblock]::Create([io.file]::ReadAllText($resolvedPath))), $null, $null) }
48+
try {
49+
$resolvedPath = $ExecutionContext.SessionState.Path.GetResolvedPSPathFromPSPath($Path).ProviderPath
50+
if ($script:doDotSource) {
51+
. $resolvedPath
52+
}
53+
else {
54+
$content = [io.file]::ReadAllText($resolvedPath)
55+
if (-not [string]::IsNullOrWhiteSpace($content)) {
56+
$scriptBlock = [scriptblock]::Create($content)
57+
if ($scriptBlock) {
58+
$ExecutionContext.InvokeCommand.InvokeScript($false, $scriptBlock, $null, $null)
59+
}
60+
}
61+
}
62+
}
63+
catch {
64+
Write-Warning "Failed to import module file '$Path': $($_.Exception.Message)"
65+
}
5166
}
5267

5368

fscps.tools/functions/get-fscpsmodelversion.ps1

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,32 @@
2222
.NOTES
2323
Author: Oleksandr Nikolaiev (@onikolaiev)
2424
#>
25+
26+
# Helper function to convert layer number to layer name
27+
function Get-LayerName {
28+
param([int]$LayerNumber)
29+
30+
switch ($LayerNumber) {
31+
0 { return "SYS" }
32+
1 { return "SYP" }
33+
2 { return "GLS" }
34+
3 { return "GLP" }
35+
4 { return "FPK" }
36+
5 { return "FPP" }
37+
6 { return "SLN" }
38+
7 { return "SLP" }
39+
8 { return "ISV" }
40+
9 { return "ISP" }
41+
10 { return "VAR" }
42+
11 { return "VAP" }
43+
12 { return "CUS" }
44+
13 { return "CUP" }
45+
14 { return "USR" }
46+
15 { return "USP" }
47+
default { return "Unknown" }
48+
}
49+
}
50+
2551
function Get-FSCPSModelVersion {
2652
[CmdletBinding()]
2753
param(
@@ -37,31 +63,6 @@ function Get-FSCPSModelVersion {
3763
if (-not (Test-Path -LiteralPath $ModelPath -PathType Container)) {
3864
throw "Model path '$ModelPath' does not exist or is not a directory"
3965
}
40-
41-
# Function to convert layer number to layer name
42-
function Get-LayerName {
43-
param([int]$LayerNumber)
44-
45-
switch ($LayerNumber) {
46-
0 { return "SYS" }
47-
1 { return "SYP" }
48-
2 { return "GLS" }
49-
3 { return "GLP" }
50-
4 { return "FPK" }
51-
5 { return "FPP" }
52-
6 { return "SLN" }
53-
7 { return "SLP" }
54-
8 { return "ISV" }
55-
9 { return "ISP" }
56-
10 { return "VAR" }
57-
11 { return "VAP" }
58-
12 { return "CUS" }
59-
13 { return "CUP" }
60-
14 { return "USR" }
61-
15 { return "USP" }
62-
default { return "Unknown" }
63-
}
64-
}
6566
}
6667

6768
process{

fscps.tools/internal/functions/test-configstoreagelocation.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,24 @@
3030
#>
3131
function Test-ConfigStorageLocation {
3232
[CmdletBinding()]
33-
[OutputType('System.String')]
33+
[OutputType([PSFramework.Configuration.ConfigScope])]
3434
param (
3535
[ValidateSet('User', 'System')]
3636
[string] $ConfigStorageLocation = "User"
3737
)
3838

39-
$configScope = "UserDefault"
39+
$configScope = [PSFramework.Configuration.ConfigScope]::UserDefault
4040

4141
if ($ConfigStorageLocation -eq "System") {
4242
if ($Script:IsAdminRuntime) {
43-
$configScope = "SystemDefault"
43+
$configScope = [PSFramework.Configuration.ConfigScope]::SystemDefault
4444
}
4545
else {
4646
Write-PSFMessage -Level Host -Message "Unable to locate save the <c='em'>configuration objects</c> in the <c='em'>system wide configuration store</c> on the machine. Please start an elevated session and run the cmdlet again."
4747
Stop-PSFFunction -Message "Elevated permissions needed. Please start an elevated session and run the cmdlet again." -StepsUpward 1
48-
return
48+
return $null
4949
}
5050
}
5151

52-
$configScope
52+
return $configScope
5353
}

0 commit comments

Comments
 (0)