Public/Get-MDSConfiguration.ps1
function Get-MDSConfiguration { <# .SYNOPSIS Set module configuration variables .DESCRIPTION Some functions in the module require variables that are unique to the environment. This function displays the configuration variables. .EXAMPLE Get-MDSConfiguration List the module configuration file .NOTES Uses the 'Configuration' module by Joel Bennett (https://www.powershellgallery.com/packages/Configuration) #> [cmdletbinding()] param( [ValidateSet("ADConnectServer","SkypeOnPremServer","ErrorTest")] [Parameter()] [String]$Setting ) begin {} process { $Configuration = Import-Configuration If ($Setting) { $ConfigSetting = $Configuration[$Setting] If (-not $ConfigSetting) { Throw "The module configuration does not have $Setting configured. Use 'Set-MDSConfiguration -Name $Setting -Value <string>' to configure your settings." } Return $ConfigSetting } If ($Configuration.count -eq 0) { Throw "Thank you for using the MDS Tools module. Please run Set-MDSConfiguration to configure the module settings." } Return $Configuration } end {} } |