. "$PSScriptRoot/../../Software/PowerShell/Profile.ps1"; . "$PSScriptRoot/../../Types/InstallerAction.ps1"; $null = New-Module { <# .SYNOPSIS Generates the components for creating a module installer. .PARAMETER Name The name of the module to install. .PARAMETER NativeOnly A value indicating whether the module is installed in Windows PowerShell only. .PARAMETER NoProfile A value indicating whether the module is not added to the profile script of users. #> function Get-ModuleInstallerComponents { param( [string] $Name, [switch] $NativeOnly, [switch] $NoProfile ) @{ arguments = @{ name = $Name; nativeOnly = $NativeOnly; }; installer = { param( [scriptblock] $Installer, [hashtable] $Arguments ) $env:PENDING_MODULE_NAME = $Arguments.Name; $installAction = { Install-Module -Scope AllUsers -Force $env:PENDING_MODULE_NAME @args }; if (-not $Arguments.NativeOnly) { & $installAction -AcceptLicense; } if (Test-Command powershell) { powershell -c ($installAction.ToString()); } Remove-Item Env:\PENDING_MODULE_NAME; & $Installer -Action ([InstallerAction]::Configure) @PSBoundParameters; }; configurator = { param( [hashtable] $Arguments ) if (-not $NoProfile) { $name = $Arguments.Name; Add-PowerShellProfileStatement ` -DefaultUser ` -Category $name ` -Script "Import-Module `"$name`";"; } }; } } };