PowerShell_Scripts/base/profile.d/EnsureJoinString.ps1

13 lines
603 B
PowerShell

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 string 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"
}