eNLib module installation script
    Copies module files to PATH diectory. by default choses user directory.
    use -useGlobalModuleFolder parameter to install for all users. requires to be run
    from elevated console.
    copies module files to user module folder
    .\install-eNLibModule.ps1 -useGlobalModuleFolder
    copies module files to global module folder. must be run in eveleted mode.
    nExoR ::))o-
    version 210208
        last changes
        - 210208 run using relative path fix
        - 201019 initialized

param (
if($useGlobalModuleFolder) {
    $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
    if(-not $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) ) {
        write-host 'you need to run console in elevated mode in order to copy module to global path' -ForegroundColor Red
        exit -1
    $moduleFolder="C:\Program Files\WindowsPowerShell\Modules"

} else {
    $moduleFolder = [string]($Env:PSModulePath -split ';'|select-string $env:username)
    if( [string]::IsNullOrEmpty($moduleFolder) ) {
        write-host 'user module folder not defined. please change $PSModulePath variable to include your folder name
or use -useGlobalMOduleFolder parameter'
 -ForegroundColor Yellow
        write-host -ForegroundColor Red "not installed."
        exit -2

remove-module -name eNLib -ErrorAction SilentlyContinue

try {
    if(-not (test-path $eNLibFolder) ) {
        new-item -Type Directory $eNLibFolder|Out-Null 
    $sourceFolder = get-item $MyInvocation.InvocationName
    Copy-Item -Path "$($sourceFolder.Directory.FullName)\*.psd1","$($sourceFolder.Directory.FullName)\*.psm1" -Destination $eNLibFolder
} catch {
Get-ChildItem $eNLibFolder
write-host "files copied to $eNLibFolder." -ForegroundColor Green