internal/Import-BBRESTConfig.ps1
function Import-BBRESTConfig { <# .SYNOPSIS Get the default Blackboard REST API configurations for your Learn Environment. .DESCRIPTION Get the default Blackboard REST API configurations for your Learn Environment. .EXAMPLE Get-BBRESTConfig Get-BBRESTConfig -Passthrough #> [CmdletBinding()] Param() Try{ Write-Verbose "$($PSScriptRoot | Split-Path -Parent)\config.json" Write-Verbose -Message "Gettting content of config.json and returning as a PSCustomObject" $config = Get-Content -Path "$($PSScriptRoot | Split-Path -Parent)\config.json" -ErrorAction "Stop" | ConvertFrom-Json if ($PassThru){ return $config } else { #region load module variables Write-Verbose "Creating module variables" $BBRestVariables.ClientUrl = $config.ClientUrl $BBRestVariables.ClientID = $config.ClientID $BBRestVariables.ClientSecret = $config.ClientSecret #endregion load module variables } } catch { Set-BBRestConfig throw "Can't find the JSON configuration file. Attempting to create a blank config.json. If this fails, you'll want to load the module in an administrative powershell window, Reload the module twice, and wse Set-BBRESTConfig to set your configs." } } |