PSUnraid.psm1
|
# Load the class definitions $classFile = Join-Path -Path $PSScriptRoot -ChildPath "classes\UnraidClasses.ps1" if (Test-Path $classFile) { try { . $classFile } catch { Write-Error "Classes failed to load from '$classFile': $_" throw } } else { throw "Can't find the class file at $classFile. Module is probably cooked." } # Variable to hold the active connection if (!$Script:DefaultUnraidSession) { $Script:DefaultUnraidSession = $null } # Init a cache for log names so we don't hammer the API on every tab press if (!$Script:UnraidLogCache) { $Script:UnraidLogCache = @{ Names = @() LastFetch = [DateTime]::MinValue } } # Ensure we can talk to modern servers without breaking legacy stuff in the user's session # We only add Tls12 if it's missing, rather than nuking existing settings $currentProtocol = [System.Net.ServicePointManager]::SecurityProtocol if ($currentProtocol -notmatch 'Tls12') { [System.Net.ServicePointManager]::SecurityProtocol = $currentProtocol -bor [System.Net.SecurityProtocolType]::Tls12 } # Source all the private helper functions $privateFuncs = Join-Path -Path $PSScriptRoot -ChildPath "private\*.ps1" Get-ChildItem -Path $privateFuncs | ForEach-Object { try { . $_.FullName } catch { Write-Error "Private function failed to load [$($_.Name)]: $_" } } # Source the public cmdlets $publicFuncs = Join-Path -Path $PSScriptRoot -ChildPath "public\*.ps1" Get-ChildItem -Path $publicFuncs | ForEach-Object { try { . $_.FullName } catch { Write-Error "Public function failed to load [$($_.Name)]: $_" } } Export-ModuleMember -Function Connect-*, Disconnect-*, Save-*, Get-*, Start-*, Stop-*, Restart-*, Suspend-*, Resume-*, Set-*, Remove-* # Aliases because I keep typing "Docker" instead of "Container" New-Alias -Name Get-UnraidDocker -Value Get-UnraidContainer New-Alias -Name Start-UnraidDocker -Value Start-UnraidContainer New-Alias -Name Stop-UnraidDocker -Value Stop-UnraidContainer New-Alias -Name Restart-UnraidDocker -Value Restart-UnraidContainer Export-ModuleMember -Alias Get-UnraidDocker, Start-UnraidDocker, Stop-UnraidDocker, Restart-UnraidDocker |