-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-IniBool.ps1
More file actions
55 lines (46 loc) · 1.8 KB
/
Get-IniBool.ps1
File metadata and controls
55 lines (46 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function Get-IniBool {
[CmdletBinding()]
param(
[Parameter(Mandatory = $false)]
[string]$section = $(Throw ((Get-ResStr 'PARAM_MANDATORY_MISSED') -f 'section', $myInvocation.Mycommand))
,
[Parameter(Mandatory = $false)]
[string]$variable = $(Throw ((Get-ResStr 'PARAM_MANDATORY_MISSED') -f 'variable', $myInvocation.Mycommand))
)
begin {
Write-Verbose -Message ((Get-ResStr 'STARTING_FUNCTION') -f $myInvocation.Mycommand)
New-Variable -Name 'result' -Scope 'Private' -Value ([boolean]$false)
$initialVariables = Get-CurrentVariables -Debug:$DebugPreference
}
process {
if (test-path variable:global:ini) {
[string]$test = $global:ini[$section][$variable]
$result = Get-Bool -boolStr $test
} else {
$result = $false
}
}
end {
Get-CurrentVariables -InitialVariables $initialVariables -Debug:$DebugPreference
Return $result
}
<# Test:
$pesterFolder = Resolve-Path -path ".\source\tests"
$iniPath = Join-Path -path $pesterFolder "pester.ini"
$ini = Read-IniFile -path $iniPath
# Should be all true
$testBool = Get-IniBool -section 'PESTERTEST' -variable 'TrueBool'
# or
$testBool = Get-IniBool -section 'PESTERTEST' -variable 'TrueOne'
# or
$testBool = Get-IniBool -section 'PESTERTEST' -variable 'TrueDollarBool'
# Should be all false
$testBool = Get-IniBool -section 'PESTERTEST' -variable 'FalseBool'
# or
$testBool = Get-IniBool -section 'PESTERTEST' -variable 'FalseZero'
# or
$testBool = Get-IniBool -section 'PESTERTEST' -variable 'FalseDollarBool'
# General
Get-IniBool -section 'Settings' -variable 'Name'
#>
}