PowerShell_Scripts/base/profile.d/EnsureJoinString.ps1

12 lines
602 B
PowerShell
Raw Normal View History

if( -not (Get-Command -ListImported Join-String -ErrorAction SilentlyContinue) ) {
if( -not (Get-Module -ListAvailable -Name "string") ) {
Write-Warning 'Join-String Command is missing, attempting to install stirng module'
$local:moduleScope = "CurrentUser"
if( Test-IsAdmin ) { $moduleScope = "AllUsers" }
Install-Module -Name "string" -Scope $moduleScope -AllowClobber -ErrorAction SilentlyContinue
}
if( -not (Get-Module -ListAvailable -Name "string") ) {
Write-Error "Failed to locate/install the module 'string'"
}
Import-Module -Name "string" -Cmdlet "Join-String"
}