IntelliSearch.psm1
#requires -version 4 #requires -RunAsAdministrator #requires -Modules powershell-yaml function ModuleRoot { $MyInvocation.ScriptName | Split-Path -Parent } # Removes the Zone Identifier from the files. # This is to help with importing the .dll files, .ps1 files and other executables Get-Item -Path ".\*" -Stream Zone.Identifier -ErrorAction:SilentlyContinue | Remove-Item -ErrorAction:SilentlyContinue $Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue ) $Private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue ) foreach($import in @($Public + $Private)) { try { Write-Verbose "Importing cmdlet $($import.fullname)" . $import.fullname } catch { Write-Error -Message "Failed to import function $($import.fullname): $_" } } Write-Verbose "Exporting cmdlets" Export-ModuleMember -Function $Public.BaseName #region Load config file $IS_SettingsPath = Join-Path $Env:ProgramData "\IntelliSearch\.IntelliShell\settings.config" if ( -not (Test-Path $IS_SettingsPath)) { $IS_SettingsFile = New-Item -Path $IS_SettingsPath -ItemType File -Force $IS_SettingsFile.Directory.Attributes = $IS_SettingsFile.Directory.Attributes -bor [io.fileattributes]::Hidden } $IS_Settings = ConvertFrom-Yaml -Yaml (Get-Content $IS_SettingsPath -Raw) if ($IS_Settings -eq $null) { $IS_Settings = New-Object -TypeName System.Collections.Hashtable } $IS_Settings.InstanceStore = if ($IS_Settings.InstanceStore) {$IS_Settings.InstanceStore} else {(Join-Path $env:ProgramData "\IntelliSearch")} $IS_Settings.ComponentStore = if ($IS_Settings.ComponentStore) {$IS_Settings.ComponentStore} else {(Join-Path $env:ProgramFiles "\IntelliSearch")} $IS_Settings.InstanceCreationPluginStore = if ($IS_Settings.InstanceCreationPluginStore) {$IS_Settings.InstanceCreationPluginStore} else {@((Join-Path (ModuleRoot) "\InstanceCreationPlugins"))} Write-Verbose "Loaded settings file with following key-values:" foreach ($Key in $IS_Settings.GetEnumerator()) { Write-Verbose ("${Key}: $($IS_Settings.$Key)") } Export-ModuleMember -Variable "IS_Settings" #endregion Load config file |