functions/Set-BBRESTConfig.ps1
function Set-BBRESTConfig { <# .SYNOPSIS Sets the default Blackboard REST API configurations for your Learn Environment to the config.json and then imports those settings into the current environment. .DESCRIPTION Sets the default Blackboard REST API configurations for your Learn Environment. Sets the default Blackboard REST API configurations for your Learn Environment to the config.json and then imports those settings into the current environment. .EXAMPLE Set-BBRESTConfig -ProductionClientURL 'https://blackbord.cmich.edu' -ClientID '' -ClientSecret '' #> [CmdletBinding()] Param( [ValidateNotNullOrEmpty()] [String] $ProductionClientURL, [ValidateNotNullOrEmpty()] [String] $TestClientURL, [ValidateNotNullOrEmpty()] [String] $ClientID, [ValidateNotNullOrEmpty()] [String] $ClientSecret ) try { Write-Verbose -Message 'Trying Get-BBRESTConfig before Set-BBRESTConfig.' $config = Get-Content -Path "$($PSScriptRoot | Split-Path -Parent)\config.json" -ErrorAction 'Stop' | ConvertFrom-Json Write-Verbose -Message 'Stored config.json found.' } catch { Write-Verbose -Message 'No configuration found - starting with empty configuration.' $config = @{ ProductionClientURL = "" TestClientURL = "" ClientID = "" ClientSecret = "" } } if ($ProductionClientURL) {$config.ProductionClientURL = $ProductionClientURL} if ($TestClientURL) {$config.TestClientURL = $TestClientURL} if ($ClientID) {$config.ClientID = $ClientID} if ($ClientSecret) {$config.ClientSecret = $ClientSecret} Write-Verbose -Message 'Setting config.json.' $config | ConvertTo-Json | Set-Content -Path "$($PSScriptRoot | Split-Path -Parent)\config.json" Import-BBRESTConfig } |