SWMSPBackup.psm1
<#
File: SWMSPBackup.psm1 Author: Casper Stekelenburg Publisher: Casper Stekelenburg Copyright: (c) 2020 Casper Stekelenburg. All rights reserved. Usage: To load this module in PowerShell: Import-Module -Name SWMSPBAckup Notes: The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software. #> # Functions in this module: #Get public and private function definition files. $Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue ) $Private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue ) #Dot source the files Foreach ($import in @($Public + $Private)) { Try { . $import.fullname } Catch { Write-Error -Message "Failed to import function $($import.fullname): $_" } } # Here I might... # Read in or create an initial config file and variable # Export Public functions ($Public.BaseName) for WIP modules # Set variables visible to the module and its functions only $Script:BMPath = [Environment]::GetFolderPath('ProgramFiles') + "\Backup Manager" $Script:CmdPath = $Script:BMPath + "\ClientTool.exe" $Script:ConfigIni = "`"" + $Script:BMPath + "\config.ini" + "`"" $Script:StatusReport = [System.Environment]::GetEnvironmentVariable('ProgramData') + "\MXB\Backup Manager\StatusReport.xml" $Script:RemoveItemParams = @{ Path = "$stdOutTempFile, $stdErrTempFile" Force = $true ErrorAction = "SilentlyContinue" } $Script:StartProcessParams = @{ FilePath = $Script:CmdPath ArgumentList = $ArgArray Wait = $true NoNewWindow = $true PassThru = $true RedirectStandardOutput = $stdOutTempFile RedirectStandardError = $stdErrTempFile ErrorAction = "SilentlyContinue" } Export-ModuleMember -Function $Public.Basename -Alias * -Variable * -Cmdlet * |