Only install PowerShell module if necessary
This commit is contained in:
parent
6a457cff12
commit
9f1adf9829
|
@ -102,3 +102,18 @@ function Test-PSPackage {
|
||||||
|
|
||||||
[bool] (Get-Package $Name -ErrorAction SilentlyContinue);
|
[bool] (Get-Package $Name -ErrorAction SilentlyContinue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Checks whether a module with the specified name is installed.
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
The name of the module to check.
|
||||||
|
#>
|
||||||
|
function Test-PSModule {
|
||||||
|
param(
|
||||||
|
[string] $Name
|
||||||
|
)
|
||||||
|
|
||||||
|
[bool](Get-Module -ListAvailable $Name -ErrorAction SilentlyContinue);
|
||||||
|
}
|
||||||
|
|
|
@ -182,8 +182,10 @@ $null = New-Module {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Install-Module -Scope AllUsers -AcceptLicense -Force $module[0] @parameters;
|
if (-not (Test-PSModule $module[0])) {
|
||||||
Import-Module $module[0];
|
Install-Module -Scope AllUsers -AcceptLicense -Force -AllowClobber $module[0] @parameters;
|
||||||
|
Import-Module $module[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
. "$PSScriptRoot/../Software/PinnedItem/Manage.ps1";
|
. "$PSScriptRoot/../Software/PinnedItem/Manage.ps1";
|
||||||
|
|
Loading…
Reference in a new issue