PSData.ImportUtility.psm1

function Import-PowerShellData {
    <#
        .SYNOPSIS
            Loads data from *.psd1 files to variable.
 
        .DESCRIPTION
            Wrapper around 'Import-PowerShellDataFile' Cmdlet. Loads Data to a variable sharing its name with the base filename of the Data File.
 
        .PARAMETER Path
            Specifies the path to a valid *.psd1 (PowerShell Data) file.
 
        .PARAMETER Scope
            Specifies the variable scope. (Global,Local,Script)
 
        .EXAMPLE
            PS> Import-PowerShellData -Path 'C:\path\to\some\foo.psd1'
            PS> $foo
     
        .EXAMPLE
            PS> Import-PowerShellData -Path 'C:\another\path\to\some\bar.psd1'
            PS> $bar
 
        .LINK
            about_PSDataImportUtility
    #>

    param(
        [Parameter(Mandatory)]
        [ValidatePattern("[A-Za-z]+\.psd1")]
        [string]$Path,
        [ValidateSet('Global','Script','Local')]
        [string]$Scope = 'Global'
    )

    $FileName = Split-Path $Path -leaf 
    $FileName = $FileName -replace '.psd1',''

    $PSData = Import-PowerShellDataFile -Path $Path 

    New-Variable -Name $FileName -Value $PSData -Scope $Scope

}