-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
OpenProviderPowershell.psm1
32 lines (30 loc) · 1.01 KB
/
OpenProviderPowershell.psm1
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
#region discover module name
$ScriptPath = Split-Path $MyInvocation.MyCommand.Path
$ModuleName = $ExecutionContext.SessionState.Module
Write-Verbose "Loading module $ModuleName"
#endregion discover module name
#load variables for module
Write-Verbose "Creating modules variables"
$opSessionData = [ordered]@{
Uri = "https://api.openprovider.eu/v1beta/"
AuthToken = $null
TimeToRefresh = $null
}
# New-Variable -Name OpenProviderSession -Value $opSessionData -Scope Script -Force
$script:OpenProviderSession = $opSessionData
#end of variables
#load functions
try {
foreach ($Scope in 'Public', 'Private') {
Get-ChildItem (Join-Path -Path $ScriptPath -ChildPath $Scope) -Recurse -Filter "func_*.ps1" | ForEach-Object {
. $_.FullName
if ($Scope -eq 'Public') {
Export-ModuleMember -Function ($_.BaseName -Split "_")[1] -ErrorAction Stop
}
}
}
}
catch {
Write-Error ("{0}: {1}" -f $_.BaseName, $_.Exception.Message)
exit 1
}