From d36969a44d008767225a127dfa80183182673837 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 22 Aug 2024 23:55:00 +0200 Subject: [PATCH] Allow skipping powershell module registration --- scripts/Common/Software/PowerShell/Module.ps1 | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/scripts/Common/Software/PowerShell/Module.ps1 b/scripts/Common/Software/PowerShell/Module.ps1 index 1f13c009..a9cc4113 100644 --- a/scripts/Common/Software/PowerShell/Module.ps1 +++ b/scripts/Common/Software/PowerShell/Module.ps1 @@ -8,11 +8,18 @@ $null = New-Module { .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] $NativeOnly, + [switch] $NoProfile ) @{ @@ -46,12 +53,14 @@ $null = New-Module { [hashtable] $Arguments ) - $name = $Arguments.Name; + if (-not $NoProfile) { + $name = $Arguments.Name; - Add-PowerShellProfileStatement ` - -DefaultUser ` - -Category $name ` - -Script "Import-Module `"$name`";"; + Add-PowerShellProfileStatement ` + -DefaultUser ` + -Category $name ` + -Script "Import-Module `"$name`";"; + } }; } }